cgroup: add cpu.stat file to root cgroup
Subsystems (2)
PATCH 1/1 cgroup: add cpu.stat file to root cgroup
Currently, the root cgroup does not have a cpu.stat file. Add one which is consistent with /proc/stat to capture global cpu statistics that might not fall under cgroup accounting.
We haven't done this in the past because the data are already presented in /proc/stat and we didn't want to add overhead from collecting root cgroup stats when cgroups are configured, but no cgroups have been created.
By keeping the data consistent with /proc/stat, I think we avoid the first problem, while improving the usability of cgroups stats. We avoid the second problem by computing the contents of cpu.stat from existing data collected for /proc/stat anyway.
--- kernel/cgroup/cgroup.c | 1 - kernel/cgroup/rstat.c | 60 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 52 insertions(+), 9 deletions(-)
kernel/cgroup/cgroup.c +0 -1
@@ -4881,7 +4881,6 @@ static struct cftype cgroup_base_files[] = { }, { .name = "cpu.stat", - .flags = CFTYPE_NOT_ON_ROOT, .seq_show = cpu_stat_show, },#ifdef CONFIG_PSI
kernel/cgroup/rstat.c +52 -8
70 lines not on this page · raw message
Signature · 1 line
2.24.1
Tejun Heo
maintainerHello,
Quoted 9 lines · Boris Burkov
Currently, the root cgroup does not have a cpu.stat file. Add one which is consistent with
/proc/statto capture global cpu statistics that might not fall under cgroup accounting.We haven't done this in the past because the data are already presented in
/proc/statand we didn't want to add overhead from collecting root cgroup stats when cgroups are configured, but no cgroups have been created.
Quoted 7 lines
By keeping the data consistent with
/proc/stat, I think we avoid the first problem, while improving the usability of cgroups stats. We avoid the second problem by computing the contents of cpu.stat from existing data collected for/proc/statanyway.Signed-off-by Boris Burkov <[email protected]>Suggested-by Tejun Heo <[email protected]>
If there are any objections, please holler. I'll wait a few days and route it through the cgroup tree.
Thanks.
Signature · 1 line
tejun
Johannes Weiner
maintainerQuoted 9 lines · Boris Burkov
Currently, the root cgroup does not have a cpu.stat file. Add one which is consistent with
/proc/statto capture global cpu statistics that might not fall under cgroup accounting.We haven't done this in the past because the data are already presented in
/proc/statand we didn't want to add overhead from collecting root cgroup stats when cgroups are configured, but no cgroups have been created.
Quoted 7 lines
By keeping the data consistent with
/proc/stat, I think we avoid the first problem, while improving the usability of cgroups stats. We avoid the second problem by computing the contents of cpu.stat from existing data collected for/proc/statanyway.Signed-off-by Boris Burkov <[email protected]>Suggested-by Tejun Heo <[email protected]>
Looks good to me, but Boris can you please update Documentation/admin-guide/cgroup-v2.rst as well in this patch?
cpu.stat
A read-only flat-keyed file which exists on non-root cgroups.
Thanks!
PATCH v2 1/1 cgroup: add cpu.stat file to root cgroup
Currently, the root cgroup does not have a cpu.stat file. Add one which is consistent with /proc/stat to capture global cpu statistics that might not fall under cgroup accounting.
We haven't done this in the past because the data are already presented in /proc/stat and we didn't want to add overhead from collecting root cgroup stats when cgroups are configured, but no cgroups have been created.
By keeping the data consistent with /proc/stat, I think we avoid the first problem, while improving the usability of cgroups stats. We avoid the second problem by computing the contents of cpu.stat from existing data collected for /proc/stat anyway.
--- Documentation/admin-guide/cgroup-v2.rst | 6 +-- kernel/cgroup/cgroup.c | 1 - kernel/cgroup/rstat.c | 60 +++++++++++++++++++++---- 3 files changed, 54 insertions(+), 13 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +2 -4
@@ -714,9 +714,7 @@ Conventions - Settings for a single feature should be contained in a single file. - The root cgroup should be exempt from resource control and thus - shouldn't have resource control interface files. Also, - informational files on the root cgroup which end up showing global - information available elsewhere shouldn't exist. + shouldn't have resource control interface files. - The default time unit is microseconds. If a different unit is ever used, an explicit unit suffix must be present.
@@ -985,7 +983,7 @@ CPU Interface Files All time durations are in microseconds. cpu.stat - A read-only flat-keyed file which exists on non-root cgroups. + A read-only flat-keyed file. This file exists whether the controller is enabled or not. It always reports the following three stats:
kernel/cgroup/cgroup.c +0 -1
@@ -4881,7 +4881,6 @@ static struct cftype cgroup_base_files[] = { }, { .name = "cpu.stat", - .flags = CFTYPE_NOT_ON_ROOT, .seq_show = cpu_stat_show, },#ifdef CONFIG_PSI
kernel/cgroup/rstat.c +52 -8
70 lines not on this page · raw message
Signature · 1 line
2.24.1
Quoted 9 lines · Boris Burkov
Currently, the root cgroup does not have a cpu.stat file. Add one which is consistent with
/proc/statto capture global cpu statistics that might not fall under cgroup accounting.We haven't done this in the past because the data are already presented in
/proc/statand we didn't want to add overhead from collecting root cgroup stats when cgroups are configured, but no cgroups have been created.
Quoted 7 lines
By keeping the data consistent with
/proc/stat, I think we avoid the first problem, while improving the usability of cgroups stats. We avoid the second problem by computing the contents of cpu.stat from existing data collected for/proc/statanyway.Signed-off-by Boris Burkov <[email protected]>Suggested-by Tejun Heo <[email protected]>
Applied to cgroup/for-5.8.
Thanks.
Signature · 1 line
tejun