[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2bba87cf-69aa-4fac-ae1a-c50e2f376e2a@bytedance.com>
Date: Fri, 24 Jan 2025 15:49:16 +0800
From: Abel Wu <wuyun.abel@...edance.com>
To: chenridong <chenridong@...wei.com>, Tejun Heo <tj@...nel.org>,
Johannes Weiner <hannes@...xchg.org>, Michal Koutný
<mkoutny@...e.com>, Jonathan Corbet <corbet@....net>,
Ingo Molnar <mingo@...hat.com>, Peter Zijlstra <peterz@...radead.org>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>, Ben Segall <bsegall@...gle.com>,
Mel Gorman <mgorman@...e.de>, Valentin Schneider <vschneid@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>, Yury Norov <yury.norov@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>, Bitao Hu <yaoma@...ux.alibaba.com>
Cc: "open list:CONTROL GROUP (CGROUP)" <cgroups@...r.kernel.org>,
"open list:DOCUMENTATION" <linux-doc@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: Re: [PATCH 1/3] cgroup/rstat: Fix forceidle time in cpu.stat
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@...edance.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
Powered by blists - more mailing lists