Skip to contentSkip to conversation

Fix hugeshmat05 test failure on lpar with 1GB hugepages.

PATCH In review Pavithra 3 participants 3 messages Apr 20 – Jun 9

lore
Share & tools
lore

Pavithra

author
#0 lore raw

PATCH 1/1 Fix hugeshmat05 test failure on lpar with 1GB hugepages.

Modified the test to detect large hugepage sizes (≥1GB) and adjust test sizes accordingly.

---
 .../mem/hugetlb/hugeshmat/hugeshmat05.c       | 30 ++++++++++++++-----
 1 file changed, 22 insertions(+), 8 deletions(-)
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat05.c +22 -8
index 3b2ae351c..c1e34f999 100644
@@ -37,9 +37,13 @@ void setup(void)
 {
 	page_size = getpagesize();
 	hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
+
+	tst_res(TINFO, "Page size: %ld bytes", page_size);
+	tst_res(TINFO, "Hugepage size: %ld bytes (%ld MB)",
+		hpage_size, hpage_size / (1024 * 1024));
 }
 
-void shm_test(int size)
+void shm_test(long size)
 {
 	int shmid;
 	char *shmaddr;
@@ -56,7 +60,7 @@ void shm_test(int size)
 	}
 
 	shmaddr[0] = 1;
-	tst_res(TINFO, "allocated %d huge bytes", size);
+	tst_res(TINFO, "allocated %ld huge bytes", size);
 
 	if (shmdt((const void *)shmaddr) != 0) {
 		shmctl(shmid, IPC_RMID, NULL);
@@ -69,13 +73,23 @@ void shm_test(int size)
 static void test_hugeshmat(void)
 {
 	unsigned int i;
+	long multiplier;
+	long tst_sizes[4];
+
+	/*
+	 * For large hugepage sizes (e.g., 1GB), use N/2 multiplier to avoid
+	 * excessive memory requirements (4GB for N=4 with 1GB pages) while
+	 * still testing alignment boundary conditions with multiple pages.
+	 */
+	if (hpage_size >= 1024 * 1024 * 1024)
+		multiplier = N / 2;
+	else
+		multiplier = N;
 
-	const int tst_sizes[] = {
-		N * hpage_size - page_size,
-		N * hpage_size - page_size - 1,
-		hpage_size,
-		hpage_size + 1
-	};
+	tst_sizes[0] = multiplier * hpage_size - page_size;
+	tst_sizes[1] = multiplier * hpage_size - page_size - 1;
+	tst_sizes[2] = hpage_size;
+	tst_sizes[3] = hpage_size + 1;
 
 	for (i = 0; i < ARRAY_SIZE(tst_sizes); ++i)
 		shm_test(tst_sizes[i]);
Signature · 5 lines
2.53.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Pavithra,

Quoted 3 lines · Pavithra

Fix hugeshmat05 test failure on lpar with 1GB hugepages.

Modified the test to detect large hugepage sizes (≥1GB) and adjust test sizes accordingly.

The commit body describes what changed but not why the test was failing. Is shmget failing because N*hpage_size=4GB exceeds what the LPAR can allocate in one call, or is it a pool exhaustion issue? Please document the root cause in the commit message.

testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat05.c void shm_test(int size) · line 87

Quoted 4 lines
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat05.c +4 -0
+       if (hpage_size >= 1024 * 1024 * 1024)
+               multiplier = N / 2;
+       else
+               multiplier = N;

With multiplier=2 for 1GB pages the test needs at most 2 hugepages at peak, but .hugepages = {N+1, TST_NEEDS} still requires 5 free 1GB pages (5 GB). On an LPAR with 2–4 free 1GB hugepages the test still cannot run. Update .hugepages to match the reduced requirement.

---
Note:

Our agent completed the review of the patch. The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
In reply to Pavithra

Hi Pavithra,

Quoted 4 lines
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat05.c +3 -0
+	tst_res(TINFO, "Page size: %ld bytes", page_size);
+	tst_res(TINFO, "Hugepage size: %ld bytes (%ld MB)",
+		hpage_size, hpage_size / (1024 * 1024));
 }

[...]

Quoted 33 lines
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat05.c +14 -3
-void shm_test(int size)
+void shm_test(long size)
 {
 	int shmid;
 	char *shmaddr;
@@ -56,7 +60,7 @@ void shm_test(int size)
 	}
 
 	shmaddr[0] = 1;
-	tst_res(TINFO, "allocated %d huge bytes", size);
+	tst_res(TINFO, "allocated %ld huge bytes", size);
 
 	if (shmdt((const void *)shmaddr) != 0) {
 		shmctl(shmid, IPC_RMID, NULL);
@@ -69,13 +73,23 @@ void shm_test(int size)
 static void test_hugeshmat(void)
 {
 	unsigned int i;
+	long multiplier;
+	long tst_sizes[4];
+
+	/*
+	 * For large hugepage sizes (e.g., 1GB), use N/2 multiplier to avoid
+	 * excessive memory requirements (4GB for N=4 with 1GB pages) while
+	 * still testing alignment boundary conditions with multiple pages.
+	 */
+	if (hpage_size >= 1024 * 1024 * 1024)
+		multiplier = N / 2;
+	else
+		multiplier = N;
 
-	const int tst_sizes[] = {

testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat05.c void shm_test(int size) · line 93

Quoted 10 lines
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat05.c +4 -5
-		N * hpage_size - page_size,
-		N * hpage_size - page_size - 1,
-		hpage_size,
-		hpage_size + 1
-	};
+	tst_sizes[0] = multiplier * hpage_size - page_size;
+	tst_sizes[1] = multiplier * hpage_size - page_size - 1;
+	tst_sizes[2] = hpage_size;
+	tst_sizes[3] = hpage_size + 1;
 

Are you still working on this patch? If yes, please update it according to the agent review, before sending a v2. Also, in LTP we have TST_KB, TST_MB, TST_GB, so you can avoid using 1024 * 1024 .. format.

Please rebase to master and send a new version, I will move this patch into Changes Requested before proceeding to the proper review.

Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp