[Devel] [PATCH RHEL8 COMMIT] ve/proc/stat: Introduce CPUTIME_USED field in cpustat statistic

Konstantin Khorenko khorenko at virtuozzo.com
Tue Nov 3 16:12:28 MSK 2020


The commit is pushed to "branch-rh8-4.18.0-193.6.3.vz8.4.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-193.6.3.vz8.4.15
------>
commit c15bffe2e2cdc0b2c7bd52f5c0dec58524e115e8
Author: Konstantin Khorenko <khorenko at virtuozzo.com>
Date:   Tue Nov 3 14:51:13 2020 +0300

    ve/proc/stat: Introduce CPUTIME_USED field in cpustat statistic
    
    It will be shown later in /proc/vestat file.
    
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
    Reviewed-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 include/linux/kernel_stat.h | 1 +
 kernel/sched/cpuacct.c      | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h
index 47b75b4be3d5..5a3851b1d771 100644
--- a/include/linux/kernel_stat.h
+++ b/include/linux/kernel_stat.h
@@ -25,6 +25,7 @@ enum cpu_usage_stat {
 	CPUTIME_IRQ,
 	CPUTIME_IDLE,
 	CPUTIME_IOWAIT,
+	CPUTIME_USED,
 	CPUTIME_STEAL,
 	CPUTIME_GUEST,
 	CPUTIME_GUEST_NICE,
diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c
index ed59607f2157..646bbd257110 100644
--- a/kernel/sched/cpuacct.c
+++ b/kernel/sched/cpuacct.c
@@ -428,7 +428,7 @@ static void cpu_cgroup_update_stat(struct cgroup_subsys_state *cpu_css,
 	struct sched_entity *se = tg->se[i];
 	u64 *cpustat = cpuacct_cpustat(cpuacct_css, i)->cpustat;
 	u64 now = cpu_clock(i);
-	u64 delta, idle, iowait, steal;
+	u64 delta, idle, iowait, steal, used;
 
 	/* root_task_group has not sched entities */
 	if (tg == &root_task_group)
@@ -437,6 +437,7 @@ static void cpu_cgroup_update_stat(struct cgroup_subsys_state *cpu_css,
 	iowait = se->statistics.iowait_sum;
 	idle = se->statistics.sum_sleep_runtime;
 	steal = se->statistics.wait_sum;
+	used = se->sum_exec_runtime;
 
 	if (idle > iowait)
 		idle -= iowait;
@@ -460,6 +461,7 @@ static void cpu_cgroup_update_stat(struct cgroup_subsys_state *cpu_css,
 	cpustat[CPUTIME_IDLE]	= max(cpustat[CPUTIME_IDLE], idle);
 	cpustat[CPUTIME_IOWAIT]	= max(cpustat[CPUTIME_IOWAIT], iowait);
 	cpustat[CPUTIME_STEAL]	= steal;
+	cpustat[CPUTIME_USED]	= used;
 #endif
 }
 
@@ -538,6 +540,8 @@ static void fixup_vcpustat_delta(struct kernel_cpustat *cur,
 					 cur_idle, target_idle);
 	}
 
+	cur->cpustat[CPUTIME_USED] = target_usage;
+
 	/* do not show steal time inside ve */
 	cur->cpustat[CPUTIME_STEAL] = 0;
 }


More information about the Devel mailing list