[PATCH V2 0/4] record non-slab shrinkers for non-root memcgs when kmem is disabled
From: Haifeng Xu
Date: Mon Mar 09 2026 - 23:13:04 EST
When registering new shrinkers, all memcgs need to expand shrinker info
if new allocated id exceeds shrinker_nr_max. But if kmem is disabled,
only non-slab shrinkers is useful in memcg slab shrink. So in this case,
it is enough to allocate non-slab shrinker info for non-root memcg. This
can save a bit of memory and reduce the holding time of shrinker lock.
With this optimization, the finish time of pod creation in our internal
test is reduced from 150 seconds to 69 seconds. We test it based on
stable kernel 6.6.102.
Changes since V1:
- reuse shrinker_id() to retrieve the id of shrinker, this also fix the
build error without CONFIG_MEMCG.
https://lore.kernel.org/all/20260306075757.198887-1-haifeng.xu@xxxxxxxxxx/
Haifeng Xu (4):
mm: shrinker: add one more parameter in shrinker_id()
mm: shrinker: move shrinker_id() code block below memcg_kmem_online()
mm: shrinker: optimize the allocation of shrinker_info when setting
cgroup_memory_nokmem
mm: shrinker: remove unnecessary check in shrink_slab_memcg()
include/linux/memcontrol.h | 194 +++++++++++++++++++------------------
include/linux/shrinker.h | 3 +
mm/huge_memory.c | 4 +-
mm/shrinker.c | 133 +++++++++++++++++++++----
4 files changed, 217 insertions(+), 117 deletions(-)
--
2.43.0