[Devel] [PATCH RHEL7 COMMIT] proc/cpu/cgroup: make boottime in CT reveal the real start time

Konstantin Khorenko khorenko at virtuozzo.com
Tue May 21 18:29:21 MSK 2019


The commit is pushed to "branch-rh7-3.10.0-957.12.2.vz7.96.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.12.2.vz7.96.1
------>
commit d822c01403c5eeed69a9e46ea26bcf7559f3603e
Author: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Date:   Tue May 21 18:29:19 2019 +0300

    proc/cpu/cgroup: make boottime in CT reveal the real start time
    
    When we call 'ps axfw -o pid,stime' in container to show the start time
    of processes of CT it looks like all of them are time travelers from the
    future, these happens in case the CT was recently migrated before.
    
    These happens because ps takes the start_time from /proc/<pid>/stat
    which should be relative to the boottime, so ps adds it to the boottime
    taken from /proc/stat and prints the results. But before these patch
    the boottime in /proc/stat in CT is just the time of cgroup creation
    (after migration), and the start_time in CT is relative to the real
    boottime of CT (before the migration).
    
    So make boottime in /proc/stat in CT be a real boottime of CT to fix
    these mess. Collateral damage is that we would always see host boottime
    in cpu.proc.stat files from host, but I don't think that cgroup creation
    times made any sense there anyway.
    
    https://jira.sw.ru/browse/PSBM-94263
    Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 kernel/sched/core.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 3d0d901e89bd..3e7c8004dafd 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -10433,7 +10433,13 @@ int cpu_cgroup_proc_stat(struct cgroup *cgrp, struct cftype *cft,
 	unsigned long tg_nr_forks = 0;
 
 	getboottime(&boottime);
-	jif = boottime.tv_sec + tg->start_time.tv_sec;
+
+	/*
+	 * In VE0 we always show host's boottime and in VEX we show real CT
+	 * start time, even across CT migrations, as we rely on userspace to
+	 * set real_start_timespec for us on resume.
+	 */
+	jif = boottime.tv_sec + get_exec_env()->real_start_timespec.tv_sec;
 
 	for_each_possible_cpu(i) {
 		cpu_cgroup_update_stat(cgrp, i);



More information about the Devel mailing list