On 10/18/26 10:23 AM, Qiliang Yuan wrote:
> ksm_tests fills regions with identical data and checks KSM's counters
> after merging them. allocate_memory() maps these regions without any
> THP hint.
>
> With mTHP enabled the regions can be backed by large folios, which KSM
> splits before merging. Splitting an anonymous folio maps its
> zero-filled pages to the shared zeropage, so with use_zero_pages=0
> those pages never become KSM pages and "KSM zero page merging" fails
> its count. "ksm_tests -Z -p 10 -z 0", 20 runs:
>
> THP setup before after
> default 0/20 0/20
> every mTHP size "always" 20/20 0/20
>
> Map the regions with MADV_NOHUGEPAGE, as ksm_functional_tests does.
> ksm_merge_hugepages_time() maps its own THP-backed region and is not
> affected.
>
> Fixes: b1f202060afe ("mm: remap unused subpages to shared zeropage when
> splitting isolated thp")
> Signed-off-by: Qiliang Yuan <[email protected]>
> ---
Tested the patch by enabling all mTHP sizes as mentioned. Before the
patch, the test failed and applying the patch fixed it. So:
Tested-by: Sarthak Sharma <[email protected]>