[rh8,2/3] ve/time/stat: idle time virtualization in /proc/loadavg

Submitted by Konstantin Khorenko on Oct. 30, 2020, 1:08 p.m.

Details

Message ID 20201030130852.2046899-2-khorenko@virtuozzo.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Konstantin Khorenko Oct. 30, 2020, 1:08 p.m.
The patch is based on following vz7 commits:
  a58fb58bff1c ("Use ve init task's css instead of opening cgroup via vfs")
  75fc174adc36 ("sched: Port cpustat related patches")

Fixes: a3c4d1d8f383 ("ve/time: Customize VE uptime")

TODO: to separate FIXME hunks from a3c4d1d8f383 ("ve/time: Customize VE
uptime") and merge them into this commit

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 fs/proc/uptime.c | 27 +++++++--------------------
 1 file changed, 7 insertions(+), 20 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/proc/uptime.c b/fs/proc/uptime.c
index bc07d42ce9f5..dae407953903 100644
--- a/fs/proc/uptime.c
+++ b/fs/proc/uptime.c
@@ -23,37 +23,24 @@  static inline void get_ve0_idle(struct timespec64 *idle)
 	idle->tv_nsec = rem;
 }
 
-static inline void get_veX_idle(struct timespec *idle, struct cgroup* cgrp)
+static inline void get_veX_idle(struct ve_struct *ve, struct timespec64 *idle)
 {
-#if 0
-FIXME:	to be reworked anyway in
-	"Use ve init task's css instead of opening cgroup via vfs"
-
 	struct kernel_cpustat kstat;
 
-	cpu_cgroup_get_stat(cgrp, &kstat);
-	*idle = ns_to_timespec(kstat.cpustat[CPUTIME_IDLE]);
-#endif
+	ve_get_cpu_stat(ve, &kstat);
+	*idle = ns_to_timespec64(kstat.cpustat[CPUTIME_IDLE]);
 }
 
 static int uptime_proc_show(struct seq_file *m, void *v)
 {
 	struct timespec uptime, offset;
 	struct timespec64 idle;
+	struct ve_struct *ve = get_exec_env();
 
-	if (ve_is_super(get_exec_env()))
-		get_ve0_idle(&idle);
-	else {
+	if (ve_is_super(ve))
 		get_ve0_idle(&idle);
-#if 0
-FIXME:  to be reworked anyway in
-        "Use ve init task's css instead of opening cgroup via vfs"
-
-		rcu_read_lock();
-		get_veX_idle(&idle, task_cgroup(current, cpu_cgroup_subsys_id));
-		rcu_read_unlock();
-#endif
-	}
+	else
+		get_veX_idle(ve, &idle);
 
 	get_monotonic_boottime(&uptime);
 #ifdef CONFIG_VE

Comments

Andrey Ryabinin Oct. 30, 2020, 4:41 p.m.
On 10/30/20 4:08 PM, Konstantin Khorenko wrote:
> The patch is based on following vz7 commits:
>   a58fb58bff1c ("Use ve init task's css instead of opening cgroup via vfs")
>   75fc174adc36 ("sched: Port cpustat related patches")
> 
> Fixes: a3c4d1d8f383 ("ve/time: Customize VE uptime")
> 
> TODO: to separate FIXME hunks from a3c4d1d8f383 ("ve/time: Customize VE
> uptime") and merge them into this commit
> 
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
> ---
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>