* [PATCH 0/2] mm: restore SHRINKER_NONSLAB on THP and zswap shrinkers
@ 2026-09-04 3:35 Qinyun Tan
2026-09-04 3:35 ` [PATCH 1/2] mm: thp: restore SHRINKER_NONSLAB on the deferred split shrinker Qinyun Tan
2026-09-04 3:35 ` [PATCH 2/2] mm: zswap: mark the zswap shrinker SHRINKER_NONSLAB Qinyun Tan
0 siblings, 2 replies; 4+ messages in thread
From: Qinyun Tan @ 2026-09-04 3:35 UTC (permalink / raw)
To: Andrew Morton
Cc: Michal Koutný, David Hildenbrand, Lorenzo Stoakes, Zi Yan,
Baolin Wang, Liam R . Howlett, Nico Pache, Ryan Roberts, Dev Jain,
Barry Song, Lance Yang, Usama Arif, Johannes Weiner, Yosry Ahmed,
Nhat Pham, Chengming Zhou, Kairui Song, Shakeel Butt, Xunlei Pang,
linux-mm, linux-kernel, Qinyun Tan
While reviewing the patch "mm/list_lru: don't copy stale shrinker id
from non-memcg-aware shrinkers" (now in mm-unstable), Michal noticed
that the two non-slab memcg-aware shrinkers, the THP deferred split
shrinker and the zswap shrinker, are registered without
SHRINKER_NONSLAB [1].
Without that flag, booting with cgroup.memory=nokmem silently demotes
both shrinkers to non-memcg-aware ones: memcg (limit-induced) reclaim
neither splits partially unmapped THPs nor writes back zswapped pages
of the cgroup under pressure.
Patch 1 restores the flag on the deferred split shrinker; it was lost
when commit fafaeceb89a5 ("mm: switch deferred split shrinker to
list_lru") re-registered the shrinker.
Patch 2 adds the flag to the zswap shrinker, which has never carried
it since its introduction in commit b5ba474f3f51 ("zswap: shrink zswap
pool based on memory pressure").
The series is based on mm-new, on top of the list_lru patch above,
but the changes are independent of it.
[1] https://lore.kernel.org/lkml/697713c4-0857-485b-aba7-c74f37a3c8b4@linux.alibaba.com/
Qinyun Tan (2):
mm: thp: restore SHRINKER_NONSLAB on the deferred split shrinker
mm: zswap: mark the zswap shrinker SHRINKER_NONSLAB
mm/huge_memory.c | 3 ++-
mm/zswap.c | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
--
2.43.7
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] mm: thp: restore SHRINKER_NONSLAB on the deferred split shrinker
2026-09-04 3:35 [PATCH 0/2] mm: restore SHRINKER_NONSLAB on THP and zswap shrinkers Qinyun Tan
@ 2026-09-04 3:35 ` Qinyun Tan
2026-09-04 15:17 ` Zi Yan
2026-09-04 3:35 ` [PATCH 2/2] mm: zswap: mark the zswap shrinker SHRINKER_NONSLAB Qinyun Tan
1 sibling, 1 reply; 4+ messages in thread
From: Qinyun Tan @ 2026-09-04 3:35 UTC (permalink / raw)
To: Andrew Morton
Cc: Michal Koutný, David Hildenbrand, Lorenzo Stoakes, Zi Yan,
Baolin Wang, Liam R . Howlett, Nico Pache, Ryan Roberts, Dev Jain,
Barry Song, Lance Yang, Usama Arif, Johannes Weiner, Yosry Ahmed,
Nhat Pham, Chengming Zhou, Kairui Song, Shakeel Butt, Xunlei Pang,
linux-mm, linux-kernel, Qinyun Tan
On a system booted with cgroup.memory=nokmem, the deferred split
shrinker is quietly demoted to a non-memcg-aware one. As a result,
partially unmapped THPs are only split under global reclaim; memcg
(limit-induced) reclaim never splits them, so a cgroup under memory
pressure keeps its underused THPs intact.
This is a regression from commit fafaeceb89a5 ("mm: switch deferred
split shrinker to list_lru"), which re-registered the shrinker without
SHRINKER_NONSLAB. The shrinker had carried this flag since commit
0a432dcbeb32 ("mm: shrinker: make shrinker not depend on memcg kmem")
precisely so it would keep working with kmem accounting disabled.
Without the flag, shrinker_memcg_alloc() fails with -ENOSYS under
nokmem and the shrinker loses its memcg awareness.
This was noticed by Michal during review of the patch "mm/list_lru:
don't copy stale shrinker id from non-memcg-aware shrinkers" [1].
Restore the flag.
[1] https://lore.kernel.org/lkml/697713c4-0857-485b-aba7-c74f37a3c8b4@linux.alibaba.com/
Fixes: fafaeceb89a5 ("mm: switch deferred split shrinker to list_lru")
Suggested-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Qinyun Tan <qinyuntan@linux.alibaba.com>
---
mm/huge_memory.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 644d6905b49cc..16f9aa5b2d077 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1022,7 +1022,8 @@ int folio_memcg_alloc_deferred(struct folio *folio)
static int __init thp_shrinker_init(void)
{
deferred_split_shrinker = shrinker_alloc(SHRINKER_NUMA_AWARE |
- SHRINKER_MEMCG_AWARE,
+ SHRINKER_MEMCG_AWARE |
+ SHRINKER_NONSLAB,
"thp-deferred_split");
if (!deferred_split_shrinker)
return -ENOMEM;
--
2.43.7
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] mm: zswap: mark the zswap shrinker SHRINKER_NONSLAB
2026-09-04 3:35 [PATCH 0/2] mm: restore SHRINKER_NONSLAB on THP and zswap shrinkers Qinyun Tan
2026-09-04 3:35 ` [PATCH 1/2] mm: thp: restore SHRINKER_NONSLAB on the deferred split shrinker Qinyun Tan
@ 2026-09-04 3:35 ` Qinyun Tan
1 sibling, 0 replies; 4+ messages in thread
From: Qinyun Tan @ 2026-09-04 3:35 UTC (permalink / raw)
To: Andrew Morton
Cc: Michal Koutný, David Hildenbrand, Lorenzo Stoakes, Zi Yan,
Baolin Wang, Liam R . Howlett, Nico Pache, Ryan Roberts, Dev Jain,
Barry Song, Lance Yang, Usama Arif, Johannes Weiner, Yosry Ahmed,
Nhat Pham, Chengming Zhou, Kairui Song, Shakeel Butt, Xunlei Pang,
linux-mm, linux-kernel, Qinyun Tan
With kmem accounting disabled (cgroup.memory=nokmem), memcg reclaim
never invokes the zswap shrinker: a cgroup under memory pressure does
not write back its own zswapped pages to make room; they are only
written back by global reclaim or once the global pool limit kicks in.
The zswap shrinker is registered memcg-aware but without
SHRINKER_NONSLAB, so under nokmem it is treated as a slab shrinker:
before commit 03375203e1da ("mm: do not allocate shrinker info with
cgroup.memory=nokmem") it was skipped by the !memcg_kmem_online()
check in shrink_slab_memcg(); since that commit it is demoted to
non-memcg-aware at registration. But the zswap shrinker is not a slab
shrinker: it tracks zswap entries and resolves the owning memcg from
the folio's objcg, independent of kmem accounting.
This was noticed by Michal during review of the patch "mm/list_lru:
don't copy stale shrinker id from non-memcg-aware shrinkers" [1].
Mark it SHRINKER_NONSLAB so it keeps its memcg awareness and runs
under memcg reclaim with nokmem.
[1] https://lore.kernel.org/lkml/697713c4-0857-485b-aba7-c74f37a3c8b4@linux.alibaba.com/
Fixes: b5ba474f3f51 ("zswap: shrink zswap pool based on memory pressure")
Suggested-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Qinyun Tan <qinyuntan@linux.alibaba.com>
---
mm/zswap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/zswap.c b/mm/zswap.c
index 761cd699e0a3e..8bcc2997d7719 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -1263,8 +1263,8 @@ static struct shrinker *zswap_alloc_shrinker(void)
{
struct shrinker *shrinker;
- shrinker =
- shrinker_alloc(SHRINKER_NUMA_AWARE | SHRINKER_MEMCG_AWARE, "mm-zswap");
+ shrinker = shrinker_alloc(SHRINKER_NUMA_AWARE | SHRINKER_MEMCG_AWARE |
+ SHRINKER_NONSLAB, "mm-zswap");
if (!shrinker)
return NULL;
--
2.43.7
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] mm: thp: restore SHRINKER_NONSLAB on the deferred split shrinker
2026-09-04 3:35 ` [PATCH 1/2] mm: thp: restore SHRINKER_NONSLAB on the deferred split shrinker Qinyun Tan
@ 2026-09-04 15:17 ` Zi Yan
0 siblings, 0 replies; 4+ messages in thread
From: Zi Yan @ 2026-09-04 15:17 UTC (permalink / raw)
To: Qinyun Tan, Andrew Morton
Cc: Michal Koutný, David Hildenbrand, Lorenzo Stoakes,
Baolin Wang, Liam R . Howlett, Nico Pache, Ryan Roberts, Dev Jain,
Barry Song, Lance Yang, Usama Arif, Johannes Weiner, Yosry Ahmed,
Nhat Pham, Chengming Zhou, Kairui Song, Shakeel Butt, Xunlei Pang,
linux-mm, linux-kernel
On Thu Sep 3, 2026 at 11:35 PM EDT, Qinyun Tan wrote:
> On a system booted with cgroup.memory=nokmem, the deferred split
> shrinker is quietly demoted to a non-memcg-aware one. As a result,
> partially unmapped THPs are only split under global reclaim; memcg
> (limit-induced) reclaim never splits them, so a cgroup under memory
> pressure keeps its underused THPs intact.
>
> This is a regression from commit fafaeceb89a5 ("mm: switch deferred
> split shrinker to list_lru"), which re-registered the shrinker without
> SHRINKER_NONSLAB. The shrinker had carried this flag since commit
> 0a432dcbeb32 ("mm: shrinker: make shrinker not depend on memcg kmem")
> precisely so it would keep working with kmem accounting disabled.
> Without the flag, shrinker_memcg_alloc() fails with -ENOSYS under
> nokmem and the shrinker loses its memcg awareness.
>
> This was noticed by Michal during review of the patch "mm/list_lru:
> don't copy stale shrinker id from non-memcg-aware shrinkers" [1].
>
> Restore the flag.
>
> [1] https://lore.kernel.org/lkml/697713c4-0857-485b-aba7-c74f37a3c8b4@linux.alibaba.com/
>
> Fixes: fafaeceb89a5 ("mm: switch deferred split shrinker to list_lru")
> Suggested-by: Michal Koutný <mkoutny@suse.com>
> Signed-off-by: Qinyun Tan <qinyuntan@linux.alibaba.com>
> ---
> mm/huge_memory.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
Makes sense.
Acked-by: Zi Yan <ziy@nvidia.com>
--
Best Regards,
Yan, Zi
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-04 15:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04 3:35 [PATCH 0/2] mm: restore SHRINKER_NONSLAB on THP and zswap shrinkers Qinyun Tan
2026-09-04 3:35 ` [PATCH 1/2] mm: thp: restore SHRINKER_NONSLAB on the deferred split shrinker Qinyun Tan
2026-09-04 15:17 ` Zi Yan
2026-09-04 3:35 ` [PATCH 2/2] mm: zswap: mark the zswap shrinker SHRINKER_NONSLAB Qinyun Tan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox