mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 02:24:24 +02:00
mm/shrinker: fix refcount leak in shrink_slab_memcg()
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.
Add the missing shrinker_put().
Also, since memcg_kmem_online() and shrinker flags cannot change
dynamically, remove the shrinker from the bitmap to avoid unnecessary
future scans.
Link: https://lkml.kernel.org/r/20260204033553.50039-1-ahacigu.linux@gmail.com
Fixes: 50d09da8e1 ("mm: shrinker: make memcg slab shrink lockless")
Signed-off-by: Altan Hacigumus <ahacigu.linux@gmail.com>
Acked-by: Qi Zheng <zhengqi.arch@bytedance.com>
Link: https://lore.kernel.org/r/20260203073757.135088-1-ahacigu.linux@gmail.com
Reviewed-by: Muchun Song <muchun.song@linux.dev>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
b8a4b08838
commit
260d70819c
|
|
@ -544,8 +544,11 @@ 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)) {
|
||||
clear_bit(offset, unit->map);
|
||||
shrinker_put(shrinker);
|
||||
continue;
|
||||
}
|
||||
|
||||
ret = do_shrink_slab(&sc, shrinker, priority);
|
||||
if (ret == SHRINK_EMPTY) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user