Skip to contentSkip to conversation

selftests: futex: Restore support checks for futex2 and priv_hash

PATCH In review Wake Liu 3 participants 4 messages Jul 22 – Jul 23

Subsystems (2)
lore
Share & tools
lore

Wake Liu

author
#0 lore raw

PATCH 1/1 selftests: futex: Restore support checks for futex2 and priv_hash

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.

---
 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(+)
tools/testing/selftests/futex/functional/futex_numa_mpol.c +2 -0
index 78c0f7a59e17..d215acf88120 100644
@@ -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);
 		}
tools/testing/selftests/futex/functional/futex_priv_hash.c +2 -0
index e8079d7c65e8..27c3ea5ff3ed 100644
@@ -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);
 
Signature · 1 line
2.55.0.229.g6434b31f56-goog
#1 lore raw

Hi Wake,

Em 22/07/2026 04:08, Wake Liu escreveu:

Quoted 16 lines

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.

---
  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(+)
tools/testing/selftests/futex/functional/futex_numa_mpol.c +0 -0
index 78c0f7a59e17..d215acf88120 100644

tools/testing/selftests/futex/functional/futex_numa_mpol.c static void __test_futex(void *futex_ptr, int err_value, unsigned int futex_flag · line 107

Quoted 5 lines
tools/testing/selftests/futex/functional/futex_numa_mpol.c +2 -0
@@ -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

Quoted 16 lines
tools/testing/selftests/futex/functional/futex_numa_mpol.c +0 -0
  			ksft_exit_fail_msg("Failed futex2_wake(%d, 0x%x): %m\n",
  					   to_wake, futex_flags);
  		}
tools/testing/selftests/futex/functional/futex_priv_hash.c +2 -0
index e8079d7c65e8..27c3ea5ff3ed 100644
@@ -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 lore raw
Quoted 28 lines · André Almeida

Hi Wake,

Em 22/07/2026 04:08, Wake Liu escreveu:

Quoted 16 lines

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.

---
  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(+)
tools/testing/selftests/futex/functional/futex_numa_mpol.c +0 -0
index 78c0f7a59e17..d215acf88120 100644

tools/testing/selftests/futex/functional/futex_numa_mpol.c static void __test_futex(void *futex_ptr, int err_value, unsigned int futex_flag · line 107

Quoted 5 lines
tools/testing/selftests/futex/functional/futex_numa_mpol.c +2 -0
@@ -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

Quoted 1 line

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/[email protected]/
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

author
#3 lore raw

Hi Carlos, André,

Ah, sorry about that. I didn't realize that I had already submitted the exact same patch and that Thomas had already merged/refactored it. Please ignore my previous email.

Best regards,
Wake

Quoted 41 lines · Carlos Llamas
Quoted 28 lines · André Almeida

Hi Wake,

Em 22/07/2026 04:08, Wake Liu escreveu:

Quoted 16 lines

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.

---
  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(+)
tools/testing/selftests/futex/functional/futex_numa_mpol.c +0 -0
index 78c0f7a59e17..d215acf88120 100644

tools/testing/selftests/futex/functional/futex_numa_mpol.c static void __test_futex(void *futex_ptr, int err_value, unsigned int futex_flag · line 107

Quoted 5 lines
tools/testing/selftests/futex/functional/futex_numa_mpol.c +2 -0
@@ -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

Quoted 1 line

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/[email protected]/
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

Signature · 2 lines
Best Regards,
Wake Liu