[Devel] [PATCH vz9 07/23] sched: Account task_group::start_time

Nikita Yushchenko nikita.yushchenko at virtuozzo.com
Fri Oct 1 18:53:15 MSK 2021


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)

Cherry-picked from vz8 commit e4826d8be177 ("sched: Account
task_group::start_time"))

Followed ktime_get_boot_ns() -> ktime_get_boottime_ns() rename.

Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
---
 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 a530d3cba26d..b164cd9de057 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -9178,6 +9178,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) {
@@ -9559,6 +9560,9 @@ struct task_group *sched_create_group(struct task_group *parent)
 
 	alloc_uclamp_sched_group(tg, parent);
 
+	/* start_time is saved CT0 uptime */
+	tg->start_time = ktime_get_boottime_ns();
+
 	return tg;
 
 err:
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 45b2cb7203ea..0a0ef82744bf 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -430,6 +430,9 @@ struct task_group {
 	struct autogroup	*autogroup;
 #endif
 
+	/* Monotonic time in nsecs: */
+	u64			start_time;
+
 	struct cfs_bandwidth	cfs_bandwidth;
 
 #ifdef CONFIG_UCLAMP_TASK_GROUP
-- 
2.30.2



More information about the Devel mailing list