public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selftests/mm: run_vmtests.sh: Fix hugetlb mem size calculation
@ 2024-03-21 21:50 peterx
  2024-03-22  3:50 ` Muchun Song
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: peterx @ 2024-03-21 21:50 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Andrew Morton, peterx, Muhammad Usama Anjum, David Hildenbrand,
	Nico Pache, Muchun Song

From: Peter Xu <peterx@redhat.com>

The script calculates a mininum required size of hugetlb memories, but
it'll stop working with <1MB huge page sizes, reporting all zeros even if
huge pages are available.

In reality, the calculation doesn't really need to be as comlicated either.
Make it simpler and work for KB-level hugepages too.

Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Nico Pache <npache@redhat.com>
Cc: Muchun Song <muchun.song@linux.dev>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 tools/testing/selftests/mm/run_vmtests.sh | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
index c2c542fe7b17..b1b78e45d613 100755
--- a/tools/testing/selftests/mm/run_vmtests.sh
+++ b/tools/testing/selftests/mm/run_vmtests.sh
@@ -152,9 +152,13 @@ done < /proc/meminfo
 # both of these requirements into account and attempt to increase
 # number of huge pages available.
 nr_cpus=$(nproc)
-hpgsize_MB=$((hpgsize_KB / 1024))
-half_ufd_size_MB=$((((nr_cpus * hpgsize_MB + 127) / 128) * 128))
-needmem_KB=$((half_ufd_size_MB * 2 * 1024))
+uffd_min_KB=$((hpgsize_KB * nr_cpus * 2))
+hugetlb_min_KB=$((256 * 1024))
+if [[ $uffd_min_KB -gt $hugetlb_min_KB ]]; then
+	needmem_KB=$uffd_min_KB
+else
+	needmem_KB=$hugetlb_min_KB
+fi
 
 # set proper nr_hugepages
 if [ -n "$freepgs" ] && [ -n "$hpgsize_KB" ]; then
-- 
2.44.0


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

end of thread, other threads:[~2024-04-03 18:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-21 21:50 [PATCH] selftests/mm: run_vmtests.sh: Fix hugetlb mem size calculation peterx
2024-03-22  3:50 ` Muchun Song
2024-03-22 17:54 ` David Hildenbrand
2024-03-24 17:56 ` Muhammad Usama Anjum
2024-04-03 11:04 ` Ryan Roberts
2024-04-03 18:19   ` Peter Xu

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