[PATCH mm-unstable v1 3/3] mm/huge_memory.c: Skip zero-page remapping when underused THP shrinker is disabled

From: Nico Pache

Date: Tue Jun 09 2026 - 07:49:42 EST


The zero-page remapping in __folio_split() was added to support the
underused THP shrinker. When the shrinker is disabled via shrink_underused,
gate TTU_USE_SHARED_ZEROPAGE on split_underused_thp to avoid scanning
subpages for zero content unnecessarily.

Suggested-by: David Hildenbrand <david@xxxxxxxxxx>
Signed-off-by: Nico Pache <npache@xxxxxxxxxx>
---
mm/huge_memory.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 94bd656eeaf8..37748d92f277 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -4103,7 +4103,7 @@ static int __folio_split(struct folio *folio, unsigned int new_order,
if (nr_shmem_dropped)
shmem_uncharge(mapping->host, nr_shmem_dropped);

- if (!ret && is_anon && !folio_is_device_private(folio))
+ if (!ret && is_anon && !folio_is_device_private(folio) && split_underused_thp)
ttu_flags = TTU_USE_SHARED_ZEROPAGE;

remap_page(folio, 1 << old_order, ttu_flags);
--
2.54.0