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]
Message-ID: <CAHbLzkpwAANd_Nci5Krcek+NmexJCZVVQqSsJF6=xfLVsMK34Q@mail.gmail.com>
Date:   Fri, 11 Dec 2020 09:52:42 -0800
From:   Yang Shi <shy828301@...il.com>
To:     Johannes Weiner <hannes@...xchg.org>
Cc:     Roman Gushchin <guro@...com>, Kirill Tkhai <ktkhai@...tuozzo.com>,
        Shakeel Butt <shakeelb@...gle.com>,
        Dave Chinner <david@...morbit.com>,
        Michal Hocko <mhocko@...e.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Linux MM <linux-mm@...ck.org>,
        Linux FS-devel Mailing List <linux-fsdevel@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 5/9] mm: memcontrol: add per memcg shrinker nr_deferred

On Thu, Dec 10, 2020 at 11:12 AM Yang Shi <shy828301@...il.com> wrote:
>
> On Thu, Dec 10, 2020 at 7:36 AM Johannes Weiner <hannes@...xchg.org> wrote:
> >
> > On Wed, Dec 02, 2020 at 10:27:21AM -0800, Yang Shi wrote:
> > > @@ -504,6 +577,34 @@ int memcg_expand_shrinker_maps(int new_id)
> > >       return ret;
> > >  }
> > >
> > > +int memcg_expand_shrinker_deferred(int new_id)
> > > +{
> > > +     int size, old_size, ret = 0;
> > > +     struct mem_cgroup *memcg;
> > > +
> > > +     size = (new_id + 1) * sizeof(atomic_long_t);
> > > +     old_size = memcg_shrinker_deferred_size;
> > > +     if (size <= old_size)
> > > +             return 0;
> > > +
> > > +     mutex_lock(&memcg_shrinker_mutex);
> >
> > The locking is somewhat confusing. I was wondering why we first read
> > memcg_shrinker_deferred_size "locklessly", then change it while
> > holding the &memcg_shrinker_mutex.
> >
> > memcg_shrinker_deferred_size only changes under shrinker_rwsem(write),
> > correct? This should be documented in a comment, IMO.
>
> Yes, it is correct.
>
> >
> > memcg_shrinker_mutex looks superfluous then. The memcg allocation path
> > is the read-side of memcg_shrinker_deferred_size, and so simply needs
> > to take shrinker_rwsem(read) to lock out shrinker (de)registration.
>
> I see you point. Yes, it seems shrinker_{maps|deferred} allocation
> could be synchronized with shrinker registration by shrinker_rwsem.
>
> memcg_shrinker_mutex is just renamed from memcg_shrinker_map_mutex
> which was introduced by shrinker_maps patchset. I'm not quite sure why
> this mutex was introduced at the first place, I guess the main purpose
> is to *not* exacerbate the contention of shrinker_rwsem?
>
> If that contention is not a concern, we could remove that dedicated mutex.

It seems using shrinker_rwsem instead of dedicated mutex should not
exacerbate the contention since we just add one read critical section.
Will do it in v2.


>
> >
> > Also, isn't memcg_shrinker_deferred_size just shrinker_nr_max? And
>
> No, it is variable. It is nr * sizeof(atomit_long_t). The nr is the
> current last shrinker ID. If a new shrinker is registered, the nr may
> grow.
>
> > memcg_expand_shrinker_deferred() is only called when size >= old_size
> > in the first place (because id >= shrinker_nr_max)?
>
> Yes.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ