Re: [PATCH] fs/super: skip non-memcg-aware nr_cached_objects in memcg slab shrink

From: Qi Zheng

Date: Mon Jul 13 2026 - 09:21:39 EST


Hi Usama,

On 6/9/26 8:30 PM, Usama Arif wrote:
The super_block shrinker is registered with SHRINKER_MEMCG_AWARE because its
dentry and inode LRUs are memcg-aware (via list_lru). But the optional
->nr_cached_objects() hooks that the shrinker also drives are not memcg-aware:
btrfs extent maps and xfs inode reclaim operate on filesystem-global
state, and shmem's unused-huge shrinker walks a per-superblock shrinklist.
None of them filter by sc->memcg.

This makes sense for now, but how should we handle this if these
shrinkers are made memcg-aware in the future?

I've recently been working on making the shmem huge shrinker
memcg-aware, but noticed my changes broke after rebasing onto the latest
tree, which led me to this patch.

As for the shmem huge shrinker, I can work around this limitation by
making it a separate shrinker. But this feels more like an overall
design decision, effectively meaning that all nr_cached_objects are
precluded from being memcg-aware.

Thanks,
Qi