From: "Qi Zheng" <zhengqi.arch@bytedance.com>
To: "Altan Hacigumus" <ahacigu.linux@gmail.com>,
<akpm@linux-foundation.org>, <david@fromorbit.com>
Cc: <roman.gushchin@linux.dev>, <muchun.song@linux.dev>,
<linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm/shrinker: Fix refcount leak in shrink_slab_memcg()
Date: Tue, 3 Feb 2026 16:17:44 +0800 [thread overview]
Message-ID: <3e59ca4e-2301-48a7-bb8e-d028f07b1446@bytedance.com> (raw)
In-Reply-To: <20260203073757.135088-1-ahacigu.linux@gmail.com>
On 2/3/26 3:37 PM, Altan Hacigumus wrote:
> When kmem is disabled for memcg, slab-backed shrinkers are skipped.
> However, shrink_slab_memcg() doesn't drop the reference acquired via
> shrinker_try_get() before continuing.
Good catch!
>
> Add the missing shrinker_put().
>
> Fixes: 50d09da8e119 ("mm: shrinker: make memcg slab shrink lockless")
>
> Signed-off-by: Altan Hacigumus <ahacigu.linux@gmail.com>
> ---
> mm/shrinker.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/mm/shrinker.c b/mm/shrinker.c
> index 4a93fd433689..d0be120488b4 100644
> --- a/mm/shrinker.c
> +++ b/mm/shrinker.c
> @@ -544,8 +544,10 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid,
>
> /* Call non-slab shrinkers even though kmem is disabled */
> if (!memcg_kmem_online() &&
> - !(shrinker->flags & SHRINKER_NONSLAB))
> + !(shrinker->flags & SHRINKER_NONSLAB)) {
Since memcg_kmem_online() and shrinker->flags cannot be changed
dynamically, it's best to remove this shrinker from the bitmap:
clear_bit(offset, unit->map);
Otherwise LGTM.
Acked-by: Qi Zheng <zhengqi.arch@bytedance.com>
Thanks!
> + shrinker_put(shrinker);
> continue;
> + }
>
> ret = do_shrink_slab(&sc, shrinker, priority);
> if (ret == SHRINK_EMPTY) {
next prev parent reply other threads:[~2026-02-03 8:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-03 7:37 Altan Hacigumus
2026-02-03 8:17 ` Qi Zheng [this message]
2026-02-03 8:43 ` Altan Hacigumus
2026-02-03 9:10 ` Altan Hacigumus
2026-02-04 3:35 ` [PATCH v2] " Altan Hacigumus
2026-02-04 3:55 ` Qi Zheng
2026-02-04 4:00 ` Muchun Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3e59ca4e-2301-48a7-bb8e-d028f07b1446@bytedance.com \
--to=zhengqi.arch@bytedance.com \
--cc=ahacigu.linux@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=david@fromorbit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox