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: <CAPpoddeGo3o4vWLYCwi2g0zs7RGi__QYuLBAVi1Y0gzP1X+7Gg@mail.gmail.com>
Date: Wed, 24 Jul 2024 00:35:04 +0900
From: Takero Funaki <flintglass@...il.com>
To: Nhat Pham <nphamcs@...il.com>
Cc: Johannes Weiner <hannes@...xchg.org>, Yosry Ahmed <yosryahmed@...gle.com>, 
	Chengming Zhou <chengming.zhou@...ux.dev>, Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 1/2] mm: zswap: fix global shrinker memcg iteration

2024年7月23日(火) 6:39 Nhat Pham <nphamcs@...il.com>:
>
> On Fri, Jul 19, 2024 at 9:41 PM Takero Funaki <flintglass@...il.com> wrote:
> >
> > This patch fixes an issue where the zswap global shrinker stopped
> > iterating through the memcg tree.
> >
> > The problem was that shrink_worker() would stop iterating when a memcg
> > was being offlined and restart from the tree root.  Now, it properly
> > handles the offline memcg and continues shrinking with the next memcg.
> >
> > To avoid holding refcount of offline memcg encountered during the memcg
> > tree walking, shrink_worker() must continue iterating to release the
> > offline memcg to ensure the next memcg stored in the cursor is online.
> >
> > The offline memcg cleaner has also been changed to avoid the same issue.
> > When the next memcg of the offlined memcg is also offline, the refcount
> > stored in the iteration cursor was held until the next shrink_worker()
> > run. The cleaner must release the offline memcg recursively.
> >
> > Fixes: a65b0e7607cc ("zswap: make shrinking memcg-aware")
> > Signed-off-by: Takero Funaki <flintglass@...il.com>
> Hmm LGTM for the most part - a couple nits
> [...]
> > +                       zswap_next_shrink = mem_cgroup_iter(NULL,
> > +                                       zswap_next_shrink, NULL);
> nit: this can fit in a single line right? Looks like it's exactly 80 characters.

Isn't that over 90 chars? But yes, we can reduce line breaks using
memcg as temporary, like:
-       if (zswap_next_shrink == memcg)
-               zswap_next_shrink = mem_cgroup_iter(NULL,
zswap_next_shrink, NULL);
+       if (zswap_next_shrink == memcg) {
+               do {
+                       memcg = mem_cgroup_iter(NULL, zswap_next_shrink, NULL);
+                       zswap_next_shrink = memcg;
+               } while (memcg && !mem_cgroup_online(memcg));


> [...]
> > +                       zswap_next_shrink = mem_cgroup_iter(NULL,
> > +                                               zswap_next_shrink, NULL);
> Same with this.
> [...]
> > +               /*
> > +                * We verified the memcg is online and got an extra memcg
> > +                * reference.  Our memcg might be offlined concurrently but the
> > +                * respective offline cleaner must be waiting for our lock.
> > +                */
> >                 spin_unlock(&zswap_shrink_lock);
> nit: can we remove this spin_unlock() call + the one within the `if
> (!memcg)` block, and just do it unconditionally outside of if
> (!memcg)? Looks like we are unlocking regardless of whether memcg is
> null or not.
>
> memcg is a local variable, not protected by zswap_shrink_lock, so this
> should be fine right?
>
> Otherwise:
> Reviewed-by: Nhat Pham <nphamcs@...il.com>

Ah that's right. We no longer modify zswap_next_shrink in the if
branches. Merging the two spin_unlock.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ