[Devel] [PATCH rh8 2/5] sched: Account task_group::start_time

Konstantin Khorenko khorenko at virtuozzo.com
Thu Oct 8 18:22:00 MSK 2020


From: Kirill Tkhai <ktkhai at virtuozzo.com>

Extracted from "Initial patch".

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>

(cherry picked from vz7 commit bad04073f185d257f6a3290523ca02c095837e8b)
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>

Rebase to vz8 notes:
* moved from struct timespec to u64 (nsec)
---
 kernel/sched/core.c  | 4 ++++
 kernel/sched/sched.h | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 92062773e632..8a57956d64d6 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6095,6 +6095,7 @@ void __init sched_init(void)
 #ifdef CONFIG_CFS_CPULIMIT
 	root_task_group.topmost_limited_ancestor = &root_task_group;
 #endif
+	root_task_group.start_time = 0;
 #endif /* CONFIG_CGROUP_SCHED */
 
 	for_each_possible_cpu(i) {
@@ -6413,6 +6414,9 @@ struct task_group *sched_create_group(struct task_group *parent)
 	if (!alloc_rt_sched_group(tg, parent))
 		goto err;
 
+	/* start_timespec is saved CT0 uptime */
+	tg->start_time = ktime_get_boot_ns();
+
 	return tg;
 
 err:
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 4dbf03a3242f..b2f0c26b2c50 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -404,6 +404,9 @@ struct task_group {
 	struct autogroup	*autogroup;
 #endif
 
+	/* Monotonic time in nsecs: */
+	u64			start_time;
+
 	struct cfs_bandwidth	cfs_bandwidth;
 #ifdef CONFIG_CFS_CPULIMIT
 #define MAX_CPU_RATE 1024
-- 
2.28.0



More information about the Devel mailing list