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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 29 Nov 2023 17:17:10 -0800
From:   Nhat Pham <nphamcs@...il.com>
To:     Johannes Weiner <hannes@...xchg.org>
Cc:     akpm@...ux-foundation.org, cerasuolodomenico@...il.com,
        yosryahmed@...gle.com, sjenning@...hat.com, ddstreet@...e.org,
        vitaly.wool@...sulko.com, mhocko@...nel.org,
        roman.gushchin@...ux.dev, shakeelb@...gle.com,
        muchun.song@...ux.dev, chrisl@...nel.org, linux-mm@...ck.org,
        kernel-team@...a.com, linux-kernel@...r.kernel.org,
        cgroups@...r.kernel.org, linux-doc@...r.kernel.org,
        linux-kselftest@...r.kernel.org, shuah@...nel.org
Subject: Re: [PATCH v7 3/6] zswap: make shrinking memcg-aware

On Wed, Nov 29, 2023 at 4:21 PM Nhat Pham <nphamcs@...il.com> wrote:
>
> On Wed, Nov 29, 2023 at 7:17 AM Johannes Weiner <hannes@...xchg.org> wrote:
> >
> > On Mon, Nov 27, 2023 at 03:45:57PM -0800, Nhat Pham wrote:
> > >  static void shrink_worker(struct work_struct *w)
> > >  {
> > >       struct zswap_pool *pool = container_of(w, typeof(*pool),
> > >                                               shrink_work);
> > > +     struct mem_cgroup *memcg;
> > >       int ret, failures = 0;
> > >
> > > +     /* global reclaim will select cgroup in a round-robin fashion. */
> > >       do {
> > > -             ret = zswap_reclaim_entry(pool);
> > > -             if (ret) {
> > > -                     zswap_reject_reclaim_fail++;
> > > -                     if (ret != -EAGAIN)
> > > -                             break;
> > > +             spin_lock(&zswap_pools_lock);
> > > +             memcg = pool->next_shrink =
> > > +                     mem_cgroup_iter_online(NULL, pool->next_shrink, NULL, true);
> > > +
> > > +             /* full round trip */
> > > +             if (!memcg) {
> > > +                     spin_unlock(&zswap_pools_lock);
> > >                       if (++failures == MAX_RECLAIM_RETRIES)
> > >                               break;
> > > +
> > > +                     goto resched;
> > >               }
> > > +
> > > +             /*
> > > +              * Acquire an extra reference to the iterated memcg in case the
> > > +              * original reference is dropped by the zswap offlining callback.
> > > +              */
> > > +             css_get(&memcg->css);
> >
> > struct mem_cgroup isn't defined when !CONFIG_MEMCG. This needs a
> > mem_cgroup_get() wrapper and a dummy function for no-memcg builds.
>
> I got this exact same issue a couple of versions ago, but it was
> hidden behind another helper function which can be implemented as a
> no-op in the case of !CONFIG_MEMCG, so I forgot about it until now. It
> always strikes me a bit weird that we have mem_cgroup_put() but not an
> equivalent get - let me correct that.

Actually, I'll instead implement mem_cgroup_tryget_online(), as we
have to check for the cgroup's onlineness as well anyway! If it's
online, then keep the extra reference - all good. If it's not, then
drop the original reference before releasing the lock.


>
> >
> > With that fixed, though, everything else looks good to me:
> >
> > Acked-by: Johannes Weiner <hannes@...xchg.org>
>
> Thanks for the review, Johannes!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ