[LTP] [PATCH] hugemmap32: guarantee enough memory for gigantic hugepage

Li Wang liwang@redhat.com
Mon May 8 15:49:03 CEST 2023


  To get rid of warning on ppc64le:

    hugemmap32.c:34: TWARN: Failed to close FILE
         '/sys/kernel/mm/hugepages/hugepages-16777216kB/nr_hugepages'
    hugemmap32.c:35: TCONF: Can't update the gigantic hugepages.
    hugemmap32.c:69: TWARN: Failed to close FILE
         '/sys/kernel/mm/hugepages/hugepages-16777216kB/nr_hugepages': EINVAL (22)

  # ll /sys/kernel/mm/hugepages/
  total 0
  drwxr-xr-x. 2 root root 0 May  4 02:02 hugepages-16384kB
  drwxr-xr-x. 2 root root 0 May  4 02:02 hugepages-16777216kB

  # cat /proc/meminfo | grep -i Hugepagesize
  Hugepagesize:      16384 kB

  # free -h
                 total        used        free      shared  buff/cache   available
  Mem:           7.4Gi       1.1Gi       992Mi        13Mi       5.9Gi       6.3Gi
  Swap:          4.0Gi          0B       4.0Gi

Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c
index 34b322bfa..7ff23b236 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c
@@ -60,6 +60,12 @@ static void setup(void)
 		tst_brk(TCONF, "Gigantic hugepages not supported");
 
 	SAFE_CLOSEDIR(dir);
+
+	if (tst_available_mem() < (long long)hpage_size) {
+		g_hpage_path[0] = '\0';
+		tst_brk(TCONF, "No enough memory for gigantic hugepage reserving");
+	}
+
 	SAFE_FILE_LINES_SCANF(g_hpage_path, "%d", &org_g_hpages);
 }
 
-- 
2.40.1



More information about the ltp mailing list