Re: [PATCH] cgroup: add cpu.stat.percpu for per-CPU cgroup stats

From: Barro Raffel, Willy

Date: Tue Apr 07 2026 - 16:24:46 EST


On Tue, Apr 07, 2026 at 08:27:41AM -1000, Tejun Heo wrote:
>On Mon, Apr 06, 2026 at 06:06:43PM -0700, Willy Barro Raffel wrote:
>> Expose per-CPU subtree_bstat via a new cgroupfs file cpu.stat.percpu.
>> Each line shows one CPU cumulative stats in io.stat-style key=value
>> format:
>>
>> cpu0 usage_usec=123 user_usec=45 system_usec=78 nice_usec=0
>> cpu1 usage_usec=456 user_usec=123 system_usec=333 nice_usec=0
>>
>> This completes the interface left as a TODO in commit 7716f383a583
>> ("Merge tag 'cgroup-for-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup")
>> which added per-CPU subtree_bstat but only exposed it via BPF/drgn.
>
>Given how quickly cpu count is increasing with 1k CPUs on common prod
>machines not too far off, I'm not sure naively formatting output for every
>possible CPU is desirable.
>
>Thanks.
>
>--
>tejun

Good point. I can skip CPUs with zero stats in the output, i.e.: a cgroup running on 4 of 1024 CPUs would only produce 4 lines. Would that address your concern?