public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
From: Abel Wu <wuyun.abel@bytedance.com>
To: chenridong <chenridong@huawei.com>, "Tejun Heo" <tj@kernel.org>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Michal Koutný" <mkoutny@suse.com>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Juri Lelli" <juri.lelli@redhat.com>,
	"Vincent Guittot" <vincent.guittot@linaro.org>,
	"Dietmar Eggemann" <dietmar.eggemann@arm.com>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Ben Segall" <bsegall@google.com>, "Mel Gorman" <mgorman@suse.de>,
	"Valentin Schneider" <vschneid@redhat.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Yury Norov" <yury.norov@gmail.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Bitao Hu" <yaoma@linux.alibaba.com>
Cc: "open list:CONTROL GROUP (CGROUP)" <cgroups@vger.kernel.org>,
	"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: Re: [PATCH 1/3] cgroup/rstat: Fix forceidle time in cpu.stat
Date: Fri, 24 Jan 2025 15:49:16 +0800	[thread overview]
Message-ID: <2bba87cf-69aa-4fac-ae1a-c50e2f376e2a@bytedance.com> (raw)
In-Reply-To: <853d2669-e05b-435e-9ac1-86311ead56e5@huawei.com>

On 1/24/25 9:47 AM, chenridong Wrote:
> 
> 
> On 2025/1/24 1:47, Abel Wu wrote:
>> The commit b824766504e4 ("cgroup/rstat: add force idle show helper")
>> retrieves forceidle_time outside cgroup_rstat_lock for non-root cgroups
>> which can be potentially inconsistent with other stats.
>>
>> Rather than reverting that commit, fix it in a way that retains the
>> effort of cleaning up the ifdef-messes.
>>
>> Fixes: b824766504e4 ("cgroup/rstat: add force idle show helper")
>> Signed-off-by: Abel Wu <wuyun.abel@bytedance.com>
>> ---
>>   kernel/cgroup/rstat.c | 29 +++++++++++++----------------
>>   1 file changed, 13 insertions(+), 16 deletions(-)
>>
>> diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c
>> index 5877974ece92..c2784c317cdd 100644
>> --- a/kernel/cgroup/rstat.c
>> +++ b/kernel/cgroup/rstat.c
>> @@ -613,36 +613,33 @@ static void cgroup_force_idle_show(struct seq_file *seq, struct cgroup_base_stat
>>   void cgroup_base_stat_cputime_show(struct seq_file *seq)
>>   {
>>   	struct cgroup *cgrp = seq_css(seq)->cgroup;
>> -	u64 usage, utime, stime, ntime;
>> +	struct cgroup_base_stat bstat;
>>   
>>   	if (cgroup_parent(cgrp)) {
>>   		cgroup_rstat_flush_hold(cgrp);
>> -		usage = cgrp->bstat.cputime.sum_exec_runtime;
>> +		bstat = cgrp->bstat;
> 
> Thank you for finding that.
> In my version 2, I used to assign cgrp->bstat to bstat.
> This is Tj's comment:
> https://lore.kernel.org/linux-kernel/ZoQ2ti7nnz9EJSc3@slm.duckdns.org/

Thanks for pointing out. Using memcpy() is fine for me, but I see
cgroup_base_stat_flush() is using the same pattern, and if we don't
want copy like this, it would be better unify them in a separate
patch.

But IMHO in either way, I don't think reading forceidle time outside
cgroup_rstat_lock is the right thing to do.

Best Regards,
	Abel


  reply	other threads:[~2025-01-24  7:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-23 17:47 [PATCH 0/3] Fix and cleanup and extend cpu.stat Abel Wu
2025-01-23 17:47 ` [PATCH 1/3] cgroup/rstat: Fix forceidle time in cpu.stat Abel Wu
2025-01-24  1:47   ` chenridong
2025-01-24  7:49     ` Abel Wu [this message]
2025-01-24 23:49       ` Tejun Heo
2025-01-25  4:54         ` Abel Wu
2025-01-24  9:22   ` Michal Koutný
2025-01-24  9:58     ` Abel Wu
2025-01-24 10:39       ` Michal Koutný
2025-01-24 10:58         ` Abel Wu
2025-01-23 17:47 ` [PATCH 2/3] cgroup/rstat: Cleanup cpu.stat once for all Abel Wu
2025-01-24  9:22   ` Michal Koutný
2025-01-24 10:00     ` Abel Wu
2025-01-23 17:47 ` [PATCH 3/3] cgroup/rstat: Add run_delay accounting for cgroups Abel Wu

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=2bba87cf-69aa-4fac-ae1a-c50e2f376e2a@bytedance.com \
    --to=wuyun.abel@bytedance.com \
    --cc=akpm@linux-foundation.org \
    --cc=bsegall@google.com \
    --cc=cgroups@vger.kernel.org \
    --cc=chenridong@huawei.com \
    --cc=corbet@lwn.net \
    --cc=dietmar.eggemann@arm.com \
    --cc=hannes@cmpxchg.org \
    --cc=juri.lelli@redhat.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=mkoutny@suse.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=yaoma@linux.alibaba.com \
    --cc=yury.norov@gmail.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