From: Chen Ridong <chenridong@huaweicloud.com>
To: "Michal Koutný" <mkoutny@suse.com>
Cc: Tejun Heo <tj@kernel.org>, Tiffany Yang <ynaffit@google.com>,
linux-kernel@vger.kernel.org, John Stultz <jstultz@google.com>,
Thomas Gleixner <tglx@linutronix.de>,
Stephen Boyd <sboyd@kernel.org>,
Anna-Maria Behnsen <anna-maria@linutronix.de>,
Frederic Weisbecker <frederic@kernel.org>,
Johannes Weiner <hannes@cmpxchg.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Pavel Machek <pavel@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Chen Ridong <chenridong@huawei.com>,
kernel-team@android.com, Jonathan Corbet <corbet@lwn.net>,
cgroups@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: cpu.stat in core or cpu controller (was Re: [RFC PATCH v2] cgroup: Track time in cgroup v2 freezer)
Date: Sat, 19 Jul 2025 10:01:07 +0800 [thread overview]
Message-ID: <e065b8da-9e7c-4214-9122-83d83700a729@huaweicloud.com> (raw)
In-Reply-To: <jyvlpm6whamo5ge533xdsvqnsjsxdonpvdjbtt5gqvcw5fjp56@q4ej7gy5frj7>
On 2025/7/18 21:58, Michal Koutný wrote:
> On Fri, Jul 18, 2025 at 05:26:54PM +0800, Chen Ridong <chenridong@huaweicloud.com> wrote:
>> With the recent merge of the series "cgroup: separate rstat trees," the rstat are not bound to CPU
>> system. This makes me wonder: should we consider moving the cpu.stat and cpu.stat.local interfaces
>> to the CPU subsystem?
>
> Note that fields printed in cpu.stat are combination of "core" and cpu
> controller values.
>
Do you mean the "core" values are shown as below:
- usage_usec
- user_usec
- system_usec
- nice_usec
In the legacy cgroup, these values are in the cpuacct subsystem.
>> The CPU subsystem could then align more closely with other resource controllers like memory or I/O
>> subsystems. By decoupling these CPU-specific statistics from the cgroup core, it could help keep
>> both cgroup and rstat implementations more focused.
>
> In my eyes, cpu controller is stuff encapsulated by cpu_cgrp_subsys. I'm
> not sure I understand what you refer to as the CPU subsystem.
>
> One thing is how it is presented to users (filenames and content)
> another one is how it is implemented. The latter surely can be
> refactored but it's not obvious to me from the short description, sorry.
>
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?
>> Is there any particular reason why the CPU subsystem must remain bound
>> to the cgroup core?
>
> The stuff that's bound to the core is essentially not "control" but only
> accounting, so with this association, the accounting can have fine
> granularity while control (which incurs higher overhead in principle)
> may remain coarse. I find it thus quite fitting that CPU stats build on
> top of rstat.
The implementation would still rely on rstat, similar to memory.stat and io.stat. The goal is to
decouple it from the cgroup core (cgroup.c and rstat.c) while preserving accounting granularity.
Best regards,
Ridong
> (Naturally, my previous claim about overhead is only rough and it's the
> reason for existence of adjustments like in the commit 34f26a15611af
> ("sched/psi: Per-cgroup PSI accounting disable/re-enable interface").)
>
> Thats how I see it, happy to discuss possible problems you see with
> this.
>
> Michal
next prev parent reply other threads:[~2025-07-19 2:01 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-14 5:00 [RFC PATCH v2] cgroup: Track time in cgroup v2 freezer Tiffany Yang
2025-07-17 12:56 ` Michal Koutný
2025-07-17 13:52 ` Chen Ridong
2025-07-17 17:06 ` Tejun Heo
2025-07-22 22:41 ` Tiffany Yang
2025-07-22 22:27 ` Tiffany Yang
2025-07-17 17:05 ` Tejun Heo
2025-07-18 8:20 ` Michal Koutný
2025-07-18 9:26 ` Chen Ridong
2025-07-18 13:58 ` cpu.stat in core or cpu controller (was Re: [RFC PATCH v2] cgroup: Track time in cgroup v2 freezer) Michal Koutný
2025-07-19 2:01 ` Chen Ridong [this message]
2025-07-19 16:27 ` Tejun Heo
2025-07-22 9:01 ` Chen Ridong
2025-07-22 11:54 ` Michal Koutný
2025-07-23 1:28 ` Chen Ridong
2025-07-25 1:08 ` Tejun Heo
2025-07-25 1:54 ` Chen Ridong
2025-07-22 22:16 ` [RFC PATCH v2] cgroup: Track time in cgroup v2 freezer Tiffany Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e065b8da-9e7c-4214-9122-83d83700a729@huaweicloud.com \
--to=chenridong@huaweicloud.com \
--cc=anna-maria@linutronix.de \
--cc=cgroups@vger.kernel.org \
--cc=chenridong@huawei.com \
--cc=corbet@lwn.net \
--cc=frederic@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=jstultz@google.com \
--cc=kernel-team@android.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkoutny@suse.com \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
--cc=roman.gushchin@linux.dev \
--cc=sboyd@kernel.org \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=ynaffit@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®