[Devel] [PATCH VZ9 1/2] cpuacct: implicitly enable cpuacct controller in cgroup-v2

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Fri Mar 22 07:48:46 MSK 2024


This way the cpuacct controller is transparent to userspace but can be
used to track cgroup cpu usages per-cpu, in next patch we will show
those usages in cpu.proc.stat file.

Notes:
- In case cpuacct is mounted in cgroup-v1 we won't have it in cgroup-v2.
- We also make this cgroup threaded to be able to make it implicit on
  default hierarchy. There should not be any problem as each thread
  accounts separately anyway.

https://virtuozzo.atlassian.net/browse/PSBM-154206
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>

Feature: sched: emulate virtual cpus for Containers
---
 kernel/sched/cpuacct.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c
index 37c102354522..55dfd37567d8 100644
--- a/kernel/sched/cpuacct.c
+++ b/kernel/sched/cpuacct.c
@@ -362,6 +362,9 @@ struct cgroup_subsys cpuacct_cgrp_subsys = {
 	.css_free	= cpuacct_css_free,
 	.legacy_cftypes	= files,
 	.early_init	= true,
+
+	.implicit_on_dfl = true,
+	.threaded       = true,
 };
 
 extern struct task_group *css_tg(struct cgroup_subsys_state *css);
-- 
2.43.0



More information about the Devel mailing list