Re: [PATCH] kernel/cgroup/pids: add "pids.forks" counter
From: Michal Koutný
Date: Fri May 02 2025 - 08:56:04 EST
Hello Max.
On Fri, May 02, 2025 at 02:19:30PM +0200, Max Kellermann <max.kellermann@xxxxxxxxx> wrote:
> Counts the number of fork()/clone() calls, similar to the "processes"
> row in /proc/stat, but per cgroup.
> This helps with analyzing who was responsible for peaks in the global
> "processes" counter.
bpftrace <<EOD
kprobe:copy_process
{
@forks[cgroup] = count();
}
END {
for ($kv : @forks) {
printf("%s\t%d\n", cgroup_path($kv.0), (int64)$kv.1);
}
clear(@forks);
}
EOD
> diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
...
> + pids.forks
> + A read-only single value file which exists on non-root cgroups.
> +
> + The number of fork()/clone() calls (whether successful or not).
> +
It would conceptually fit better as a pids.stat:forks (but there's no
pids.stat unlike other controllers')
But I don't know this new field justifies introductions of a cgroup
attribute and (yet) another atomic operation on the forking path.
Does the value have long-term or broad use?
Thanks,
Michal
Attachment:
signature.asc
Description: PGP signature