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. But as this will skip over the aarch64+64k pmd tests, this patch is intended to resolve the problem with 64k pages by scaling up the initial allocated memory region subject to base page size of the architecture. Fixes: a2bf6a9ca805 ("selftests/mm: add UFFDIO_MOVE ioctl test") Signed-off-by: John J. Coleman --- I too have been looking into a solution for aarch64+64k. I wanted to gauge your thoughts on this patch to scale up memory allocation region size predicated on architecture base page sizes. tools/testing/selftests/mm/uffd-unit-tests.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c index 2a97ba1d6feb1b35d6281449fd1917793a64fab1..c6cebb3c880d0b47e44c8afc4e3a4c3050cea579 100644 --- a/tools/testing/selftests/mm/uffd-unit-tests.c +++ b/tools/testing/selftests/mm/uffd-unit-tests.c @@ -13,8 +13,14 @@ #ifdef __NR_userfaultfd -/* The unit test doesn't need a large or random size, make it 32MB for now */ -#define UFFD_TEST_MEM_SIZE (32UL << 20) +/* + * The unit test does not need a large or random size, but the allocation size + * needs to scale with base page size per architecture otherwise pmd alignment + * tests will fail for architectures like aarch64+64k. For standard 4k pages, + * this will allocate 64MiB, while allocating 1GiB for 64k page sizes. + */ +#define PAGE_SIZE sysconf(_SC_PAGESIZE) +#define UFFD_TEST_MEM_SIZE (PAGE_SIZE * (16 << 10)) #define MEM_ANON BIT_ULL(0) #define MEM_SHMEM BIT_ULL(1) -- 2.56.0