Skip to contentSkip to conversation

lib/tst_hugepage: TCONF when huge pages are not supported

PATCH New Jan Stancek 2 participants 6 messages Apr 22, 2020 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/tst_hugepage: TCONF when huge pages are not supported

/sys/kernel/mm/hugepages is not present when there are no supported hugepage sizes. This is common for ppc64le KVM guests, when hypervisor does not enable hugepages. Guest will boot with:
hugetlbfs: disabling because there are no supported hugepage sizes

  # cat /proc/filesystems  | grep huge; echo $?
  1

End the test with TCONF to avoid TBROK on mmap, set_sys_tune, etc.

---
 lib/tst_hugepage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/tst_hugepage.c +1 -1
index 52667a14e8ff..eb66c4fbbc91 100644
@@ -18,7 +18,7 @@ unsigned long tst_request_hugepages(unsigned long hpages)
 
 	if (access(PATH_HUGEPAGES, F_OK)) {
 		tst_hugepages = 0;
-		goto out;
+		tst_brk(TCONF, "Huge pages not supported.");
 	}
 
 	if (nr_opt)
Signature · 1 line
2.18.1
#1 lore raw

PATCH 1/1 lib/tst_hugepage: TCONF when huge pages are not supported

Hi Jan,

Quoted 20 lines · Jan Stancek

/sys/kernel/mm/hugepages is not present when there are no supported hugepage sizes. This is common for ppc64le KVM guests, when hypervisor does not enable hugepages. Guest will boot with:
hugetlbfs: disabling because there are no supported hugepage sizes

  # cat /proc/filesystems  | grep huge; echo $?
  1

End the test with TCONF to avoid TBROK on mmap, set_sys_tune, etc.

---
 lib/tst_hugepage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/tst_hugepage.c +0 -0
index 52667a14e8ff..eb66c4fbbc91 100644

lib/tst_hugepage.c unsigned long tst_request_hugepages(unsigned long hpages) · line 22

Quoted 6 lines
lib/tst_hugepage.c +1 -1
@@ -18,7 +18,7 @@ unsigned long tst_request_hugepages(unsigned long hpages)
 
        if (access(PATH_HUGEPAGES, F_OK)) {
                tst_hugepages = 0;
-               goto out;
+               tst_brk(TCONF, "Huge pages not supported.");
 

We don't do that because hugetlb is not the hard requirement for some tests (i.e pkey01.c). If we exit with TCONF at an early phase on a non-hugetlb system the remaining test will be missed too. In a word, the goto out here is on purpose.

Quoted 7 lines
lib/tst_hugepage.c +0 -0
        }
 
        if (nr_opt)

--
2.18.1

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200422/4c25d7a1/attachment.htm>
#2 lore raw

PATCH 1/1 lib/tst_hugepage: TCONF when huge pages are not supported

----- Original Message -----

Quoted 10 lines

lib/tst_hugepage.c unsigned long tst_request_hugepages(unsigned long hpages) · line 21

Quoted 5 lines
        if (access(PATH_HUGEPAGES, F_OK)) {
                tst_hugepages = 0;
lib/tst_hugepage.c +1 -1
-               goto out;
+               tst_brk(TCONF, "Huge pages not supported.");

We don't do that because hugetlb is not the hard requirement for some tests (i.e pkey01.c). If we exit with TCONF at an early phase on a non-hugetlb system the remaining test will be missed too. In a word, the goto out here is on purpose.

Then it's a bit strange it TBROKs if it can't reserve enough huge pages.

I'll send v2, that's checking tst_hugepages. Almost all tests appear to have the check already, it just needs to be moved up a little in setup().

#3 lore raw

PATCH v2 1/1 hugetlb: check for requested huge pages first

In reply to Jan Stancek

/sys/kernel/mm/hugepages is not present when there are no supported hugepage sizes. This is common for ppc64le KVM guests, when hypervisor does not enable hugepages. Guest will boot with:
hugetlbfs: disabling because there are no supported hugepage sizes

  # cat /proc/filesystems  | grep huge; echo $?
  1

Move the check up in setup to check it as first thing to avoid
running into TBROK on mount or set_sys_tune when hugetlbfs is
not available:
safe_macros.c:766: BROK: hugemmap01.c:82: mount(none, /mnt/testarea/ltp-07Kg6lCOmm/Ai9D0M, hugetlbfs, 0, (nil)) failed: ENODEV (19) safe_macros.c:766: BROK: hugemmap02.c:129: mount(none, /mnt/testarea/ltp-07Kg6lCOmm/Cxf7A6, hugetlbfs, 0, (nil)) failed: ENODEV (19) safe_macros.c:766: BROK: hugemmap04.c:100: mount(none, /mnt/testarea/ltp-07Kg6lCOmm/kS60Mk, hugetlbfs, 0, (nil)) failed: ENODEV (19) safe_file_ops.c:219: BROK: Expected 1 conversions got 0 at hugemmap06.c:42
safe_file_ops.c:155: BROK: The FILE '/proc/sys/vm/nr_hugepages' ended prematurely at mem.c:836 safe_file_ops.c:219: BROK: Expected 1 conversions got 0 at hugeshmat05.c:39

---
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c   | 6 +++---
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c   | 6 +++---
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c   | 6 +++---
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap06.c   | 2 +-
 testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c | 3 +++
 testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat05.c | 6 +++---
 6 files changed, 16 insertions(+), 13 deletions(-)
testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c +3 -3
index 891c42e4613c..d7ea6d87ae85 100644
@@ -77,13 +77,13 @@ static void test_hugemmap(void)
 
 void setup(void)
 {
+	if (tst_hugepages == 0)
+		tst_brk(TCONF, "Not enough hugepages for testing.");
+
 	if (!Hopt)
 		Hopt = tst_get_tmpdir();
 	SAFE_MOUNT("none", Hopt, "hugetlbfs", 0, NULL);
 
-	if (tst_hugepages == 0)
-		tst_brk(TCONF, "No enough hugepages for testing.");
-
 	snprintf(TEMPFILE, sizeof(TEMPFILE), "%s/mmapfile%d", Hopt, getpid());
 }
 
testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c +3 -3
index c0dbb60d659e..85f39c5d5829 100644
@@ -124,13 +124,13 @@ static void test_hugemmap(void)
 
 static void setup(void)
 {
+	if (tst_hugepages == 0)
+		tst_brk(TCONF, "Not enough hugepages for testing.");
+
 	if (!Hopt)
 		Hopt = tst_get_tmpdir();
 	SAFE_MOUNT("none", Hopt, "hugetlbfs", 0, NULL);
 
-	if (tst_hugepages == 0)
-		tst_brk(TCONF, "No enough hugepages for testing.");
-
 	snprintf(TEMPFILE, sizeof(TEMPFILE), "%s/mmapfile%d", Hopt, getpid());
 }
 
testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c +3 -3
index 5fcbe27891c6..7c8ed8a78975 100644
@@ -95,13 +95,13 @@ static void test_hugemmap(void)
 
 void setup(void)
 {
+	if (tst_hugepages == 0)
+		tst_brk(TCONF, "Not enough hugepages for testing!");
+
 	if (!Hopt)
 		Hopt = tst_get_tmpdir();
 	SAFE_MOUNT("none", Hopt, "hugetlbfs", 0, NULL);
 
-	if (tst_hugepages == 0)
-		tst_brk(TCONF, "No enough hugepages for testing!");
-
 	snprintf(TEMPFILE, sizeof(TEMPFILE), "%s/mmapfile%d", Hopt, getpid());
 }
 
testcases/kernel/mem/hugetlb/hugemmap/hugemmap06.c +1 -1
index 93f9af7f3901..ab2ccc40b82d 100644
@@ -39,9 +39,9 @@ struct mp {
 
 static void setup(void)
 {
-	hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 	if (tst_hugepages != test.request_hugepages)
 		tst_brk(TCONF, "System RAM is not enough to test.");
+	hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 }
 
 static void *thr(void *arg)
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c +3 -0
index 0808496711fc..e9bb9fbf7b4b 100644
@@ -74,6 +74,9 @@ static void setup(void)
 {
 	long mem_total, hpage_size, orig_hugepages;
 
+	if (tst_hugepages == 0)
+		tst_brk(TCONF, "Not enough hugepages for testing.");
+
 	orig_hugepages = get_sys_tune("nr_hugepages");
 	mem_total = SAFE_READ_MEMINFO("MemTotal:");
 	SAFE_FILE_SCANF(PATH_SHMMAX, "%ld", &orig_shmmax);
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat05.c +3 -3
index a30e1e3c3d3f..7152e3363acd 100644
@@ -35,11 +35,11 @@ static long hpage_size;
 
 void setup(void)
 {
+	if (tst_hugepages != test.request_hugepages)
+		tst_brk(TCONF, "Not enough hugepages for testing.");
+
 	page_size = getpagesize();
 	hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
-
-	if (tst_hugepages != test.request_hugepages)
-		tst_brk(TCONF, "No enough hugepages for testing.");
 }
 
 void shm_test(int size)
Signature · 1 line
2.18.1
#4 lore raw

PATCH v2 1/1 hugetlb: check for requested huge pages first

Quoted 27 lines · Jan Stancek

/sys/kernel/mm/hugepages is not present when there are no supported hugepage sizes. This is common for ppc64le KVM guests, when hypervisor does not enable hugepages. Guest will boot with:
hugetlbfs: disabling because there are no supported hugepage sizes

  # cat /proc/filesystems  | grep huge; echo $?
  1

Move the check up in setup to check it as first thing to avoid running into TBROK on mount or set_sys_tune when hugetlbfs is not available:
safe_macros.c:766: BROK: hugemmap01.c:82: mount(none,
/mnt/testarea/ltp-07Kg6lCOmm/Ai9D0M, hugetlbfs, 0, (nil)) failed: ENODEV
(19)
safe_macros.c:766: BROK: hugemmap02.c:129: mount(none,
/mnt/testarea/ltp-07Kg6lCOmm/Cxf7A6, hugetlbfs, 0, (nil)) failed: ENODEV
(19)
safe_macros.c:766: BROK: hugemmap04.c:100: mount(none,
/mnt/testarea/ltp-07Kg6lCOmm/kS60Mk, hugetlbfs, 0, (nil)) failed: ENODEV
(19)
safe_file_ops.c:219: BROK: Expected 1 conversions got 0 at
hugemmap06.c:42
safe_file_ops.c:155: BROK: The FILE '/proc/sys/vm/nr_hugepages' ended
prematurely at mem.c:836
safe_file_ops.c:219: BROK: Expected 1 conversions got 0 at
hugeshmat05.c:39

Quoted 2 lines

This is obviously right! ACK.

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200422/4d0a864b/attachment-0001.htm>
#5 lore raw

PATCH v2 1/1 hugetlb: check for requested huge pages first

----- Original Message -----

Quoted 29 lines · Jan Stancek
Quoted 28 lines

/sys/kernel/mm/hugepages is not present when there are no supported hugepage sizes. This is common for ppc64le KVM guests, when hypervisor does not enable hugepages. Guest will boot with:
hugetlbfs: disabling because there are no supported hugepage sizes

  # cat /proc/filesystems  | grep huge; echo $?
  1

Move the check up in setup to check it as first thing to avoid running into TBROK on mount or set_sys_tune when hugetlbfs is not available:
safe_macros.c:766: BROK: hugemmap01.c:82: mount(none,
/mnt/testarea/ltp-07Kg6lCOmm/Ai9D0M, hugetlbfs, 0, (nil)) failed: ENODEV
(19)
safe_macros.c:766: BROK: hugemmap02.c:129: mount(none,
/mnt/testarea/ltp-07Kg6lCOmm/Cxf7A6, hugetlbfs, 0, (nil)) failed: ENODEV
(19)
safe_macros.c:766: BROK: hugemmap04.c:100: mount(none,
/mnt/testarea/ltp-07Kg6lCOmm/kS60Mk, hugetlbfs, 0, (nil)) failed: ENODEV
(19)
safe_file_ops.c:219: BROK: Expected 1 conversions got 0 at
hugemmap06.c:42
safe_file_ops.c:155: BROK: The FILE '/proc/sys/vm/nr_hugepages' ended
prematurely at mem.c:836
safe_file_ops.c:219: BROK: Expected 1 conversions got 0 at
hugeshmat05.c:39

Quoted 5 lines
Quoted 2 lines

This is obviously right! ACK.

Pushed.