Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH] selftests/mm: remove unreachable returns after ksft exit helpers
@ 2026-09-03 13:52 Zenghui Yu
  2026-09-03 14:04 ` Lorenzo Stoakes (ARM)
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Zenghui Yu @ 2026-09-03 13:52 UTC (permalink / raw)
  To: linux-mm, linux-kselftest, linux-kernel
  Cc: akpm, david, ljs, liam, vbabka, rppt, surenb, mhocko, shuah, ziy,
	baolin.wang, nico.pache, ryan.roberts, dev.jain, baohua,
	lance.yang, usama.arif, Zenghui Yu (Huawei)

From: "Zenghui Yu (Huawei)" <zenghui.yu@linux.dev>

The ksft_exit*() helpers such as ksft_exit_fail_msg() are declared
__noreturn, and the ksft_exit() and ksft_finished() macros expand to calls
of them, always terminating the process via exit().  Any return statements
following such calls are unreachable, both at the end of main() and on
error paths of helper functions.

Remove all of them.  No functional change.

Assisted-by: GLM-5.3 OpenCode
Signed-off-by: Zenghui Yu (Huawei) <zenghui.yu@linux.dev>
---
 tools/testing/selftests/mm/folio_split_race_test.c | 2 --
 tools/testing/selftests/mm/mlock-random-test.c     | 1 -
 tools/testing/selftests/mm/pkey_sighandler_tests.c | 1 -
 tools/testing/selftests/mm/split_huge_page_test.c  | 4 ----
 4 files changed, 8 deletions(-)

diff --git a/tools/testing/selftests/mm/folio_split_race_test.c b/tools/testing/selftests/mm/folio_split_race_test.c
index 45b84f7b364e..1960635a953e 100644
--- a/tools/testing/selftests/mm/folio_split_race_test.c
+++ b/tools/testing/selftests/mm/folio_split_race_test.c
@@ -269,6 +269,4 @@ int main(void)
 				      NUM_ITERATIONS);
 
 	ksft_exit(iter == NUM_ITERATIONS);
-
-	return 0;
 }
diff --git a/tools/testing/selftests/mm/mlock-random-test.c b/tools/testing/selftests/mm/mlock-random-test.c
index 16294bc7dae6..58772914fd79 100644
--- a/tools/testing/selftests/mm/mlock-random-test.c
+++ b/tools/testing/selftests/mm/mlock-random-test.c
@@ -71,7 +71,6 @@ int get_proc_locked_vm_size(void)
 
 	fclose(f);
 	ksft_exit_fail_msg("cannot parse VmLck in /proc/self/status: %s\n", strerror(errno));
-	return -1;
 }
 
 /*
diff --git a/tools/testing/selftests/mm/pkey_sighandler_tests.c b/tools/testing/selftests/mm/pkey_sighandler_tests.c
index 74bf79a5399d..f9c728ba96a5 100644
--- a/tools/testing/selftests/mm/pkey_sighandler_tests.c
+++ b/tools/testing/selftests/mm/pkey_sighandler_tests.c
@@ -556,5 +556,4 @@ int main(int argc, char *argv[])
 	}
 
 	ksft_finished();
-	return 0;
 }
diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
index 86a603692826..c01d227d7fd6 100644
--- a/tools/testing/selftests/mm/split_huge_page_test.c
+++ b/tools/testing/selftests/mm/split_huge_page_test.c
@@ -101,7 +101,6 @@ static bool is_backed_by_folio(char *vaddr, int order, int pagemap_fd,
 	return (pfn_flags & folio_tail_flags) != folio_tail_flags;
 fail:
 	ksft_exit_fail_msg("Failed to get folio info\n");
-	return false;
 }
 
 static int check_after_split_folio_orders(char *vaddr_start, size_t len,
@@ -548,7 +547,6 @@ static int create_pagecache_thp_and_fd(const char *testfile, size_t fd_size,
 err_out_unlink:
 	unlink(testfile);
 	ksft_exit_fail_msg("Failed to create large pagecache folios\n");
-	return -1;
 }
 
 static void split_thp_in_pagecache_to_order_at(size_t fd_size,
@@ -711,6 +709,4 @@ int main(int argc, char **argv)
 	free(expected_orders);
 
 	ksft_finished();
-
-	return 0;
 }
-- 
2.53.0


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

* Re: [PATCH] selftests/mm: remove unreachable returns after ksft exit helpers
  2026-09-03 13:52 [PATCH] selftests/mm: remove unreachable returns after ksft exit helpers Zenghui Yu
@ 2026-09-03 14:04 ` Lorenzo Stoakes (ARM)
  2026-09-04  0:44 ` SJ Park
  2026-09-04  1:33 ` Zi Yan
  2 siblings, 0 replies; 4+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-09-03 14:04 UTC (permalink / raw)
  To: Zenghui Yu
  Cc: linux-mm, linux-kselftest, linux-kernel, akpm, david, liam,
	vbabka, rppt, surenb, mhocko, shuah, ziy, baolin.wang, nico.pache,
	ryan.roberts, dev.jain, baohua, lance.yang, usama.arif

On Thu, Sep 03, 2026 at 09:52:51PM +0800, Zenghui Yu wrote:
> From: "Zenghui Yu (Huawei)" <zenghui.yu@linux.dev>
>
> The ksft_exit*() helpers such as ksft_exit_fail_msg() are declared
> __noreturn, and the ksft_exit() and ksft_finished() macros expand to calls
> of them, always terminating the process via exit().  Any return statements
> following such calls are unreachable, both at the end of main() and on
> error paths of helper functions.
>
> Remove all of them.  No functional change.
>
> Assisted-by: GLM-5.3 OpenCode

Thanks for providing the tag, much appreciated :)

> Signed-off-by: Zenghui Yu (Huawei) <zenghui.yu@linux.dev>

LGTM, so:

Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>

> ---
>  tools/testing/selftests/mm/folio_split_race_test.c | 2 --
>  tools/testing/selftests/mm/mlock-random-test.c     | 1 -
>  tools/testing/selftests/mm/pkey_sighandler_tests.c | 1 -
>  tools/testing/selftests/mm/split_huge_page_test.c  | 4 ----
>  4 files changed, 8 deletions(-)
>
> diff --git a/tools/testing/selftests/mm/folio_split_race_test.c b/tools/testing/selftests/mm/folio_split_race_test.c
> index 45b84f7b364e..1960635a953e 100644
> --- a/tools/testing/selftests/mm/folio_split_race_test.c
> +++ b/tools/testing/selftests/mm/folio_split_race_test.c
> @@ -269,6 +269,4 @@ int main(void)
>  				      NUM_ITERATIONS);
>
>  	ksft_exit(iter == NUM_ITERATIONS);
> -
> -	return 0;
>  }
> diff --git a/tools/testing/selftests/mm/mlock-random-test.c b/tools/testing/selftests/mm/mlock-random-test.c
> index 16294bc7dae6..58772914fd79 100644
> --- a/tools/testing/selftests/mm/mlock-random-test.c
> +++ b/tools/testing/selftests/mm/mlock-random-test.c
> @@ -71,7 +71,6 @@ int get_proc_locked_vm_size(void)
>
>  	fclose(f);
>  	ksft_exit_fail_msg("cannot parse VmLck in /proc/self/status: %s\n", strerror(errno));
> -	return -1;
>  }
>
>  /*
> diff --git a/tools/testing/selftests/mm/pkey_sighandler_tests.c b/tools/testing/selftests/mm/pkey_sighandler_tests.c
> index 74bf79a5399d..f9c728ba96a5 100644
> --- a/tools/testing/selftests/mm/pkey_sighandler_tests.c
> +++ b/tools/testing/selftests/mm/pkey_sighandler_tests.c
> @@ -556,5 +556,4 @@ int main(int argc, char *argv[])
>  	}
>
>  	ksft_finished();
> -	return 0;
>  }
> diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
> index 86a603692826..c01d227d7fd6 100644
> --- a/tools/testing/selftests/mm/split_huge_page_test.c
> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
> @@ -101,7 +101,6 @@ static bool is_backed_by_folio(char *vaddr, int order, int pagemap_fd,
>  	return (pfn_flags & folio_tail_flags) != folio_tail_flags;
>  fail:
>  	ksft_exit_fail_msg("Failed to get folio info\n");
> -	return false;
>  }
>
>  static int check_after_split_folio_orders(char *vaddr_start, size_t len,
> @@ -548,7 +547,6 @@ static int create_pagecache_thp_and_fd(const char *testfile, size_t fd_size,
>  err_out_unlink:
>  	unlink(testfile);
>  	ksft_exit_fail_msg("Failed to create large pagecache folios\n");
> -	return -1;
>  }
>
>  static void split_thp_in_pagecache_to_order_at(size_t fd_size,
> @@ -711,6 +709,4 @@ int main(int argc, char **argv)
>  	free(expected_orders);
>
>  	ksft_finished();
> -
> -	return 0;
>  }
> --
> 2.53.0
>

--
Cheers, Lorenzo

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

* Re: [PATCH] selftests/mm: remove unreachable returns after ksft exit helpers
  2026-09-03 13:52 [PATCH] selftests/mm: remove unreachable returns after ksft exit helpers Zenghui Yu
  2026-09-03 14:04 ` Lorenzo Stoakes (ARM)
@ 2026-09-04  0:44 ` SJ Park
  2026-09-04  1:33 ` Zi Yan
  2 siblings, 0 replies; 4+ messages in thread
From: SJ Park @ 2026-09-04  0:44 UTC (permalink / raw)
  To: Zenghui Yu
  Cc: SJ Park, linux-mm, linux-kselftest, linux-kernel, akpm, david,
	ljs, liam, vbabka, rppt, surenb, mhocko, shuah, ziy, baolin.wang,
	nico.pache, ryan.roberts, dev.jain, baohua, lance.yang,
	usama.arif, Kiryl Shutsemau

'get_maintainer.pl --nogit --nogit-fallback' on mm-new suggests adding Kiryl.
I added him.

- Kiryl Shutsemau <kas@kernel.org>

On Thu,  3 Sep 2026 21:52:51 +0800 Zenghui Yu <zenghui.yu@linux.dev> wrote:

> From: "Zenghui Yu (Huawei)" <zenghui.yu@linux.dev>
> 
> The ksft_exit*() helpers such as ksft_exit_fail_msg() are declared
> __noreturn, and the ksft_exit() and ksft_finished() macros expand to calls
> of them, always terminating the process via exit().  Any return statements
> following such calls are unreachable, both at the end of main() and on
> error paths of helper functions.
> 
> Remove all of them.  No functional change.

Makes sense and looks correct to me :)

> 
> Assisted-by: GLM-5.3 OpenCode
> Signed-off-by: Zenghui Yu (Huawei) <zenghui.yu@linux.dev>

Reviewed-by: SJ Park <sj@kernel.org>


Thanks,
SJ

[...]

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

* Re: [PATCH] selftests/mm: remove unreachable returns after ksft exit helpers
  2026-09-03 13:52 [PATCH] selftests/mm: remove unreachable returns after ksft exit helpers Zenghui Yu
  2026-09-03 14:04 ` Lorenzo Stoakes (ARM)
  2026-09-04  0:44 ` SJ Park
@ 2026-09-04  1:33 ` Zi Yan
  2 siblings, 0 replies; 4+ messages in thread
From: Zi Yan @ 2026-09-04  1:33 UTC (permalink / raw)
  To: Zenghui Yu, linux-mm, linux-kselftest, linux-kernel
  Cc: akpm, david, ljs, liam, vbabka, rppt, surenb, mhocko, shuah,
	baolin.wang, nico.pache, ryan.roberts, dev.jain, baohua,
	lance.yang, usama.arif

On Thu Sep 3, 2026 at 9:52 AM EDT, Zenghui Yu wrote:
> From: "Zenghui Yu (Huawei)" <zenghui.yu@linux.dev>
>
> The ksft_exit*() helpers such as ksft_exit_fail_msg() are declared
> __noreturn, and the ksft_exit() and ksft_finished() macros expand to calls
> of them, always terminating the process via exit().  Any return statements
> following such calls are unreachable, both at the end of main() and on
> error paths of helper functions.
>
> Remove all of them.  No functional change.
>
> Assisted-by: GLM-5.3 OpenCode
> Signed-off-by: Zenghui Yu (Huawei) <zenghui.yu@linux.dev>
> ---
>  tools/testing/selftests/mm/folio_split_race_test.c | 2 --
>  tools/testing/selftests/mm/mlock-random-test.c     | 1 -
>  tools/testing/selftests/mm/pkey_sighandler_tests.c | 1 -
>  tools/testing/selftests/mm/split_huge_page_test.c  | 4 ----
>  4 files changed, 8 deletions(-)
>
Reviewed-by: Zi Yan <ziy@nvidia.com>

-- 
Best Regards,
Yan, Zi


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

end of thread, other threads:[~2026-09-04  1:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-03 13:52 [PATCH] selftests/mm: remove unreachable returns after ksft exit helpers Zenghui Yu
2026-09-03 14:04 ` Lorenzo Stoakes (ARM)
2026-09-04  0:44 ` SJ Park
2026-09-04  1:33 ` Zi Yan

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