Re: cpu.stat in core or cpu controller (was Re: [RFC PATCH v2] cgroup: Track time in cgroup v2 freezer)

From: Chen Ridong
Date: Tue Jul 22 2025 - 05:02:19 EST




On 2025/7/20 0:27, Tejun Heo wrote:
> On Sat, Jul 19, 2025 at 10:01:07AM +0800, Chen Ridong wrote:
> ...
>> What I'm considering is moving the implementation of cpu.stat from cgroup_base_files to
>> cpu_cgrp_subsys—without changing the user-facing interface (filenames and content remain the same).
>> However, the interface would only appear if the CPU subsystem is enabled.
>>
>> Currently, cpu.stat and cpu.stat.local are visible in every cgroup, even when the CPU subsystem is
>> disabled. The only populated fields in such cases are:
>>
>> - usage_usec
>> - user_usec
>> - system_usec
>> - nice_usec
>>
>> I’m unsure whether this change would be acceptable?
>
> I don't think so and don't really see what benefits moving the stats would
> bring. Why would we move these?
>
> Thanks.
>

Thank you for your attention. My intention is to better modularize the cgroup code by moving CPU
subsystem-specific statistics out of the core cgroup implementation (cgroup.c and rstat.c).

Specifically, this change would allow us to:

1.Remove these CPU-specific callbacks from the core:
css_extra_stat_show()
css_local_stat_show()
2. Clean up the 'is_self' logic in rstat.c.
3. Make the stat handling consistent across subsystems (currently cpu.stat is the only
subsystem-specific stat implemented in the core).

Best regards,
Ridong.