linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/mm: run_vmtests.sh: fix half_ufd_size_MB calculation
@ 2025-02-18 19:22 Rafael Aquini
  2025-02-19  9:30 ` David Hildenbrand
  2025-02-19 14:26 ` Peter Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Rafael Aquini @ 2025-02-18 19:22 UTC (permalink / raw)
  To: linux-kselftest
  Cc: linux-mm, linux-kernel, Peter Xu, David Hildenbrand, Shuah Khan

From: Rafael Aquini <raquini@redhat.com>

We noticed that uffd-stress test was always failing to run when invoked
for the hugetlb profiles on x86_64 systems with a processor count of 64
or bigger:
  ...
  # ------------------------------------
  # running ./uffd-stress hugetlb 128 32
  # ------------------------------------
  # ERROR: invalid MiB (errno=9, @uffd-stress.c:459)
  ...
  # [FAIL]
  not ok 3 uffd-stress hugetlb 128 32 # exit=1
  ...

The problem boils down to how run_vmtests.sh (mis)calculates the size
of the region it feeds to uffd-stress. The latter expects to see an
amount of MiB while the former is just giving out the number of free
hugepages halved down. This measurement discrepancy ends up violating
uffd-stress' assertion on number of hugetlb pages allocated per CPU,
causing it to bail out with the error above.

This commit fixes that issue by adjusting run_vmtests.sh's half_ufd_size_MB
calculation so it properly renders the region size in MiB, as expected,
while maintaining all of its original constraints in place.

Fixes: 2e47a445d7b3 ("selftests/mm: run_vmtests.sh: fix hugetlb mem size calculation")
Signed-off-by: Rafael Aquini <raquini@redhat.com>
---
 tools/testing/selftests/mm/run_vmtests.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
index 333c468c2699..157d07e5aaa3 100755
--- a/tools/testing/selftests/mm/run_vmtests.sh
+++ b/tools/testing/selftests/mm/run_vmtests.sh
@@ -304,7 +304,9 @@ uffd_stress_bin=./uffd-stress
 CATEGORY="userfaultfd" run_test ${uffd_stress_bin} anon 20 16
 # Hugetlb tests require source and destination huge pages. Pass in half
 # the size of the free pages we have, which is used for *each*.
-half_ufd_size_MB=$((freepgs / 2))
+# uffd-stress expects a region expressed in MiB, so we adjust
+# half_ufd_size_MB accordingly.
+half_ufd_size_MB=$(((freepgs * hpgsize_KB) / 1024 / 2))
 CATEGORY="userfaultfd" run_test ${uffd_stress_bin} hugetlb "$half_ufd_size_MB" 32
 CATEGORY="userfaultfd" run_test ${uffd_stress_bin} hugetlb-private "$half_ufd_size_MB" 32
 CATEGORY="userfaultfd" run_test ${uffd_stress_bin} shmem 20 16
-- 
2.47.0



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] selftests/mm: run_vmtests.sh: fix half_ufd_size_MB calculation
  2025-02-18 19:22 [PATCH] selftests/mm: run_vmtests.sh: fix half_ufd_size_MB calculation Rafael Aquini
@ 2025-02-19  9:30 ` David Hildenbrand
  2025-02-19 14:26 ` Peter Xu
  1 sibling, 0 replies; 3+ messages in thread
From: David Hildenbrand @ 2025-02-19  9:30 UTC (permalink / raw)
  To: Rafael Aquini, linux-kselftest
  Cc: linux-mm, linux-kernel, Peter Xu, Shuah Khan

On 18.02.25 20:22, Rafael Aquini wrote:
> From: Rafael Aquini <raquini@redhat.com>
> 
> We noticed that uffd-stress test was always failing to run when invoked
> for the hugetlb profiles on x86_64 systems with a processor count of 64
> or bigger:
>    ...
>    # ------------------------------------
>    # running ./uffd-stress hugetlb 128 32
>    # ------------------------------------
>    # ERROR: invalid MiB (errno=9, @uffd-stress.c:459)
>    ...
>    # [FAIL]
>    not ok 3 uffd-stress hugetlb 128 32 # exit=1
>    ...
> 
> The problem boils down to how run_vmtests.sh (mis)calculates the size
> of the region it feeds to uffd-stress. The latter expects to see an
> amount of MiB while the former is just giving out the number of free
> hugepages halved down. This measurement discrepancy ends up violating
> uffd-stress' assertion on number of hugetlb pages allocated per CPU,
> causing it to bail out with the error above.
> 
> This commit fixes that issue by adjusting run_vmtests.sh's half_ufd_size_MB
> calculation so it properly renders the region size in MiB, as expected,
> while maintaining all of its original constraints in place.
> 
> Fixes: 2e47a445d7b3 ("selftests/mm: run_vmtests.sh: fix hugetlb mem size calculation")
> Signed-off-by: Rafael Aquini <raquini@redhat.com>
> ---
>   tools/testing/selftests/mm/run_vmtests.sh | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
> index 333c468c2699..157d07e5aaa3 100755
> --- a/tools/testing/selftests/mm/run_vmtests.sh
> +++ b/tools/testing/selftests/mm/run_vmtests.sh
> @@ -304,7 +304,9 @@ uffd_stress_bin=./uffd-stress
>   CATEGORY="userfaultfd" run_test ${uffd_stress_bin} anon 20 16
>   # Hugetlb tests require source and destination huge pages. Pass in half
>   # the size of the free pages we have, which is used for *each*.
> -half_ufd_size_MB=$((freepgs / 2))
> +# uffd-stress expects a region expressed in MiB, so we adjust
> +# half_ufd_size_MB accordingly.
> +half_ufd_size_MB=$(((freepgs * hpgsize_KB) / 1024 / 2))

LGTM

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] selftests/mm: run_vmtests.sh: fix half_ufd_size_MB calculation
  2025-02-18 19:22 [PATCH] selftests/mm: run_vmtests.sh: fix half_ufd_size_MB calculation Rafael Aquini
  2025-02-19  9:30 ` David Hildenbrand
@ 2025-02-19 14:26 ` Peter Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Xu @ 2025-02-19 14:26 UTC (permalink / raw)
  To: Rafael Aquini
  Cc: linux-kselftest, linux-mm, linux-kernel, David Hildenbrand, Shuah Khan

On Tue, Feb 18, 2025 at 02:22:51PM -0500, Rafael Aquini wrote:
> From: Rafael Aquini <raquini@redhat.com>
> 
> We noticed that uffd-stress test was always failing to run when invoked
> for the hugetlb profiles on x86_64 systems with a processor count of 64
> or bigger:
>   ...
>   # ------------------------------------
>   # running ./uffd-stress hugetlb 128 32
>   # ------------------------------------
>   # ERROR: invalid MiB (errno=9, @uffd-stress.c:459)
>   ...
>   # [FAIL]
>   not ok 3 uffd-stress hugetlb 128 32 # exit=1
>   ...
> 
> The problem boils down to how run_vmtests.sh (mis)calculates the size
> of the region it feeds to uffd-stress. The latter expects to see an
> amount of MiB while the former is just giving out the number of free
> hugepages halved down. This measurement discrepancy ends up violating
> uffd-stress' assertion on number of hugetlb pages allocated per CPU,
> causing it to bail out with the error above.
> 
> This commit fixes that issue by adjusting run_vmtests.sh's half_ufd_size_MB
> calculation so it properly renders the region size in MiB, as expected,
> while maintaining all of its original constraints in place.
> 
> Fixes: 2e47a445d7b3 ("selftests/mm: run_vmtests.sh: fix hugetlb mem size calculation")
> Signed-off-by: Rafael Aquini <raquini@redhat.com>

Oops.. thanks!

Reviewed-by: Peter Xu <peterx@redhat.com>

-- 
Peter Xu



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-02-19 14:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-18 19:22 [PATCH] selftests/mm: run_vmtests.sh: fix half_ufd_size_MB calculation Rafael Aquini
2025-02-19  9:30 ` David Hildenbrand
2025-02-19 14:26 ` Peter Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox