Re: [PATCH v3 06/13] selftest/mm: adjust hugepage-mremap test size for large huge pages
From: David Hildenbrand (Arm)
Date: Wed Apr 01 2026 - 10:21:24 EST
On 3/27/26 08:16, Sayali Patil wrote:
> The hugepage-mremap selftest uses a default size of 10MB, which is
> sufficient for small huge page sizes. However, when the huge page size
> is large (e.g. 1GB), 10MB is smaller than a single huge page.
> As a result, the test does not trigger PMD sharing and the
> corresponding unshare path in mremap(), causing the
> test to fail (mremap succeeds where a failure is expected).
>
> Update run_vmtest.sh to use twice the huge page size when the huge page
> size exceeds 10MB, while retaining the 10MB default for smaller huge
> pages. This ensures the test exercises the intended PMD sharing and
> unsharing paths for larger huge page sizes.
>
> Before patch:
> running ./hugepage-mremap
> ------------------------------
> TAP version 13
> 1..1
> Map haddr: Returned address is 0x7eaa40000000
> Map daddr: Returned address is 0x7daa40000000
> Map vaddr: Returned address is 0x7faa40000000
> Address returned by mmap() = 0x7fffaa600000
> Mremap: Returned address is 0x7faa40000000
> First hex is 0
> First hex is 3020100
> Bail out! mremap: Expected failure, but call succeeded
> Planned tests != run tests (1 != 0)
> Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
> [FAIL]
> not ok 1 hugepage-mremap # exit=1
>
> Before patch:
> running ./hugepage-mremap
> ------------------------------
> TAP version 13
> 1..1
> Map haddr: Returned address is 0x7eaa40000000
> Map daddr: Returned address is 0x7daa40000000
> Map vaddr: Returned address is 0x7faa40000000
> Address returned by mmap() = 0x7fffaa600000
> Mremap: Returned address is 0x7faa40000000
> First hex is 0
> First hex is 3020100
> Bail out! mremap: Expected failure, but call succeeded
> Planned tests != run tests (1 != 0)
> Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
> [FAIL]
> not ok 1 hugepage-mremap # exit=1
>
Why are there two "Before patch" in here?
> After patch:
> running ./hugepage-mremap 2048
> ------------------------------
> TAP version 13
> 1..1
> Map haddr: Returned address is 0x7eaa40000000
> Map daddr: Returned address is 0x7daa40000000
> Map vaddr: Returned address is 0x7faa40000000
> Address returned by mmap() = 0x7fff13000000
> Mremap: Returned address is 0x7faa40000000
> First hex is 0
> First hex is 3020100
> ok 1 Read same data
> Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
> [PASS]
> ok 1 hugepage-mremap 2048
>
> Fixes: f77a286de48c ("mm, hugepages: make memory size variable in hugepage-mremap selftest")
> Acked-by: Zi Yan <ziy@xxxxxxxxxx>
> Tested-by: Venkat Rao Bagalkote <venkat88@xxxxxxxxxxxxx>
> Signed-off-by: Sayali Patil <sayalip@xxxxxxxxxxxxx>
> ---
> tools/testing/selftests/mm/run_vmtests.sh | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
> index afdcfd0d7cef..eecec0b6eb13 100755
> --- a/tools/testing/selftests/mm/run_vmtests.sh
> +++ b/tools/testing/selftests/mm/run_vmtests.sh
> @@ -293,7 +293,18 @@ echo "$shmmax" > /proc/sys/kernel/shmmax
> echo "$shmall" > /proc/sys/kernel/shmall
>
> CATEGORY="hugetlb" run_test ./map_hugetlb
> -CATEGORY="hugetlb" run_test ./hugepage-mremap
> +
> +# If the huge page size is larger than 10MB, increase the test memory size
> +# to twice the huge page size (in MB) to ensure the test exercises PMD sharing
> +# and the unshare path in hugepage-mremap. Otherwise, run the test with
> +# the default 10MB memory size.
PMD sharing requires, on x86, a 1 GiB area with 2 MiB hugetlb folios.
How does doubling sort that out?
Also, why the magic value 10mb?
--
Cheers,
David