Re: [PATCH v2 1/2] mm/huge_memory.c: skip zero-page remapping when underused THP shrinker is disabled

From: David Hildenbrand (Arm)

Date: Mon Nov 16 2026 - 17:30:14 EST


On 10/25/26 18:39, Nico Pache (Red Hat) wrote:
> 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>
> Fixes: b1f202060afe ("mm: remap unused subpages to shared zeropage when splitting isolated thp")
> Signed-off-by: Nico Pache <nico.pache@xxxxxxxxx>
> ---
> 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 bd44d58e8684..2d56d1bff0ea 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -4104,7 +4104,8 @@ static int __folio_freeze_split_anon(struct folio *folio,
> out_no_split:
> local_irq_enable();
> if (anon_vma) {
> - if (!ret && !folio_is_device_private(folio))
> + if (!ret && !folio_is_device_private(folio) &&
> + split_underused_thp)
> ttu_flags = TTU_USE_SHARED_ZEROPAGE;
> remap_anon_folio(folio, 1 << old_order, ttu_flags);
> }
>

I guess the change is not that relevant in practice, because I suspect most
people always run with split_underused_thp=true

Th question is whether "split_underused_thp" only determines "that we trigger a
split if underused", or also "what to do when splitting a folio".

Yes, it was added for the deferred shrinker, but the semantics of the toggle are
not quite clear. I don't think there is any documentation for it ...

Disabling the "split to zeropage" entirely with the toggle off (behavior before
the toggle was introduced) makes sense to me.

But the behavior now already like that in the kernel for a while.


I know that I suggested this, but I wonder, is this patch relevant for your use
case and patch #2?

IOW, woudl RHEL customers disable this toggle here when running with KSM on
affected systems?

--
Cheers,

David