lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ