[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250319191638.GD1876369@cmpxchg.org>
Date: Wed, 19 Mar 2025 15:16:38 -0400
From: Johannes Weiner <hannes@...xchg.org>
To: Yosry Ahmed <yosry.ahmed@...ux.dev>
Cc: Greg Thelen <gthelen@...gle.com>, Tejun Heo <tj@...nel.org>,
Michal Koutný <mkoutny@...e.com>,
Andrew Morton <akpm@...ux-foundation.org>, cgroups@...r.kernel.org,
linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Eric Dumazet <edumazet@...gle.com>
Subject: Re: [PATCH] cgroup/rstat: avoid disabling irqs for O(num_cpu)
On Wed, Mar 19, 2025 at 06:35:02PM +0000, Yosry Ahmed wrote:
> On Wed, Mar 19, 2025 at 02:06:43PM -0400, Johannes Weiner wrote:
> > (btw, why do we not have any locking around the root stats in
> > cgroup_base_stat_cputime_show()? There isn't anything preventing a
> > reader from seeing all zeroes if another reader runs the memset() on
> > cgrp->bstat, is there? Or double times...)
>
> (I think root_cgroup_cputime() operates on a stack allocated bstat, not
> cgrp->bstat)
That was the case until:
commit b824766504e49f3fdcbb8c722e70996a78c3636e
Author: Chen Ridong <chenridong@...wei.com>
Date: Thu Jul 4 14:01:19 2024 +0000
cgroup/rstat: add force idle show helper
Now it's doing this:
void cgroup_base_stat_cputime_show(struct seq_file *seq)
{
struct cgroup *cgrp = seq_css(seq)->cgroup;
if (cgroup_parent(cgrp)) {
...
} else {
/* cgrp->bstat of root is not actually used, reuse it */
root_cgroup_cputime(&cgrp->bstat);
usage = cgrp->bstat.cputime.sum_exec_runtime;
utime = cgrp->bstat.cputime.utime;
stime = cgrp->bstat.cputime.stime;
ntime = cgrp->bstat.ntime;
}
}
and then:
static void root_cgroup_cputime(struct cgroup_base_stat *bstat)
{
struct task_cputime *cputime = &bstat->cputime;
int i;
memset(bstat, 0, sizeof(*bstat));
/* various += on bstat and cputime members */
}
So all readers are mucking with the root cgroup's bstat.
Powered by blists - more mailing lists