mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] selftests/mm: hugetlb_madv_vs_map: fix TAP plan mismatches
@ 2026-10-07  9:28 Jaeyeon Lee
  2026-10-07 10:16 ` David Hildenbrand (Arm)
  0 siblings, 1 reply; 3+ messages in thread
From: Jaeyeon Lee @ 2026-10-07  9:28 UTC (permalink / raw)
  To: Andrew Morton, Guillaume Morin
  Cc: David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett,
	Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
	Shuah Khan, Breno Leitao, Sarthak Sharma, linux-mm,
	linux-kselftest, linux-kernel, Jaeyeon Lee

The plan was raised from 1 to 3, but the HugeTLB setup check that may
call ksft_exit_skip() still runs after ksft_set_plan(), so a setup
failure reports one result against a plan of 3. Move ksft_set_plan()
below the setup check.

Also, when the underflow check fails, or munmap() fails,
test_underflow() jumps to err_cleanup and exits without reporting the
remaining results. Report the munmap() failure as a test result and
skip the final HugePages_Rsvd check in err_cleanup, so these failure
paths report all 3 planned results.

Fixes: 827149aad495 ("selftests/mm: hugetlb_madv_vs_map: add underflow test")
Assisted-by: LLM
Signed-off-by: Jaeyeon Lee <jaeyeon.lee.dev@gmail.com>
---
Changes in v2:
- Drop the duplicate ksft_perror() and report errno in
  ksft_test_result_fail() (Sarthak Sharma).

 tools/testing/selftests/mm/hugetlb_madv_vs_map.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/mm/hugetlb_madv_vs_map.c b/tools/testing/selftests/mm/hugetlb_madv_vs_map.c
index 1d111f42dd59..0f6afb834dbf 100644
--- a/tools/testing/selftests/mm/hugetlb_madv_vs_map.c
+++ b/tools/testing/selftests/mm/hugetlb_madv_vs_map.c
@@ -168,7 +168,7 @@ void test_underflow(void)
 
 	/* First unmap, this will close the vma */
 	if (munmap(huge_ptr, mmap_size) != 0) {
-		ksft_perror("munmap failed");
+		ksft_test_result_fail("munmap failed: %s (%d)\n", strerror(errno), errno);
 		goto err_cleanup;
 	}
 
@@ -203,18 +203,20 @@ void test_underflow(void)
 	if (waitpid(pid, NULL, 0) <= 0)
 		ksft_exit_fail_perror("waitpid failed");
 
+	ksft_test_result_skip("HugePages_Rsvd check after child exit\n");
 	ksft_exit_fail();
 }
 
 int main(void)
 {
 	ksft_print_header();
-	ksft_set_plan(3);
 
 	if (!hugetlb_setup_default_exact(1))
 		ksft_exit_skip("This test needs one and only one page to execute. Got %lu\n",
 			       hugetlb_free_default_pages());
 
+	ksft_set_plan(3);
+
 	test_madv_vs_map();
 	test_underflow();
 
-- 
2.43.0


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

* Re: [PATCH v2] selftests/mm: hugetlb_madv_vs_map: fix TAP plan mismatches
  2026-10-07  9:28 [PATCH v2] selftests/mm: hugetlb_madv_vs_map: fix TAP plan mismatches Jaeyeon Lee
@ 2026-10-07 10:16 ` David Hildenbrand (Arm)
  2026-10-07 12:01   ` Sarthak Sharma
  0 siblings, 1 reply; 3+ messages in thread
From: David Hildenbrand (Arm) @ 2026-10-07 10:16 UTC (permalink / raw)
  To: Jaeyeon Lee, Andrew Morton, Guillaume Morin
  Cc: Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Shuah Khan, Breno Leitao,
	Sarthak Sharma, linux-mm, linux-kselftest, linux-kernel

On 10/7/26 11:28, Jaeyeon Lee wrote:
> The plan was raised from 1 to 3, but the HugeTLB setup check that may
> call ksft_exit_skip() still runs after ksft_set_plan(), so a setup
> failure reports one result against a plan of 3. Move ksft_set_plan()
> below the setup check.
> 
> Also, when the underflow check fails, or munmap() fails,
> test_underflow() jumps to err_cleanup and exits without reporting the
> remaining results. Report the munmap() failure as a test result and
> skip the final HugePages_Rsvd check in err_cleanup, so these failure
> paths report all 3 planned results.
> 
> Fixes: 827149aad495 ("selftests/mm: hugetlb_madv_vs_map: add underflow test")
> Assisted-by: LLM
> Signed-off-by: Jaeyeon Lee <jaeyeon.lee.dev@gmail.com>
> ---
> Changes in v2:
> - Drop the duplicate ksft_perror() and report errno in
>   ksft_test_result_fail() (Sarthak Sharma).
> 
>  tools/testing/selftests/mm/hugetlb_madv_vs_map.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/mm/hugetlb_madv_vs_map.c b/tools/testing/selftests/mm/hugetlb_madv_vs_map.c
> index 1d111f42dd59..0f6afb834dbf 100644
> --- a/tools/testing/selftests/mm/hugetlb_madv_vs_map.c
> +++ b/tools/testing/selftests/mm/hugetlb_madv_vs_map.c
> @@ -168,7 +168,7 @@ void test_underflow(void)
>  
>  	/* First unmap, this will close the vma */
>  	if (munmap(huge_ptr, mmap_size) != 0) {
> -		ksft_perror("munmap failed");
> +		ksft_test_result_fail("munmap failed: %s (%d)\n", strerror(errno), errno);
>  		goto err_cleanup;
>  	}
>  
> @@ -203,18 +203,20 @@ void test_underflow(void)
>  	if (waitpid(pid, NULL, 0) <= 0)
>  		ksft_exit_fail_perror("waitpid failed");
>  
> +	ksft_test_result_skip("HugePages_Rsvd check after child exit\n");
>  	ksft_exit_fail();

That looks odd. SKIP + fail on the same path?

-- 
Cheers,

David

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

* Re: [PATCH v2] selftests/mm: hugetlb_madv_vs_map: fix TAP plan mismatches
  2026-10-07 10:16 ` David Hildenbrand (Arm)
@ 2026-10-07 12:01   ` Sarthak Sharma
  0 siblings, 0 replies; 3+ messages in thread
From: Sarthak Sharma @ 2026-10-07 12:01 UTC (permalink / raw)
  To: David Hildenbrand (Arm), Jaeyeon Lee, Andrew Morton, Guillaume Morin
  Cc: Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Shuah Khan, Breno Leitao,
	linux-mm, linux-kselftest, linux-kernel



On 10/7/26 3:46 PM, David Hildenbrand (Arm) wrote:
> On 10/7/26 11:28, Jaeyeon Lee wrote:
>> The plan was raised from 1 to 3, but the HugeTLB setup check that may
>> call ksft_exit_skip() still runs after ksft_set_plan(), so a setup
>> failure reports one result against a plan of 3. Move ksft_set_plan()
>> below the setup check.
>>
>> Also, when the underflow check fails, or munmap() fails,
>> test_underflow() jumps to err_cleanup and exits without reporting the
>> remaining results. Report the munmap() failure as a test result and
>> skip the final HugePages_Rsvd check in err_cleanup, so these failure
>> paths report all 3 planned results.
>>
>> Fixes: 827149aad495 ("selftests/mm: hugetlb_madv_vs_map: add underflow test")
>> Assisted-by: LLM
>> Signed-off-by: Jaeyeon Lee <jaeyeon.lee.dev@gmail.com>
>> ---
>> Changes in v2:
>> - Drop the duplicate ksft_perror() and report errno in
>>   ksft_test_result_fail() (Sarthak Sharma).
>>
>>  tools/testing/selftests/mm/hugetlb_madv_vs_map.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/testing/selftests/mm/hugetlb_madv_vs_map.c b/tools/testing/selftests/mm/hugetlb_madv_vs_map.c
>> index 1d111f42dd59..0f6afb834dbf 100644
>> --- a/tools/testing/selftests/mm/hugetlb_madv_vs_map.c
>> +++ b/tools/testing/selftests/mm/hugetlb_madv_vs_map.c
>> @@ -168,7 +168,7 @@ void test_underflow(void)
>>  
>>  	/* First unmap, this will close the vma */
>>  	if (munmap(huge_ptr, mmap_size) != 0) {
>> -		ksft_perror("munmap failed");
>> +		ksft_test_result_fail("munmap failed: %s (%d)\n", strerror(errno), errno);
>>  		goto err_cleanup;
>>  	}
>>  
>> @@ -203,18 +203,20 @@ void test_underflow(void)
>>  	if (waitpid(pid, NULL, 0) <= 0)
>>  		ksft_exit_fail_perror("waitpid failed");
>>  
>> +	ksft_test_result_skip("HugePages_Rsvd check after child exit\n");
>>  	ksft_exit_fail();
> 
> That looks odd. SKIP + fail on the same path?

Seemed odd to me too when I read it. But it seems like one function
contains 2 tests:

i) Check resv_hugepages when parent unmaps the VMA and child is holding
the hugetlb page

ii) Check resv_hugepages when child exits

So we're skipping the third test if the munmap fails or the second test
fails. Skipping incase of munmap failure makes sense but I'm not sure
about the case when the second test fails, ig this could still run in
that case.

Anyways, the original code also calls a ksft_exit_fail() in err_cleanup,
so this skip is just preserving the TAP test count, else we'll get that
planned tests != run tests message.

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

end of thread, other threads:[~2026-10-07 12:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-07  9:28 [PATCH v2] selftests/mm: hugetlb_madv_vs_map: fix TAP plan mismatches Jaeyeon Lee
2026-10-07 10:16 ` David Hildenbrand (Arm)
2026-10-07 12:01   ` Sarthak Sharma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®