The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] selftests: futex: Restore support checks for futex2 and priv_hash
@ 2026-07-22  7:08 Wake Liu
  2026-07-22 15:20 ` André Almeida
  0 siblings, 1 reply; 3+ messages in thread
From: Wake Liu @ 2026-07-22  7:08 UTC (permalink / raw)
  To: shuah, tglx, mingo
  Cc: cmllamas, andrealmeid, linux-kselftest, linux-kernel, peterz,
	dvhart, dave, Wake Liu

Older kernels may not support FUTEX2 syscalls or PR_FUTEX_HASH.
Removing these checks causes false failures when running the tests on
such kernels. Restore the checks so the tests can be gracefully
skipped when the features are not supported.

Signed-off-by: Wake Liu <wakel@google.com>
---
 tools/testing/selftests/futex/functional/futex_numa_mpol.c | 2 ++
 tools/testing/selftests/futex/functional/futex_priv_hash.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/tools/testing/selftests/futex/functional/futex_numa_mpol.c b/tools/testing/selftests/futex/functional/futex_numa_mpol.c
index 78c0f7a59e17..d215acf88120 100644
--- a/tools/testing/selftests/futex/functional/futex_numa_mpol.c
+++ b/tools/testing/selftests/futex/functional/futex_numa_mpol.c
@@ -103,6 +103,8 @@ static void __test_futex(void *futex_ptr, int err_value, unsigned int futex_flag
 			break;
 		}
 		if (ret < 0) {
+			if (errno == ENOSYS || (errno == EINVAL && (futex_flags & FUTEX2_NUMA)))
+				ksft_exit_skip("futex2 or FUTEX2_NUMA not supported by kernel\n");
 			ksft_exit_fail_msg("Failed futex2_wake(%d, 0x%x): %m\n",
 					   to_wake, futex_flags);
 		}
diff --git a/tools/testing/selftests/futex/functional/futex_priv_hash.c b/tools/testing/selftests/futex/functional/futex_priv_hash.c
index e8079d7c65e8..27c3ea5ff3ed 100644
--- a/tools/testing/selftests/futex/functional/futex_priv_hash.c
+++ b/tools/testing/selftests/futex/functional/futex_priv_hash.c
@@ -145,6 +145,8 @@ TEST(priv_hash)
 	}
 	/* First thread, expect to be 0, not yet initialized */
 	ret = futex_hash_slots_get();
+	if (ret < 0 && errno == EINVAL)
+		ksft_exit_skip("PR_FUTEX_HASH not supported by kernel\n");
 	if (ret != 0)
 		ksft_exit_fail_msg("futex_hash_slots_get() failed: %d, %m\n", ret);
 
-- 
2.55.0.229.g6434b31f56-goog


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

* Re: [PATCH] selftests: futex: Restore support checks for futex2 and priv_hash
  2026-07-22  7:08 [PATCH] selftests: futex: Restore support checks for futex2 and priv_hash Wake Liu
@ 2026-07-22 15:20 ` André Almeida
  2026-07-22 16:51   ` Carlos Llamas
  0 siblings, 1 reply; 3+ messages in thread
From: André Almeida @ 2026-07-22 15:20 UTC (permalink / raw)
  To: Wake Liu
  Cc: cmllamas, tglx, linux-kselftest, linux-kernel, peterz, dvhart,
	dave, shuah, mingo

Hi Wake,

Em 22/07/2026 04:08, Wake Liu escreveu:
> Older kernels may not support FUTEX2 syscalls or PR_FUTEX_HASH.
> Removing these checks causes false failures when running the tests on
> such kernels. Restore the checks so the tests can be gracefully
> skipped when the features are not supported.
> 
> Signed-off-by: Wake Liu <wakel@google.com>
> ---
>   tools/testing/selftests/futex/functional/futex_numa_mpol.c | 2 ++
>   tools/testing/selftests/futex/functional/futex_priv_hash.c | 2 ++
>   2 files changed, 4 insertions(+)
> 
> diff --git a/tools/testing/selftests/futex/functional/futex_numa_mpol.c b/tools/testing/selftests/futex/functional/futex_numa_mpol.c
> index 78c0f7a59e17..d215acf88120 100644
> --- a/tools/testing/selftests/futex/functional/futex_numa_mpol.c
> +++ b/tools/testing/selftests/futex/functional/futex_numa_mpol.c
> @@ -103,6 +103,8 @@ static void __test_futex(void *futex_ptr, int err_value, unsigned int futex_flag
>   			break;
>   		}
>   		if (ret < 0) {
> +			if (errno == ENOSYS || (errno == EINVAL && (futex_flags & FUTEX2_NUMA)))
> +				ksft_exit_skip("futex2 or FUTEX2_NUMA not supported by kernel\n");

Why aren't you using SKIP() instead of ksft_exit_skip() like how you 
have done at

https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=locking/futex&id=50c121e5a57abe446e46825fb9c69ac419765d5c


>   			ksft_exit_fail_msg("Failed futex2_wake(%d, 0x%x): %m\n",
>   					   to_wake, futex_flags);
>   		}
> diff --git a/tools/testing/selftests/futex/functional/futex_priv_hash.c b/tools/testing/selftests/futex/functional/futex_priv_hash.c
> index e8079d7c65e8..27c3ea5ff3ed 100644
> --- a/tools/testing/selftests/futex/functional/futex_priv_hash.c
> +++ b/tools/testing/selftests/futex/functional/futex_priv_hash.c
> @@ -145,6 +145,8 @@ TEST(priv_hash)
>   	}
>   	/* First thread, expect to be 0, not yet initialized */
>   	ret = futex_hash_slots_get();
> +	if (ret < 0 && errno == EINVAL)
> +		ksft_exit_skip("PR_FUTEX_HASH not supported by kernel\n");
>   	if (ret != 0)
>   		ksft_exit_fail_msg("futex_hash_slots_get() failed: %d, %m\n", ret);
>   


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

* Re: [PATCH] selftests: futex: Restore support checks for futex2 and priv_hash
  2026-07-22 15:20 ` André Almeida
@ 2026-07-22 16:51   ` Carlos Llamas
  0 siblings, 0 replies; 3+ messages in thread
From: Carlos Llamas @ 2026-07-22 16:51 UTC (permalink / raw)
  To: André Almeida
  Cc: Wake Liu, tglx, linux-kselftest, linux-kernel, peterz, dvhart,
	dave, shuah, mingo

On Wed, Jul 22, 2026 at 12:20:37PM -0300, André Almeida wrote:
> Hi Wake,
> 
> Em 22/07/2026 04:08, Wake Liu escreveu:
> > Older kernels may not support FUTEX2 syscalls or PR_FUTEX_HASH.
> > Removing these checks causes false failures when running the tests on
> > such kernels. Restore the checks so the tests can be gracefully
> > skipped when the features are not supported.
> > 
> > Signed-off-by: Wake Liu <wakel@google.com>
> > ---
> >   tools/testing/selftests/futex/functional/futex_numa_mpol.c | 2 ++
> >   tools/testing/selftests/futex/functional/futex_priv_hash.c | 2 ++
> >   2 files changed, 4 insertions(+)
> > 
> > diff --git a/tools/testing/selftests/futex/functional/futex_numa_mpol.c b/tools/testing/selftests/futex/functional/futex_numa_mpol.c
> > index 78c0f7a59e17..d215acf88120 100644
> > --- a/tools/testing/selftests/futex/functional/futex_numa_mpol.c
> > +++ b/tools/testing/selftests/futex/functional/futex_numa_mpol.c
> > @@ -103,6 +103,8 @@ static void __test_futex(void *futex_ptr, int err_value, unsigned int futex_flag
> >   			break;
> >   		}
> >   		if (ret < 0) {
> > +			if (errno == ENOSYS || (errno == EINVAL && (futex_flags & FUTEX2_NUMA)))
> > +				ksft_exit_skip("futex2 or FUTEX2_NUMA not supported by kernel\n");
> 
> Why aren't you using SKIP() instead of ksft_exit_skip() like how you have
> done at
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=locking/futex&id=50c121e5a57abe446e46825fb9c69ac419765d5c

It's actually the same patch. See:
https://lore.kernel.org/all/20260624070223.1533167-1-wakel@google.com/
Thomas, just refactored it to use the harness API.

I'm not sure why Wake sent the same fix twice but it was likely by
mistake. That's all, nothing to see here.

--
Carlos Llamas

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

end of thread, other threads:[~2026-07-22 16:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-22  7:08 [PATCH] selftests: futex: Restore support checks for futex2 and priv_hash Wake Liu
2026-07-22 15:20 ` André Almeida
2026-07-22 16:51   ` Carlos Llamas

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