Skip to content

Commit 13fdecf

Browse files
peilin-yeAlexei Starovoitov
authored andcommitted
selftests/bpf: Use CAN_USE_LOAD_ACQ_STORE_REL when appropriate
Instead of open-coding the conditions, use '#ifdef CAN_USE_LOAD_ACQ_STORE_REL' to guard the following tests: verifier_precision/bpf_load_acquire verifier_precision/bpf_store_release verifier_store_release/* Note that, for the first two tests in verifier_precision.c, switching to '#ifdef CAN_USE_LOAD_ACQ_STORE_REL' means also checking if '__clang_major__ >= 18', which has already been guaranteed by the outer '#if' check. Acked-by: Björn Töpel <[email protected]> Reviewed-by: Pu Lehui <[email protected]> Tested-by: Björn Töpel <[email protected]> # QEMU/RVA23 Signed-off-by: Peilin Ye <[email protected]> Link: https://lore.kernel.org/r/45d7e025f6e390a8ff36f08fc51e31705ac896bd.1746588351.git.yepeilin@google.com Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent db7a382 commit 13fdecf

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

tools/testing/selftests/bpf/progs/verifier_precision.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ __naked int bpf_end_bswap(void)
9191
::: __clobber_all);
9292
}
9393

94-
#if defined(ENABLE_ATOMICS_TESTS) && \
95-
(defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86))
94+
#ifdef CAN_USE_LOAD_ACQ_STORE_REL
9695

9796
SEC("?raw_tp")
9897
__success __log_level(2)
@@ -138,7 +137,7 @@ __naked int bpf_store_release(void)
138137
: __clobber_all);
139138
}
140139

141-
#endif /* load-acquire, store-release */
140+
#endif /* CAN_USE_LOAD_ACQ_STORE_REL */
142141
#endif /* v4 instruction */
143142

144143
SEC("?raw_tp")

tools/testing/selftests/bpf/progs/verifier_store_release.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
#include "../../../include/linux/filter.h"
77
#include "bpf_misc.h"
88

9-
#if __clang_major__ >= 18 && defined(ENABLE_ATOMICS_TESTS) && \
10-
(defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86))
9+
#ifdef CAN_USE_LOAD_ACQ_STORE_REL
1110

1211
SEC("socket")
1312
__description("store-release, 8-bit")
@@ -271,7 +270,7 @@ __naked void store_release_with_invalid_reg(void)
271270
: __clobber_all);
272271
}
273272

274-
#else
273+
#else /* CAN_USE_LOAD_ACQ_STORE_REL */
275274

276275
SEC("socket")
277276
__description("Clang version < 18, ENABLE_ATOMICS_TESTS not defined, and/or JIT doesn't support store-release, use a dummy test")
@@ -281,6 +280,6 @@ int dummy_test(void)
281280
return 0;
282281
}
283282

284-
#endif
283+
#endif /* CAN_USE_LOAD_ACQ_STORE_REL */
285284

286285
char _license[] SEC("license") = "GPL";

0 commit comments

Comments
 (0)