linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/mm: fix split_huge_page_test for folio_split() tests.
@ 2025-07-09  1:27 Zi Yan
  2025-07-09  2:55 ` Baolin Wang
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Zi Yan @ 2025-07-09  1:27 UTC (permalink / raw)
  To: Andrew Morton, linux-mm
  Cc: David Hildenbrand, Lorenzo Stoakes, Zi Yan, Baolin Wang,
	Liam R. Howlett, Nico Pache, Ryan Roberts, Dev Jain, Barry Song,
	Shuah Khan, linux-kselftest, linux-kernel

PID_FMT does not have an offset field, so folio_split() tests are not
performed. Add PID_FMT_OFFSET with an offset field and use it to perform
folio_split() tests.

Fixes: 80a5c494c89f ("selftests/mm: add tests for folio_split(), buddy allocator like split")
Signed-off-by: Zi Yan <ziy@nvidia.com>
---
 tools/testing/selftests/mm/split_huge_page_test.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
index aa7400ed0e99..f0d9c035641d 100644
--- a/tools/testing/selftests/mm/split_huge_page_test.c
+++ b/tools/testing/selftests/mm/split_huge_page_test.c
@@ -31,6 +31,7 @@ uint64_t pmd_pagesize;
 #define INPUT_MAX 80
 
 #define PID_FMT "%d,0x%lx,0x%lx,%d"
+#define PID_FMT_OFFSET "%d,0x%lx,0x%lx,%d,%d"
 #define PATH_FMT "%s,0x%lx,0x%lx,%d"
 
 #define PFN_MASK     ((1UL<<55)-1)
@@ -483,7 +484,7 @@ void split_thp_in_pagecache_to_order_at(size_t fd_size, const char *fs_loc,
 		write_debugfs(PID_FMT, getpid(), (uint64_t)addr,
 			      (uint64_t)addr + fd_size, order);
 	else
-		write_debugfs(PID_FMT, getpid(), (uint64_t)addr,
+		write_debugfs(PID_FMT_OFFSET, getpid(), (uint64_t)addr,
 			      (uint64_t)addr + fd_size, order, offset);
 
 	for (i = 0; i < fd_size; i++)
-- 
2.47.2



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

* Re: [PATCH] selftests/mm: fix split_huge_page_test for folio_split() tests.
  2025-07-09  1:27 [PATCH] selftests/mm: fix split_huge_page_test for folio_split() tests Zi Yan
@ 2025-07-09  2:55 ` Baolin Wang
  2025-07-09  4:56 ` Donet Tom
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Baolin Wang @ 2025-07-09  2:55 UTC (permalink / raw)
  To: Zi Yan, Andrew Morton, linux-mm
  Cc: David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett, Nico Pache,
	Ryan Roberts, Dev Jain, Barry Song, Shuah Khan, linux-kselftest,
	linux-kernel



On 2025/7/9 09:27, Zi Yan wrote:
> PID_FMT does not have an offset field, so folio_split() tests are not
> performed. Add PID_FMT_OFFSET with an offset field and use it to perform
> folio_split() tests.
> 
> Fixes: 80a5c494c89f ("selftests/mm: add tests for folio_split(), buddy allocator like split")
> Signed-off-by: Zi Yan <ziy@nvidia.com>

LGTM.
Tested-by: Baolin Wang <baolin.wang@linux.alibaba.com>

> ---
>   tools/testing/selftests/mm/split_huge_page_test.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
> index aa7400ed0e99..f0d9c035641d 100644
> --- a/tools/testing/selftests/mm/split_huge_page_test.c
> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
> @@ -31,6 +31,7 @@ uint64_t pmd_pagesize;
>   #define INPUT_MAX 80
>   
>   #define PID_FMT "%d,0x%lx,0x%lx,%d"
> +#define PID_FMT_OFFSET "%d,0x%lx,0x%lx,%d,%d"
>   #define PATH_FMT "%s,0x%lx,0x%lx,%d"
>   
>   #define PFN_MASK     ((1UL<<55)-1)
> @@ -483,7 +484,7 @@ void split_thp_in_pagecache_to_order_at(size_t fd_size, const char *fs_loc,
>   		write_debugfs(PID_FMT, getpid(), (uint64_t)addr,
>   			      (uint64_t)addr + fd_size, order);
>   	else
> -		write_debugfs(PID_FMT, getpid(), (uint64_t)addr,
> +		write_debugfs(PID_FMT_OFFSET, getpid(), (uint64_t)addr,
>   			      (uint64_t)addr + fd_size, order, offset);
>   
>   	for (i = 0; i < fd_size; i++)



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

* Re: [PATCH] selftests/mm: fix split_huge_page_test for folio_split() tests.
  2025-07-09  1:27 [PATCH] selftests/mm: fix split_huge_page_test for folio_split() tests Zi Yan
  2025-07-09  2:55 ` Baolin Wang
@ 2025-07-09  4:56 ` Donet Tom
  2025-07-09 12:28 ` Lorenzo Stoakes
  2025-07-11 13:29 ` David Hildenbrand
  3 siblings, 0 replies; 6+ messages in thread
From: Donet Tom @ 2025-07-09  4:56 UTC (permalink / raw)
  To: Zi Yan, Andrew Morton, linux-mm
  Cc: David Hildenbrand, Lorenzo Stoakes, Baolin Wang, Liam R. Howlett,
	Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Shuah Khan,
	linux-kselftest, linux-kernel


On 7/9/25 6:57 AM, Zi Yan wrote:

Hi Zi Yan

> PID_FMT does not have an offset field, so folio_split() tests are not
> performed. Add PID_FMT_OFFSET with an offset field and use it to perform
> folio_split() tests.
>
> Fixes: 80a5c494c89f ("selftests/mm: add tests for folio_split(), buddy allocator like split")
> Signed-off-by: Zi Yan <ziy@nvidia.com>
> ---
>   tools/testing/selftests/mm/split_huge_page_test.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
> index aa7400ed0e99..f0d9c035641d 100644
> --- a/tools/testing/selftests/mm/split_huge_page_test.c
> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
> @@ -31,6 +31,7 @@ uint64_t pmd_pagesize;
>   #define INPUT_MAX 80
>   
>   #define PID_FMT "%d,0x%lx,0x%lx,%d"
> +#define PID_FMT_OFFSET "%d,0x%lx,0x%lx,%d,%d"
>   #define PATH_FMT "%s,0x%lx,0x%lx,%d"
>   
>   #define PFN_MASK     ((1UL<<55)-1)
> @@ -483,7 +484,7 @@ void split_thp_in_pagecache_to_order_at(size_t fd_size, const char *fs_loc,
>   		write_debugfs(PID_FMT, getpid(), (uint64_t)addr,
>   			      (uint64_t)addr + fd_size, order);
>   	else
> -		write_debugfs(PID_FMT, getpid(), (uint64_t)addr,
> +		write_debugfs(PID_FMT_OFFSET, getpid(), (uint64_t)addr,
>   			      (uint64_t)addr + fd_size, order, offset);
>   
>   	for (i = 0; i < fd_size; i++)
>

This looks good to me.

I tested it on my system, and the test is passing.

ok 17 Split PMD-mapped pagecache folio to order 0 at in-folio offset 0 
passed
ok 18 Split PMD-mapped pagecache folio to order 0 at in-folio offset 8 
passed
ok 19 Split PMD-mapped pagecache folio to order 0 at in-folio offset 16 
passed
ok 20 Split PMD-mapped pagecache folio to order 0 at in-folio offset 24 
passed
ok 21 Split PMD-mapped pagecache folio to order 1 at in-folio offset 0 
passed
ok 22 Split PMD-mapped pagecache folio to order 1 at in-folio offset 8 
passed
ok 23 Split PMD-mapped pagecache folio to order 1 at in-folio offset 16 
passed
ok 24 Split PMD-mapped pagecache folio to order 1 at in-folio offset 24 
passed
ok 25 Split PMD-mapped pagecache folio to order 2 at in-folio offset 0 
passed
ok 26 Split PMD-mapped pagecache folio to order 2 at in-folio offset 8 
passed
ok 27 Split PMD-mapped pagecache folio to order 2 at in-folio offset 16 
passed
ok 28 Split PMD-mapped pagecache folio to order 2 at in-folio offset 24 
passed
ok 29 Split PMD-mapped pagecache folio to order 3 at in-folio offset 0 
passed
ok 30 Split PMD-mapped pagecache folio to order 3 at in-folio offset 8 
passed
ok 31 Split PMD-mapped pagecache folio to order 3 at in-folio offset 16 
passed
ok 32 Split PMD-mapped pagecache folio to order 3 at in-folio offset 24 
passed
ok 33 Split PMD-mapped pagecache folio to order 4 at in-folio offset 0 
passed
ok 34 Split PMD-mapped pagecache folio to order 4 at in-folio offset 16 
passed


Feel free to add:

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





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

* Re: [PATCH] selftests/mm: fix split_huge_page_test for folio_split() tests.
  2025-07-09  1:27 [PATCH] selftests/mm: fix split_huge_page_test for folio_split() tests Zi Yan
  2025-07-09  2:55 ` Baolin Wang
  2025-07-09  4:56 ` Donet Tom
@ 2025-07-09 12:28 ` Lorenzo Stoakes
  2025-07-11 13:29 ` David Hildenbrand
  3 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Stoakes @ 2025-07-09 12:28 UTC (permalink / raw)
  To: Zi Yan
  Cc: Andrew Morton, linux-mm, David Hildenbrand, Baolin Wang,
	Liam R. Howlett, Nico Pache, Ryan Roberts, Dev Jain, Barry Song,
	Shuah Khan, linux-kselftest, linux-kernel

On Tue, Jul 08, 2025 at 09:27:59PM -0400, Zi Yan wrote:
> PID_FMT does not have an offset field, so folio_split() tests are not
> performed. Add PID_FMT_OFFSET with an offset field and use it to perform
> folio_split() tests.
>
> Fixes: 80a5c494c89f ("selftests/mm: add tests for folio_split(), buddy allocator like split")
> Signed-off-by: Zi Yan <ziy@nvidia.com>

LGTM, so:

Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

> ---
>  tools/testing/selftests/mm/split_huge_page_test.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
> index aa7400ed0e99..f0d9c035641d 100644
> --- a/tools/testing/selftests/mm/split_huge_page_test.c
> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
> @@ -31,6 +31,7 @@ uint64_t pmd_pagesize;
>  #define INPUT_MAX 80
>
>  #define PID_FMT "%d,0x%lx,0x%lx,%d"
> +#define PID_FMT_OFFSET "%d,0x%lx,0x%lx,%d,%d"
>  #define PATH_FMT "%s,0x%lx,0x%lx,%d"
>
>  #define PFN_MASK     ((1UL<<55)-1)
> @@ -483,7 +484,7 @@ void split_thp_in_pagecache_to_order_at(size_t fd_size, const char *fs_loc,
>  		write_debugfs(PID_FMT, getpid(), (uint64_t)addr,
>  			      (uint64_t)addr + fd_size, order);
>  	else
> -		write_debugfs(PID_FMT, getpid(), (uint64_t)addr,
> +		write_debugfs(PID_FMT_OFFSET, getpid(), (uint64_t)addr,
>  			      (uint64_t)addr + fd_size, order, offset);
>
>  	for (i = 0; i < fd_size; i++)
> --
> 2.47.2
>


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

* Re: [PATCH] selftests/mm: fix split_huge_page_test for folio_split() tests.
  2025-07-09  1:27 [PATCH] selftests/mm: fix split_huge_page_test for folio_split() tests Zi Yan
                   ` (2 preceding siblings ...)
  2025-07-09 12:28 ` Lorenzo Stoakes
@ 2025-07-11 13:29 ` David Hildenbrand
  2025-07-11 14:19   ` Zi Yan
  3 siblings, 1 reply; 6+ messages in thread
From: David Hildenbrand @ 2025-07-11 13:29 UTC (permalink / raw)
  To: Zi Yan, Andrew Morton, linux-mm
  Cc: Lorenzo Stoakes, Baolin Wang, Liam R. Howlett, Nico Pache,
	Ryan Roberts, Dev Jain, Barry Song, Shuah Khan, linux-kselftest,
	linux-kernel

On 09.07.25 03:27, Zi Yan wrote:
> PID_FMT does not have an offset field, so folio_split() tests are not
> performed. Add PID_FMT_OFFSET with an offset field and use it to perform
> folio_split() tests.
> 
> Fixes: 80a5c494c89f ("selftests/mm: add tests for folio_split(), buddy allocator like split")
> Signed-off-by: Zi Yan <ziy@nvidia.com>
> ---
>   tools/testing/selftests/mm/split_huge_page_test.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
> index aa7400ed0e99..f0d9c035641d 100644
> --- a/tools/testing/selftests/mm/split_huge_page_test.c
> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
> @@ -31,6 +31,7 @@ uint64_t pmd_pagesize;
>   #define INPUT_MAX 80
>   
>   #define PID_FMT "%d,0x%lx,0x%lx,%d"
> +#define PID_FMT_OFFSET "%d,0x%lx,0x%lx,%d,%d"
>   #define PATH_FMT "%s,0x%lx,0x%lx,%d"
>   
>   #define PFN_MASK     ((1UL<<55)-1)
> @@ -483,7 +484,7 @@ void split_thp_in_pagecache_to_order_at(size_t fd_size, const char *fs_loc,
>   		write_debugfs(PID_FMT, getpid(), (uint64_t)addr,
>   			      (uint64_t)addr + fd_size, order);
>   	else
> -		write_debugfs(PID_FMT, getpid(), (uint64_t)addr,
> +		write_debugfs(PID_FMT_OFFSET, getpid(), (uint64_t)addr,
>   			      (uint64_t)addr + fd_size, order, offset);
>   
>   	for (i = 0; i < fd_size; i++)

So I assume the tests still passed. Would there be a way to have made 
them fail? (IOW, detect that the wrong kind-of split was performed)

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

-- 
Cheers,

David / dhildenb



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

* Re: [PATCH] selftests/mm: fix split_huge_page_test for folio_split() tests.
  2025-07-11 13:29 ` David Hildenbrand
@ 2025-07-11 14:19   ` Zi Yan
  0 siblings, 0 replies; 6+ messages in thread
From: Zi Yan @ 2025-07-11 14:19 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: Andrew Morton, linux-mm, Lorenzo Stoakes, Baolin Wang,
	Liam R. Howlett, Nico Pache, Ryan Roberts, Dev Jain, Barry Song,
	Shuah Khan, linux-kselftest, linux-kernel

On 11 Jul 2025, at 9:29, David Hildenbrand wrote:

> On 09.07.25 03:27, Zi Yan wrote:
>> PID_FMT does not have an offset field, so folio_split() tests are not
>> performed. Add PID_FMT_OFFSET with an offset field and use it to perform
>> folio_split() tests.
>>
>> Fixes: 80a5c494c89f ("selftests/mm: add tests for folio_split(), buddy allocator like split")
>> Signed-off-by: Zi Yan <ziy@nvidia.com>
>> ---
>>   tools/testing/selftests/mm/split_huge_page_test.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
>> index aa7400ed0e99..f0d9c035641d 100644
>> --- a/tools/testing/selftests/mm/split_huge_page_test.c
>> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
>> @@ -31,6 +31,7 @@ uint64_t pmd_pagesize;
>>   #define INPUT_MAX 80
>>    #define PID_FMT "%d,0x%lx,0x%lx,%d"
>> +#define PID_FMT_OFFSET "%d,0x%lx,0x%lx,%d,%d"
>>   #define PATH_FMT "%s,0x%lx,0x%lx,%d"
>>    #define PFN_MASK     ((1UL<<55)-1)
>> @@ -483,7 +484,7 @@ void split_thp_in_pagecache_to_order_at(size_t fd_size, const char *fs_loc,
>>   		write_debugfs(PID_FMT, getpid(), (uint64_t)addr,
>>   			      (uint64_t)addr + fd_size, order);
>>   	else
>> -		write_debugfs(PID_FMT, getpid(), (uint64_t)addr,
>> +		write_debugfs(PID_FMT_OFFSET, getpid(), (uint64_t)addr,
>>   			      (uint64_t)addr + fd_size, order, offset);
>>    	for (i = 0; i < fd_size; i++)
>
> So I assume the tests still passed. Would there be a way to have made them fail? (IOW, detect that the wrong kind-of split was performed)

Only if the initial PMD page is not split. To detect whether all after-split
folios are the size we expect, additional code that reads kpageflags
is needed. I will put it in my TODO to make this test more robust.

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

Thanks.

Best Regards,
Yan, Zi


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

end of thread, other threads:[~2025-07-11 14:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-09  1:27 [PATCH] selftests/mm: fix split_huge_page_test for folio_split() tests Zi Yan
2025-07-09  2:55 ` Baolin Wang
2025-07-09  4:56 ` Donet Tom
2025-07-09 12:28 ` Lorenzo Stoakes
2025-07-11 13:29 ` David Hildenbrand
2025-07-11 14:19   ` Zi Yan

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