linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch v2] selftests/mm: do check_huge_anon() with a number been passed in
@ 2025-08-09 19:42 Wei Yang
  2025-08-10 13:37 ` Donet Tom
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Wei Yang @ 2025-08-09 19:42 UTC (permalink / raw)
  To: akpm
  Cc: linux-mm, linux-kselftest, Wei Yang, Baolin Wang, Donet Tom,
	David Hildenbrand, Dev Jain, Lorenzo Stoakes, Zi Yan

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.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Donet Tom <donettom@linux.ibm.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Zi Yan <ziy@nvidia.com>

---
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(-)

diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
index 5ab488fab1cd..63ac82f0b9e0 100644
--- a/tools/testing/selftests/mm/split_huge_page_test.c
+++ b/tools/testing/selftests/mm/split_huge_page_test.c
@@ -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);
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Patch v2] selftests/mm: do check_huge_anon() with a number been passed in
  2025-08-09 19:42 [Patch v2] selftests/mm: do check_huge_anon() with a number been passed in Wei Yang
@ 2025-08-10 13:37 ` Donet Tom
  2025-08-11  0:53   ` Wei Yang
  2025-08-11  5:58 ` Baolin Wang
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Donet Tom @ 2025-08-10 13:37 UTC (permalink / raw)
  To: Wei Yang, akpm
  Cc: linux-mm, linux-kselftest, Baolin Wang, David Hildenbrand,
	Dev Jain, Lorenzo Stoakes, Zi Yan


On 8/10/25 1:12 AM, Wei Yang wrote:
> 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.
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: Donet Tom <donettom@linux.ibm.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Dev Jain <dev.jain@arm.com>
> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Cc: Zi Yan <ziy@nvidia.com>
>
> ---
> 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(-)
>
> diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
> index 5ab488fab1cd..63ac82f0b9e0 100644
> --- a/tools/testing/selftests/mm/split_huge_page_test.c
> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
> @@ -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?


>   {
>   	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);
>   }

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Patch v2] selftests/mm: do check_huge_anon() with a number been passed in
  2025-08-10 13:37 ` Donet Tom
@ 2025-08-11  0:53   ` Wei Yang
  2025-08-11  1:48     ` Donet Tom
  0 siblings, 1 reply; 9+ messages in thread
From: Wei Yang @ 2025-08-11  0:53 UTC (permalink / raw)
  To: Donet Tom
  Cc: Wei Yang, akpm, linux-mm, linux-kselftest, Baolin Wang,
	David Hildenbrand, Dev Jain, Lorenzo Stoakes, Zi Yan

On Sun, Aug 10, 2025 at 07:07:47PM +0530, Donet Tom wrote:
>
>On 8/10/25 1:12 AM, Wei Yang wrote:
>> 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.
>> 
>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
>> Cc: Donet Tom <donettom@linux.ibm.com>
>> Cc: David Hildenbrand <david@redhat.com>
>> Cc: Dev Jain <dev.jain@arm.com>
>> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
>> Cc: Zi Yan <ziy@nvidia.com>
>> 
>> ---
>> 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(-)
>> 
>> diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
>> index 5ab488fab1cd..63ac82f0b9e0 100644
>> --- a/tools/testing/selftests/mm/split_huge_page_test.c
>> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
>> @@ -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.

-- 
Wei Yang
Help you, Help me

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Patch v2] selftests/mm: do check_huge_anon() with a number been passed in
  2025-08-11  0:53   ` Wei Yang
@ 2025-08-11  1:48     ` Donet Tom
  0 siblings, 0 replies; 9+ messages in thread
From: Donet Tom @ 2025-08-11  1:48 UTC (permalink / raw)
  To: Wei Yang
  Cc: akpm, linux-mm, linux-kselftest, Baolin Wang, David Hildenbrand,
	Dev Jain, Lorenzo Stoakes, Zi Yan


On 8/11/25 6:23 AM, Wei Yang wrote:
> On Sun, Aug 10, 2025 at 07:07:47PM +0530, Donet Tom wrote:
>> On 8/10/25 1:12 AM, Wei Yang wrote:
>>> 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.
>>>
>>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>>> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
>>> Cc: Donet Tom <donettom@linux.ibm.com>
>>> Cc: David Hildenbrand <david@redhat.com>
>>> Cc: Dev Jain <dev.jain@arm.com>
>>> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
>>> Cc: Zi Yan <ziy@nvidia.com>
>>>
>>> ---
>>> 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(-)
>>>
>>> diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
>>> index 5ab488fab1cd..63ac82f0b9e0 100644
>>> --- a/tools/testing/selftests/mm/split_huge_page_test.c
>>> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
>>> @@ -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.

Thank you for the clarification

LGTM

Reviewed by: Donet Tom <donettom@linux.ibm.com>

>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Patch v2] selftests/mm: do check_huge_anon() with a number been passed in
  2025-08-09 19:42 [Patch v2] selftests/mm: do check_huge_anon() with a number been passed in Wei Yang
  2025-08-10 13:37 ` Donet Tom
@ 2025-08-11  5:58 ` Baolin Wang
  2025-08-11  8:00 ` David Hildenbrand
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Baolin Wang @ 2025-08-11  5:58 UTC (permalink / raw)
  To: Wei Yang, akpm
  Cc: linux-mm, linux-kselftest, Donet Tom, David Hildenbrand, Dev Jain,
	Lorenzo Stoakes, Zi Yan



On 2025/8/10 03:42, Wei Yang wrote:
> 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.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: Donet Tom <donettom@linux.ibm.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Dev Jain <dev.jain@arm.com>
> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Cc: Zi Yan <ziy@nvidia.com>
> 
> ---
> 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.
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>

>   tools/testing/selftests/mm/split_huge_page_test.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
> index 5ab488fab1cd..63ac82f0b9e0 100644
> --- a/tools/testing/selftests/mm/split_huge_page_test.c
> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
> @@ -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);
>   }


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Patch v2] selftests/mm: do check_huge_anon() with a number been passed in
  2025-08-09 19:42 [Patch v2] selftests/mm: do check_huge_anon() with a number been passed in Wei Yang
  2025-08-10 13:37 ` Donet Tom
  2025-08-11  5:58 ` Baolin Wang
@ 2025-08-11  8:00 ` David Hildenbrand
  2025-08-11 18:42 ` Zi Yan
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: David Hildenbrand @ 2025-08-11  8:00 UTC (permalink / raw)
  To: Wei Yang, akpm
  Cc: linux-mm, linux-kselftest, Baolin Wang, Donet Tom, Dev Jain,
	Lorenzo Stoakes, Zi Yan

On 09.08.25 21:42, Wei Yang wrote:
> 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.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: Donet Tom <donettom@linux.ibm.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Dev Jain <dev.jain@arm.com>
> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Cc: Zi Yan <ziy@nvidia.com>
> 
> ---

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Patch v2] selftests/mm: do check_huge_anon() with a number been passed in
  2025-08-09 19:42 [Patch v2] selftests/mm: do check_huge_anon() with a number been passed in Wei Yang
                   ` (2 preceding siblings ...)
  2025-08-11  8:00 ` David Hildenbrand
@ 2025-08-11 18:42 ` Zi Yan
  2025-08-11 20:08 ` Vishal Moola (Oracle)
  2025-08-12  2:26 ` wang lian
  5 siblings, 0 replies; 9+ messages in thread
From: Zi Yan @ 2025-08-11 18:42 UTC (permalink / raw)
  To: Wei Yang
  Cc: akpm, linux-mm, linux-kselftest, Baolin Wang, Donet Tom,
	David Hildenbrand, Dev Jain, Lorenzo Stoakes

On 9 Aug 2025, at 15:42, Wei Yang wrote:

> 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.
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: Donet Tom <donettom@linux.ibm.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Dev Jain <dev.jain@arm.com>
> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Cc: Zi Yan <ziy@nvidia.com>
>
> ---
> 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(-)
>

LGTM. Reviewed-by: Zi Yan <ziy@nvidia.com>

Best Regards,
Yan, Zi

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Patch v2] selftests/mm: do check_huge_anon() with a number been passed in
  2025-08-09 19:42 [Patch v2] selftests/mm: do check_huge_anon() with a number been passed in Wei Yang
                   ` (3 preceding siblings ...)
  2025-08-11 18:42 ` Zi Yan
@ 2025-08-11 20:08 ` Vishal Moola (Oracle)
  2025-08-12  2:26 ` wang lian
  5 siblings, 0 replies; 9+ messages in thread
From: Vishal Moola (Oracle) @ 2025-08-11 20:08 UTC (permalink / raw)
  To: Wei Yang
  Cc: akpm, linux-mm, linux-kselftest, Baolin Wang, Donet Tom,
	David Hildenbrand, Dev Jain, Lorenzo Stoakes, Zi Yan

On Sat, Aug 09, 2025 at 07:42:09PM +0000, Wei Yang wrote:
> 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.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: Donet Tom <donettom@linux.ibm.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Dev Jain <dev.jain@arm.com>
> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Cc: Zi Yan <ziy@nvidia.com>
> 
> ---

Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Patch v2] selftests/mm: do check_huge_anon() with a number been passed in
  2025-08-09 19:42 [Patch v2] selftests/mm: do check_huge_anon() with a number been passed in Wei Yang
                   ` (4 preceding siblings ...)
  2025-08-11 20:08 ` Vishal Moola (Oracle)
@ 2025-08-12  2:26 ` wang lian
  5 siblings, 0 replies; 9+ messages in thread
From: wang lian @ 2025-08-12  2:26 UTC (permalink / raw)
  To: richard.weiyang
  Cc: akpm, baolin.wang, david, dev.jain, donettom, linux-kselftest,
	linux-mm, lorenzo.stoakes, ziy, wang lian


> 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.
Reviewed-by: wang lian <lianux.mm@gmail.com>

Best regards,
wang lian

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-08-12  2:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-09 19:42 [Patch v2] selftests/mm: do check_huge_anon() with a number been passed in Wei Yang
2025-08-10 13:37 ` Donet Tom
2025-08-11  0:53   ` Wei Yang
2025-08-11  1:48     ` Donet Tom
2025-08-11  5:58 ` Baolin Wang
2025-08-11  8:00 ` David Hildenbrand
2025-08-11 18:42 ` Zi Yan
2025-08-11 20:08 ` Vishal Moola (Oracle)
2025-08-12  2:26 ` wang lian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).