Skip to contentSkip to conversation

selftests/mm: fix split huge page tests

PATCH Applied Zi Yan 4 participants 4 messages Mar 6, 2023 – Mar 7, 2023

Subsystems (4)
lore
Share & tools
lore

Zi Yan

author
#0 lore raw

PATCH 1/1 selftests/mm: fix split huge page tests

From: Zi Yan <[email protected]>

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

Fixes c07c343cda8e ("selftests/vm: dedup THP helpers")
Cc Zach O'Keefe <[email protected]>
---
 tools/testing/selftests/mm/split_huge_page_test.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/mm/split_huge_page_test.c +3 -3
index 76e1c36dd9e5..b8558c7f1a39 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.39.2
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 46 lines · Zi Yan

From: Zi Yan <[email protected]>

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

Fixes c07c343cda8e ("selftests/vm: dedup THP helpers")
Cc Zach O'Keefe <[email protected]>
---
 tools/testing/selftests/mm/split_huge_page_test.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/mm/split_huge_page_test.c +3 -3
index 76e1c36dd9e5..b8558c7f1a39 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.39.2

Thanks Zi -- I had this in my TODO-log, but was slow to get it it -- apologies for the clearly buggy code, and thanks for the cleanup. I've ran these tests to confirm (as I should have previously), and it all looks good. Can have either my

I don't know which is more appropriate.

Best,
Zach

reviewer
#2 lore raw
Quoted 52 lines · Zach O'Keefe
Quoted 46 lines · Zi Yan

From: Zi Yan <[email protected]>

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

Fixes c07c343cda8e ("selftests/vm: dedup THP helpers")
Cc Zach O'Keefe <[email protected]>
---
 tools/testing/selftests/mm/split_huge_page_test.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/mm/split_huge_page_test.c +3 -3
index 76e1c36dd9e5..b8558c7f1a39 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.39.2

Thanks Zi -- I had this in my TODO-log, but was slow to get it it -- apologies for the clearly buggy code, and thanks for the cleanup. I've ran these tests to confirm (as I should have previously), and it all looks good. Can have either my

Quoted 3 lines

Thanks.

--
Best Regards,
Yan, Zi

Acked-by on v1 1/1
#3 lore raw
In reply to Zi Yan
Quoted 35 lines · Zi Yan

From: Zi Yan <[email protected]>

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

Fixes c07c343cda8e ("selftests/vm: dedup THP helpers")
Cc Zach O'Keefe <[email protected]>
---
  tools/testing/selftests/mm/split_huge_page_test.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/mm/split_huge_page_test.c +2 -2
index 76e1c36dd9e5..b8558c7f1a39 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);
  	}

tools/testing/selftests/mm/split_huge_page_test.c void split_pte_mapped_thp(void) · line 175

Quoted 8 lines
tools/testing/selftests/mm/split_huge_page_test.c +1 -1
@@ -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);
  	}

Hard to read. It should probably be "get_huge_anon()" to then check for the value in the caller manually. Negative value could be used as an indicator for an error obtaining the value.

Anyhow, was briefly confused about the 4 ("magic value" also apprearing in "size_t len = 4 * pmd_pagesize;") but it seems to be the right thing to do.

Signature · 3 lines
Thanks,

David / dhildenb