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

Submitted by Konstantin Khorenko on Nov. 3, 2020, 1:12 p.m.

Details

Message ID 202011031312.0A3DCSdg2050689@finist-co8.sw.ru
State New
Series "ve/proc/sched/stat: Virtualize /proc/stat in a Container"
Headers show

Commit Message

Konstantin Khorenko Nov. 3, 2020, 1:12 p.m.
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@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@virtuozzo.com>
    Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 include/linux/kernel_stat.h | 1 +
 kernel/sched/cpuacct.c      | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

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;
 }