[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <h5xdtfh7dc4rjh74b4cwkpjszro73hfbxzdobwtivyx4hl4hyn@p5lp5h5gzjuj>
Date: Fri, 24 May 2024 16:23:09 +0200
From: Michal Koutný <mkoutny@...e.com>
To: "T.J. Mercier" <tjmercier@...gle.com>
Cc: Tejun Heo <tj@...nel.org>, Zefan Li <lizefan.x@...edance.com>,
Johannes Weiner <hannes@...xchg.org>, shakeel.butt@...ux.dev, cgroups@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [RFC] cgroup: Fix /proc/cgroups count for v2
Hello.
On Sun, May 19, 2024 at 05:46:48PM GMT, "T.J. Mercier" <tjmercier@...gle.com> 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
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists