Re: [PATCH] selftests/mm: allocate nr_pages based on pmd size for uffd pmd_move tests

From: Zenghui Yu

Date: Tue Nov 17 2026 - 23:09:21 EST


Hi John,

On 11/13/26 12:00 PM, John J. Coleman wrote:
> When executing the uffd-unit-test, the "move-pmd on anon" test will fail
> on aarch64+64k with a segmentation fault because the initial allocated
> memory region is too small. This only happens with the move-pmd* tests
> because the architecture base page size is still utilized even though the
> memory region is specific to the size indicated by the pmd.
>
> Patch 9f5c2aec3388 ("selftests/mm: fix uffd move-pmd test crash on 64K
> base page systems") implements an initial fix to the segmentation fault
> by skipping the test if the allocated memory region is not large enough
> for the number of pages x page size requested. Since this will skip over
> the aarch64+64k pmd tests, this patch is intended to resolve the problem
> with 64k pages by pre-allocating the memory region with 2x the pmd page
> size (for area_src and area_dst) for only the move_pmd tests by using the
> uffd_test_case_ops pre_alloc hook.
>
> Link: https://lore.kernel.org/all/20261103202049.499206-1-jocolema@xxxxxxxxxx
>
> Fixes: a2bf6a9ca805 ("selftests/mm: add UFFDIO_MOVE ioctl test")
>
> Signed-off-by: John J. Coleman <jocolema@xxxxxxxxxx>

Thanks for chasing it. I've tested mm-new (which already contains this
patch) on my 64k-page-size box.

Before this patch:

ok 14 # SKIP move-pmd on anon (chunk size does not fit in the test area)
ok 15 # SKIP move-pmd-huge-zeropage on anon (not enough pages for one PMD-sized move)
ok 16 # SKIP move-pmd-split on anon (chunk size does not fit in the test area)

After this patch:

ok 14 move-pmd on anon
ok 15 move-pmd-huge-zeropage on anon
ok 16 move-pmd-split on anon

So,

Tested-by: Zenghui Yu (Huawei) <zenghui.yu@xxxxxxxxx>

Thanks,
Zenghui