Skip to contentSkip to conversation

selftests/mm: do check_huge_anon() with a number been passed in

PATCH In review Wei Yang 7 participants 9 messages Aug 9, 2025 – Aug 12, 2025

Subsystems (4)
lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH v2 1/1 selftests/mm: do check_huge_anon() with a number been passed in

Currently it hard codes the number of hugepage to check for check_huge_anon(), but it would be more reasonable to do the check based on a number passed in.

Pass in the hugepage number and do the check based on it.

Cc Baolin Wang <[email protected]>
Cc Donet Tom <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Dev Jain <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Zi Yan <[email protected]>

---
v2:
* use mm-new
* add back nr_hpages which is removed by an early commit
* adjust the change log a little
* drop RB and resend

---
 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 5ab488fab1cd..63ac82f0b9e0 100644
@@ -105,12 +105,12 @@ static char *allocate_zero_filled_hugepage(size_t len)
 	return result;
 }
 
-static void verify_rss_anon_split_huge_page_all_zeroes(char *one_page, size_t len)
+static void verify_rss_anon_split_huge_page_all_zeroes(char *one_page, int nr_hpages, size_t len)
 {
 	unsigned long rss_anon_before, rss_anon_after;
 	size_t i;
 
-	if (!check_huge_anon(one_page, 4, pmd_pagesize))
+	if (!check_huge_anon(one_page, nr_hpages, pmd_pagesize))
 		ksft_exit_fail_msg("No THP is allocated\n");
 
 	rss_anon_before = rss_anon();
@@ -141,7 +141,7 @@ void split_pmd_zero_pages(void)
 	size_t len = nr_hpages * pmd_pagesize;
 
 	one_page = allocate_zero_filled_hugepage(len);
-	verify_rss_anon_split_huge_page_all_zeroes(one_page, len);
+	verify_rss_anon_split_huge_page_all_zeroes(one_page, nr_hpages, len);
 	ksft_test_result_pass("Split zero filled huge pages successful\n");
 	free(one_page);
 }
Signature · 1 line
2.34.1
#1 lore raw
Quoted 29 lines · Wei Yang

Currently it hard codes the number of hugepage to check for check_huge_anon(), but it would be more reasonable to do the check based on a number passed in.

Pass in the hugepage number and do the check based on it.

Cc Baolin Wang <[email protected]>
Cc Donet Tom <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Dev Jain <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Zi Yan <[email protected]>

---
v2:
* use mm-new
* add back nr_hpages which is removed by an early commit
* adjust the change log a little
* drop RB and resend

---
  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 +0 -0
index 5ab488fab1cd..63ac82f0b9e0 100644

tools/testing/selftests/mm/split_huge_page_test.c static char *allocate_zero_filled_hugepage(size_t len) · line 108

Quoted 5 lines
tools/testing/selftests/mm/split_huge_page_test.c +1 -1
@@ -105,12 +105,12 @@ static char *allocate_zero_filled_hugepage(size_t len)
  	return result;
  }
 
-static void verify_rss_anon_split_huge_page_all_zeroes(char *one_page, size_t len)
+static void verify_rss_anon_split_huge_page_all_zeroes(char *one_page, int nr_hpages, size_t len)

We are re-adding this argument because nr_hpages should be the same in both split_pmd_zero_pages and verify_rss_anon_split_huge_page_all_zeroes, correct? I was just wondering — since the value is currently hardcoded in both functions, would it be preferable to pass it as an argument, or keep it hardcoded, What benefit do we gain by re-adding this argument?

Quoted 18 lines
tools/testing/selftests/mm/split_huge_page_test.c +2 -2
  {
  	unsigned long rss_anon_before, rss_anon_after;
  	size_t i;
 
-	if (!check_huge_anon(one_page, 4, pmd_pagesize))
+	if (!check_huge_anon(one_page, nr_hpages, pmd_pagesize))
  		ksft_exit_fail_msg("No THP is allocated\n");
 
  	rss_anon_before = rss_anon();
@@ -141,7 +141,7 @@ void split_pmd_zero_pages(void)
  	size_t len = nr_hpages * pmd_pagesize;
 
  	one_page = allocate_zero_filled_hugepage(len);
-	verify_rss_anon_split_huge_page_all_zeroes(one_page, len);
+	verify_rss_anon_split_huge_page_all_zeroes(one_page, nr_hpages, len);
  	ksft_test_result_pass("Split zero filled huge pages successful\n");
  	free(one_page);
  }
author
#2 lore raw
Quoted 26 lines · Donet Tom
Quoted 24 lines · Wei Yang

Currently it hard codes the number of hugepage to check for check_huge_anon(), but it would be more reasonable to do the check based on a number passed in.

Pass in the hugepage number and do the check based on it.

Cc Baolin Wang <[email protected]>
Cc Donet Tom <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Dev Jain <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Zi Yan <[email protected]>

---
v2:
* use mm-new
* add back nr_hpages which is removed by an early commit
* adjust the change log a little
* drop RB and resend

---
  tools/testing/selftests/mm/split_huge_page_test.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
Quoted 17 lines

tools/testing/selftests/mm/split_huge_page_test.c static char *allocate_zero_filled_hugepage(size_t len) · line 107

Quoted 9 lines
tools/testing/selftests/mm/split_huge_page_test.c +1 -1
index 5ab488fab1cd..63ac82f0b9e0 100644
@@ -105,12 +105,12 @@ static char *allocate_zero_filled_hugepage(size_t len)
  	return result;
  }
-static void verify_rss_anon_split_huge_page_all_zeroes(char *one_page, size_t len)
+static void verify_rss_anon_split_huge_page_all_zeroes(char *one_page, int nr_hpages, size_t len)

We are re-adding this argument because nr_hpages should be the same in both split_pmd_zero_pages and verify_rss_anon_split_huge_page_all_zeroes, correct? I was just wondering — since the value is currently hardcoded in both functions, would it be preferable to pass it as an argument, or keep it hardcoded, What benefit do we gain by re-adding this argument?

Thanks for your comment.

It looks the correct way to do so.

Signature · 2 lines
Wei Yang
Help you, Help me
#3 lore raw
Quoted 42 lines · Wei Yang
Quoted 25 lines · Donet Tom
Quoted 24 lines · Wei Yang

Currently it hard codes the number of hugepage to check for check_huge_anon(), but it would be more reasonable to do the check based on a number passed in.

Pass in the hugepage number and do the check based on it.

Cc Baolin Wang <[email protected]>
Cc Donet Tom <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Dev Jain <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Zi Yan <[email protected]>

---
v2:
* use mm-new
* add back nr_hpages which is removed by an early commit
* adjust the change log a little
* drop RB and resend

---
   tools/testing/selftests/mm/split_huge_page_test.c | 6 +++---
   1 file changed, 3 insertions(+), 3 deletions(-)
Quoted 16 lines

tools/testing/selftests/mm/split_huge_page_test.c static char *allocate_zero_filled_hugepage(size_t len) · line 107

Quoted 9 lines
tools/testing/selftests/mm/split_huge_page_test.c +1 -1
index 5ab488fab1cd..63ac82f0b9e0 100644
@@ -105,12 +105,12 @@ static char *allocate_zero_filled_hugepage(size_t len)
   	return result;
   }
-static void verify_rss_anon_split_huge_page_all_zeroes(char *one_page, size_t len)
+static void verify_rss_anon_split_huge_page_all_zeroes(char *one_page, int nr_hpages, size_t len)

We are re-adding this argument because nr_hpages should be the same in both split_pmd_zero_pages and verify_rss_anon_split_huge_page_all_zeroes, correct? I was just wondering — since the value is currently hardcoded in both functions, would it be preferable to pass it as an argument, or keep it hardcoded, What benefit do we gain by re-adding this argument?

Quoted 3 lines

Thanks for your comment.

It looks the correct way to do so.

Thank you for the clarification

LGTM

Reviewed by: Donet Tom <[email protected]>

Quoted 1 line
reviewer Reviewed-by on v2 1/1
#4 lore raw
In reply to Wei Yang
Quoted 14 lines · Wei Yang

Currently it hard codes the number of hugepage to check for check_huge_anon(), but it would be more reasonable to do the check based on a number passed in.

Pass in the hugepage number and do the check based on it.

Cc Baolin Wang <[email protected]>
Cc Donet Tom <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Dev Jain <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Zi Yan <[email protected]>
Quoted 7 lines

---
v2:
* use mm-new
* add back nr_hpages which is removed by an early commit
* adjust the change log a little
* drop RB and resend
---

LGTM.

Quoted 31 lines
  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 5ab488fab1cd..63ac82f0b9e0 100644
@@ -105,12 +105,12 @@ static char *allocate_zero_filled_hugepage(size_t len)
  	return result;
  }
 
-static void verify_rss_anon_split_huge_page_all_zeroes(char *one_page, size_t len)
+static void verify_rss_anon_split_huge_page_all_zeroes(char *one_page, int nr_hpages, size_t len)
  {
  	unsigned long rss_anon_before, rss_anon_after;
  	size_t i;
 
-	if (!check_huge_anon(one_page, 4, pmd_pagesize))
+	if (!check_huge_anon(one_page, nr_hpages, pmd_pagesize))
  		ksft_exit_fail_msg("No THP is allocated\n");
 
  	rss_anon_before = rss_anon();
@@ -141,7 +141,7 @@ void split_pmd_zero_pages(void)
  	size_t len = nr_hpages * pmd_pagesize;
 
  	one_page = allocate_zero_filled_hugepage(len);
-	verify_rss_anon_split_huge_page_all_zeroes(one_page, len);
+	verify_rss_anon_split_huge_page_all_zeroes(one_page, nr_hpages, len);
  	ksft_test_result_pass("Split zero filled huge pages successful\n");
  	free(one_page);
  }
Acked-by on v2 1/1
#5 lore raw
In reply to Wei Yang
Quoted 14 lines · Wei Yang

Currently it hard codes the number of hugepage to check for check_huge_anon(), but it would be more reasonable to do the check based on a number passed in.

Pass in the hugepage number and do the check based on it.

Cc Baolin Wang <[email protected]>
Cc Donet Tom <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Dev Jain <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Zi Yan <[email protected]>
Quoted 1 line

---

Signature · 3 lines
Cheers,

David / dhildenb
reviewer
#6 lore raw
In reply to Wei Yang
Quoted 20 lines · Wei Yang

Currently it hard codes the number of hugepage to check for check_huge_anon(), but it would be more reasonable to do the check based on a number passed in.

Pass in the hugepage number and do the check based on it.

Cc Baolin Wang <[email protected]>
Cc Donet Tom <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Dev Jain <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Zi Yan <[email protected]>

---
v2:
* use mm-new
* add back nr_hpages which is removed by an early commit
* adjust the change log a little
* drop RB and resend

Quoted 4 lines
---
 tools/testing/selftests/mm/split_huge_page_test.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

LGTM. Reviewed-by: Zi Yan <[email protected]>

Best Regards,
Yan, Zi

Reviewed-by on v2 1/1
#7 lore raw
In reply to Wei Yang
Quoted 14 lines · Wei Yang

Currently it hard codes the number of hugepage to check for check_huge_anon(), but it would be more reasonable to do the check based on a number passed in.

Pass in the hugepage number and do the check based on it.

Cc Baolin Wang <[email protected]>
Cc Donet Tom <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Dev Jain <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Zi Yan <[email protected]>
Quoted 1 line

---

Reviewed-by on v2 1/1
#8 lore raw
In reply to Wei Yang
Quoted 6 lines

Currently it hard codes the number of hugepage to check for check_huge_anon(), but it would be more reasonable to do the check based on a number passed in.

Pass in the hugepage number and do the check based on it.

LGTM.

Best regards,
wang lian