[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJD7tkYS1iSo94WhtDE2GbpTkukaKY3aAKTSaUkGj0K5ifek+A@mail.gmail.com>
Date: Wed, 26 Jul 2023 08:14:35 -0700
From: Yosry Ahmed <yosryahmed@...gle.com>
To: Johannes Weiner <hannes@...xchg.org>
Cc: linux-kernel@...r.kernel.org, Michal Hocko <mhocko@...nel.org>,
cgroups@...r.kernel.org, linux-mm@...ck.org,
Muchun Song <muchun.song@...ux.dev>,
Shakeel Butt <shakeelb@...gle.com>,
Roman Gushchin <roman.gushchin@...ux.dev>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH v2] mm: memcg: use rstat for non-hierarchical stats
On Wed, Jul 26, 2023 at 8:13 AM Johannes Weiner <hannes@...xchg.org> wrote:
>
> On Tue, Jul 25, 2023 at 05:36:45PM -0700, Yosry Ahmed wrote:
> > On Tue, Jul 25, 2023 at 5:29 PM Yosry Ahmed <yosryahmed@...gle.com> wrote:
> > > - Fix a subtle bug where updating a local counter would be missed if it
> > > was cancelled out by a pending update from child memcgs.
> >
> >
> > Johannes, I fixed a subtle bug here and I kept your Ack, I wasn't sure
> > what the Ack retention policy should be here. A quick look at the fix
> > would be great.
>
> Ah, I found it:
>
> > > @@ -5542,19 +5539,23 @@ static void mem_cgroup_css_rstat_flush(struct cgroup_subsys_state *css, int cpu)
> > > memcg->vmstats->state_pending[i] = 0;
> > >
> > > /* Add CPU changes on this level since the last flush */
> > > + delta_cpu = 0;
> > > v = READ_ONCE(statc->state[i]);
> > > if (v != statc->state_prev[i]) {
> > > - delta += v - statc->state_prev[i];
> > > + delta_cpu = v - statc->state_prev[i];
> > > + delta += delta_cpu;
> > > statc->state_prev[i] = v;
> > > }
> > >
> > > - if (!delta)
> > > - continue;
> > > -
> > > /* Aggregate counts on this level and propagate upwards */
> > > - memcg->vmstats->state[i] += delta;
> > > - if (parent)
> > > - parent->vmstats->state_pending[i] += delta;
> > > + if (delta_cpu)
> > > + memcg->vmstats->state_local[i] += delta_cpu;
>
> When delta nulls out, but delta_cpu is non-zero... subtle.
Yup, led to a few missed updates, was not trivial to track down :)
>
> This fixed version looks good, please keep my ack :)
Thanks!
Powered by blists - more mailing lists