Skip to contentSkip to conversation

selftests/vm: fix split huge page tests

PATCH In review Guangming Wang 3 participants 3 messages May 30, 2025 – Jun 2, 2025 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 selftests/vm: fix split huge page tests

From: Zi Yan <[email protected]>

[ upstream commit dd63bd7df41a8f9393a2e3ff9157a441c08eb996 ]

Fix two inputs to check_anon_huge() and one if condition, so the tests work as expected.

Steps to reproduce the issue.
make headers
make -C tools/testing/selftests/vm

Before patching:test fails with a non-zero exit code

~/linux$ sudo tools/testing/selftests/vm/split_huge_page_test \

Quoted 1 line

/dev/null 2>&1;echo $?

1

~/linux$ ./split_huge_page_test
No THP is allocated

After patching:

~/linux$ sudo tools/testing/selftests/vm/split_huge_page_test \

Quoted 1 line

/dev/null 2>&1;echo $?

0

~/linux$ sudo tools/testing/selftests/vm/split_huge_page_test Split huge pages successful
...

---
 tools/testing/selftests/vm/split_huge_page_test.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/vm/split_huge_page_test.c +3 -3
index 76e1c36dd..b8558c7f1 100644
@@ -106,7 +106,7 @@ void split_pmd_thp(void)
 	for (i = 0; i < len; i++)
 		one_page[i] = (char)i;
 
-	if (!check_huge_anon(one_page, 1, pmd_pagesize)) {
+	if (!check_huge_anon(one_page, 4, pmd_pagesize)) {
 		printf("No THP is allocated\n");
 		exit(EXIT_FAILURE);
 	}
@@ -122,7 +122,7 @@ void split_pmd_thp(void)
 		}
 
 
-	if (check_huge_anon(one_page, 0, pmd_pagesize)) {
+	if (!check_huge_anon(one_page, 0, pmd_pagesize)) {
 		printf("Still AnonHugePages not split\n");
 		exit(EXIT_FAILURE);
 	}
@@ -169,7 +169,7 @@ void split_pte_mapped_thp(void)
 	for (i = 0; i < len; i++)
 		one_page[i] = (char)i;
 
-	if (!check_huge_anon(one_page, 1, pmd_pagesize)) {
+	if (!check_huge_anon(one_page, 4, pmd_pagesize)) {
 		printf("No THP is allocated\n");
 		exit(EXIT_FAILURE);
 	}
Signature · 1 line
2.34.1
maintainer Reviewed-by Zach O'Keefe Tested-by Zach O'Keefe Acked-by David Hildenbrand on v2 1/1
#1 lore raw

[ Sasha's backport helper bot ]

Hi,

✅ All tests passed successfully. No issues detected. No action required from the submitter.

The upstream commit SHA1 provided is correct: dd63bd7df41a8f9393a2e3ff9157a441c08eb996

WARNING: Author mismatch between patch and upstream commit:
Backport author: Guangming Wang<[email protected]> Commit author: Zi Yan<[email protected]>

Status in newer kernel trees:
6.14.y | Present (exact SHA1)
6.12.y | Present (exact SHA1)
6.6.y | Present (exact SHA1)

Note: The patch differs from the upstream commit:
---
1: dd63bd7df41a8 ! 1: 11da32ef6e926 selftests/mm: fix split huge page tests
@@ Metadata
Author: Zi Yan <[email protected]>

## Commit message ##
- selftests/mm: fix split huge page tests
+ selftests/vm: fix split huge page tests
+
+ [ upstream commit dd63bd7df41a8f9393a2e3ff9157a441c08eb996 ]

Fix two inputs to check_anon_huge() and one if condition, so the tests work as expected.

+ Steps to reproduce the issue.
+ make headers
+ make -C tools/testing/selftests/vm
+
+ Before patching:test fails with a non-zero exit code
+
+ ~/linux$ sudo tools/testing/selftests/vm/split_huge_page_test \
+ > /dev/null 2>&1;echo $?
+ 1
+
+ ~/linux$ ./split_huge_page_test
+ No THP is allocated
+
+ After patching:
+
+ ~/linux$ sudo tools/testing/selftests/vm/split_huge_page_test \
+ > /dev/null 2>&1;echo $?
+ 0
+
+ ~/linux$ sudo tools/testing/selftests/vm/split_huge_page_test
+ Split huge pages successful
+ ...
+

Fixes c07c343cda8e ("selftests/vm: dedup THP helpers")

+ Cc: [email protected]

- Cc: Shuah Khan <[email protected]>

+ Signed-off-by: Guangming Wang <[email protected]>

- ## tools/testing/selftests/mm/split_huge_page_test.c ##
-@@ tools/testing/selftests/mm/split_huge_page_test.c: void split_pmd_thp(void)
+ ## tools/testing/selftests/vm/split_huge_page_test.c ##
+@@ tools/testing/selftests/vm/split_huge_page_test.c: void split_pmd_thp(void)
for (i = 0; i < len; i++)
one_page[i] = (char)i;

@@ tools/testing/selftests/mm/split_huge_page_test.c: void split_pmd_thp(void)
printf("No THP is allocated\n");
exit(EXIT_FAILURE);
}
-@@ tools/testing/selftests/mm/split_huge_page_test.c: void split_pmd_thp(void) +@@ tools/testing/selftests/vm/split_huge_page_test.c: void split_pmd_thp(void)
}

@@ tools/testing/selftests/mm/split_huge_page_test.c: void split_pmd_thp(void)
printf("Still AnonHugePages not split\n"); exit(EXIT_FAILURE);
}
-@@ tools/testing/selftests/mm/split_huge_page_test.c: void split_pte_mapped_thp(void) +@@ tools/testing/selftests/vm/split_huge_page_test.c: void split_pte_mapped_thp(void)
for (i = 0; i < len; i++)
one_page[i] = (char)i;

---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.1.y        |  Success    |  Success   |
maintainer
#2 lore raw
In reply to Guangming Wang
Quoted 78 lines · Guangming Wang

From: Zi Yan <[email protected]>

[ upstream commit dd63bd7df41a8f9393a2e3ff9157a441c08eb996 ]

Fix two inputs to check_anon_huge() and one if condition, so the tests work as expected.

Steps to reproduce the issue.
make headers
make -C tools/testing/selftests/vm

Before patching:test fails with a non-zero exit code

~/linux$ sudo tools/testing/selftests/vm/split_huge_page_test \

Quoted 1 line

/dev/null 2>&1;echo $?

1

~/linux$ ./split_huge_page_test
No THP is allocated

After patching:

~/linux$ sudo tools/testing/selftests/vm/split_huge_page_test \

Quoted 1 line

/dev/null 2>&1;echo $?

0

~/linux$ sudo tools/testing/selftests/vm/split_huge_page_test Split huge pages successful
...

---
 tools/testing/selftests/vm/split_huge_page_test.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/vm/split_huge_page_test.c +3 -3
index 76e1c36dd..b8558c7f1 100644
@@ -106,7 +106,7 @@ void split_pmd_thp(void)
 	for (i = 0; i < len; i++)
 		one_page[i] = (char)i;
 
-	if (!check_huge_anon(one_page, 1, pmd_pagesize)) {
+	if (!check_huge_anon(one_page, 4, pmd_pagesize)) {
 		printf("No THP is allocated\n");
 		exit(EXIT_FAILURE);
 	}
@@ -122,7 +122,7 @@ void split_pmd_thp(void)
 		}
 
 
-	if (check_huge_anon(one_page, 0, pmd_pagesize)) {
+	if (!check_huge_anon(one_page, 0, pmd_pagesize)) {
 		printf("Still AnonHugePages not split\n");
 		exit(EXIT_FAILURE);
 	}
@@ -169,7 +169,7 @@ void split_pte_mapped_thp(void)
 	for (i = 0; i < len; i++)
 		one_page[i] = (char)i;
 
-	if (!check_huge_anon(one_page, 1, pmd_pagesize)) {
+	if (!check_huge_anon(one_page, 4, pmd_pagesize)) {
 		printf("No THP is allocated\n");
 		exit(EXIT_FAILURE);
 	}
Signature · 1 line
2.34.1

As previously stated, we can not take any backports for the stable trees from your company until you have properly changed your development processes.

greg k-h