Hello. On Sun, May 19, 2024 at 05:46:48PM GMT, "T.J. Mercier" <tjmercier@xxxxxxxxxx> wrote: > The number of cgroups using a controller is an important metric since > kernel memory is used for each cgroup, and some kernel operations scale > with the number of cgroups for some controllers (memory, io). So users > have an interest in minimizing/tracking the number of them. I agree this is good for debugging or quick checks of unified hierarchy enablement status. > To deal with num_cgroups being reported as 1 for those utility > controllers regardless of the number of cgroups that exist and support > their use, But '1' is correct number no? Those utility controllers are v1-only and their single group only exists on (default) root. > @@ -675,11 +699,19 @@ int proc_cgroupstats_show(struct seq_file *m, void *v) > * cgroup_mutex contention. > */ > > - for_each_subsys(ss, i) > + for_each_subsys(ss, i) { > + int count; > + > + if (!cgroup_on_dfl(&ss->root->cgrp) || is_v2_utility_controller(i)) > + count = atomic_read(&ss->root->nr_cgrps); I think is_v2_utility_controller(ssid) implies !cgroup_on_dfl(&ss->root->cgrp). I'd only decide based on the cgroup_on_dfl() predicate. > --- a/kernel/cgroup/cgroup.c > +++ b/kernel/cgroup/cgroup.c > @@ -2047,6 +2047,8 @@ void init_cgroup_root(struct cgroup_fs_context *ctx) > > INIT_LIST_HEAD_RCU(&root->root_list); > atomic_set(&root->nr_cgrps, 1); > + for (int i = 0; i < CGROUP_SUBSYS_COUNT; ++i) > + atomic_set(&root->nr_css[i], 0); Strictly not needed, non-dfl roots are kzalloc'd and dfl root is global variable (zeroed). HTH, Michal
Attachment:
signature.asc
Description: PGP signature