[Devel] [PATCH RH7] proc/cpu/cgroup: make boottime in CT reveal the real start time
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Tue May 7 12:05:47 MSK 2019
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 800d295dc7d0..c35fcbef4397 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -10409,7 +10409,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);
--
2.20.1
More information about the Devel
mailing list