selftests/futex: load atomic values before harness comparisons
PATCH 1/1 selftests/futex: load atomic values before harness comparisons
Clang 21 rejects the harness comparison because typeof(*futex) preserves the atomic qualification. Load the value explicitly in the three affected assertions so the harness compares unsigned integers. Atomic access and its existing sequentially consistent ordering are preserved.
The baseline produces three invalid-operands errors. The complete futex suite builds with Clang 21 and GCC 14 after the change.
--- tools/testing/selftests/futex/functional/robust_list.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/futex/functional/robust_list.c +3 -3
@@ -669,7 +669,7 @@ TEST_F(vdso_unlock, test_robust_try_unlock_uncontended) ret = self->vdso (futex, tid, &head.list_op_pending);ASSERT_EQ (ret, tid); -ASSERT_EQ (*futex,0 ); +ASSERT_EQ (atomic_load (futex),0 );/* Check only the lower 32 bits for the 32-bit entry point */ if (variant->is_32) {
@@ -709,7 +709,7 @@ TEST_F(vdso_unlock, test_robust_try_unlock_contended) ret = self->vdso (futex, tid, &head.list_op_pending);ASSERT_EQ (ret, tid |FUTEX_WAITERS ); -ASSERT_EQ (*futex, tid |FUTEX_WAITERS ); +ASSERT_EQ (atomic_load (futex), tid |FUTEX_WAITERS );ASSERT_EQ (head.list_op_pending, &lock.list); }
@@ -793,7 +793,7 @@ TEST_F(futex_op, test_futex_robust_unlock) &head.list_op_pending, variant->val3);ASSERT_EQ (ret,0 ); -ASSERT_EQ (*futex,0 ); +ASSERT_EQ (atomic_load (futex),0 );if (variant->op &FUTEX_ROBUST_LIST32 ) { exp = (uint64_t )(unsigned long )&lock.list;
base-commit: 4eb2586bd40db27d77cc5b724ca9386ed0c71d53
Signature · 1 line
2.53.0
Ping, this still applies on 7.4-rc1. The clang jobs in KernelCI still fail to build futex/functional/robust_list.c with the three invalid-operands errors.
Signature · 2 lines
Thanks, Sasha
Em 14/10/2026 17:01, Sasha Levin escreveu:
Quoted 10 lines
Clang 21 rejects the harness comparison because
typeof(*futex)preserves the atomic qualification. Load the value explicitly in the three affected assertions so the harness compares unsigned integers. Atomic access and its existing sequentially consistent ordering are preserved.The baseline produces three invalid-operands errors. The complete futex suite builds with Clang 21 and GCC 14 after the change.
Fixes 608323bf7bb8 ("selftests: futex: Add tests for robust release operations")Signed-off-by Sasha Levin <[email protected]>
[tip: locking/futex] selftests/futex: Load atomic values before harness comparisons
In reply to Sasha LevinThe following commit has been merged into the locking/futex branch of tip:
The following commit has been merged into the locking/futex branch of tip:
Commit-ID: 30d00ffecaa9624bc7f4f84f3e8ff810be83a0a0 Gitweb: https://git.kernel.org/tip/30d00ffecaa9624bc7f4f84f3e8ff810be83a0a0 Author: Sasha Levin <[email protected]> AuthorDate: Wed, 14 Oct 2026 16:01:47 -04:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Mon, 30 Nov 2026 22:03:34 +01:00
selftests/futex: Load atomic values before harness comparisons
Clang 21 rejects the harness comparison because typeof(*futex) preserves the atomic qualification. Load the value explicitly in the three affected assertions so the harness compares unsigned integers. Atomic access and its existing sequentially consistent ordering are preserved.
The baseline produces three invalid-operands errors. The complete futex suite builds with Clang 21 and GCC 14 after the change.
--- tools/testing/selftests/futex/functional/robust_list.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/futex/functional/robust_list.c +3 -3
@@ -669,7 +669,7 @@ TEST_F(vdso_unlock, test_robust_try_unlock_uncontended) ret = self->vdso (futex, tid, &head.list_op_pending);ASSERT_EQ (ret, tid); -ASSERT_EQ (*futex,0 ); +ASSERT_EQ (atomic_load (futex),0 );/* Check only the lower 32 bits for the 32-bit entry point */ if (variant->is_32) {
@@ -709,7 +709,7 @@ TEST_F(vdso_unlock, test_robust_try_unlock_contended) ret = self->vdso (futex, tid, &head.list_op_pending);ASSERT_EQ (ret, tid |FUTEX_WAITERS ); -ASSERT_EQ (*futex, tid |FUTEX_WAITERS ); +ASSERT_EQ (atomic_load (futex), tid |FUTEX_WAITERS );ASSERT_EQ (head.list_op_pending, &lock.list); }
@@ -793,7 +793,7 @@ TEST_F(futex_op, test_futex_robust_unlock) &head.list_op_pending, variant->val3);ASSERT_EQ (ret,0 ); -ASSERT_EQ (*futex,0 ); +ASSERT_EQ (atomic_load (futex),0 );if (variant->op &FUTEX_ROBUST_LIST32 ) { exp = (uint64_t )(unsigned long )&lock.list;