[Devel] [PATCH rh7 08/14] Port diff-ve-proc-report-real_start_time-in-_proc_PID_stat-if-CONFIG_VE

Vladimir Davydov vdavydov at parallels.com
Tue Jun 23 09:29:44 PDT 2015


Author: Vladimir Davydov
Email: vdavydov at parallels.com
Subject: proc: report real_start_time in /proc/PID/stat if CONFIG_VE
Date: Mon, 14 Oct 2013 19:04:59 +0400

In case !CONFIG_VE, real_start_time is reported, so should be if
CONFIG_VE is on.

The difference between start_time and real_start_time is that the former
is the monotonic time of process start while the latter is bootbased,
i.e. includes time the system was suspended and uptime from the previous
boot in case the system was vzrebooted. Reporting start_time instead of
real_start_time leads to a wrong process etime reported by ps after
vzreboot or system suspend/resume.

https://jira.sw.ru/browse/PSBM-22925

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
Acked-by: Stanislav Kinsbursky <skinsbursky at parallels.com>
=============================================================================

Author: Vladimir Davydov
Email: vdavydov at parallels.com
Subject: proc: fix negative start time in /proc/PID/stat
Date: Mon, 14 Oct 2013 19:05:01 +0400

Tasks inside a CT can have negative start time e.g. if the CT was
migrated from another hw node. In this case we'd better report 0 in
order not to confuse userspace and avoid warning trigger in
nsec_to_clock_t().

https://jira.sw.ru/browse/PSBM-22925

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
Acked-by: Stanislav Kinsbursky <skinsbursky at parallels.com>
=============================================================================

Related to https://jira.sw.ru/browse/PSBM-33650

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 fs/proc/array.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/fs/proc/array.c b/fs/proc/array.c
index 177e477b7224..32c7f1a5d9eb 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -538,17 +538,27 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
 	priority = task_prio(task);
 	nice = task_nice(task);
 
-#ifndef CONFIG_VE
 	/* Temporary variable needed for gcc-2.96 */
 	/* convert timespec -> nsec*/
 	start_time =
 		(unsigned long long)task->real_start_time.tv_sec * NSEC_PER_SEC
 				+ task->real_start_time.tv_nsec;
+#ifdef CONFIG_VE
+	if (!is_super) {
+		struct timespec *ve_start_ts =
+				&get_exec_env()->real_start_timespec;
+		start_time -=
+			(unsigned long long)ve_start_ts->tv_sec * NSEC_PER_SEC
+				+ ve_start_ts->tv_nsec;
+	}
+	/* tasks inside a CT can have negative start time e.g. if the CT was
+	 * migrated from another hw node, in which case we will report 0 in
+	 * order not to confuse userspace */
+	if ((s64)start_time < 0)
+		start_time = 0;
+#endif
 	/* convert nsec -> ticks */
 	start_time = nsec_to_clock_t(start_time);
-#else
-	start_time = ve_relative_clock(&task->start_time);
-#endif
 
 #ifdef CONFIG_BEANCOUNTERS
 	ub_dump_task_info(task, ub_task_info, sizeof(ub_task_info),
-- 
2.1.4




More information about the Devel mailing list