[PATCH bpf-next 5/8] selftests/bpf: Use CAN_USE_LOAD_ACQ_STORE_REL when appropriate
Pu Lehui
pulehui at huawei.com
Tue May 6 07:22:49 PDT 2025
On 2025/4/30 8:51, Peilin Ye wrote:
> 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.
>
> Signed-off-by: Peilin Ye <yepeilin at google.com>
> ---
> tools/testing/selftests/bpf/progs/verifier_precision.c | 5 ++---
> tools/testing/selftests/bpf/progs/verifier_store_release.c | 7 +++----
> 2 files changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/progs/verifier_precision.c b/tools/testing/selftests/bpf/progs/verifier_precision.c
> index 6662d4b39969..2dd0d15c2678 100644
> --- a/tools/testing/selftests/bpf/progs/verifier_precision.c
> +++ b/tools/testing/selftests/bpf/progs/verifier_precision.c
> @@ -91,8 +91,7 @@ __naked int bpf_end_bswap(void)
> ::: __clobber_all);
> }
>
> -#if defined(ENABLE_ATOMICS_TESTS) && \
> - (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86))
> +#ifdef CAN_USE_LOAD_ACQ_STORE_REL
>
> SEC("?raw_tp")
> __success __log_level(2)
> @@ -138,7 +137,7 @@ __naked int bpf_store_release(void)
> : __clobber_all);
> }
>
> -#endif /* load-acquire, store-release */
> +#endif /* CAN_USE_LOAD_ACQ_STORE_REL */
> #endif /* v4 instruction */
>
> SEC("?raw_tp")
> diff --git a/tools/testing/selftests/bpf/progs/verifier_store_release.c b/tools/testing/selftests/bpf/progs/verifier_store_release.c
> index c0442d5bb049..7e456e2861b4 100644
> --- a/tools/testing/selftests/bpf/progs/verifier_store_release.c
> +++ b/tools/testing/selftests/bpf/progs/verifier_store_release.c
> @@ -6,8 +6,7 @@
> #include "../../../include/linux/filter.h"
> #include "bpf_misc.h"
>
> -#if __clang_major__ >= 18 && defined(ENABLE_ATOMICS_TESTS) && \
> - (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86))
> +#ifdef CAN_USE_LOAD_ACQ_STORE_REL
>
> SEC("socket")
> __description("store-release, 8-bit")
> @@ -271,7 +270,7 @@ __naked void store_release_with_invalid_reg(void)
> : __clobber_all);
> }
>
> -#else
> +#else /* CAN_USE_LOAD_ACQ_STORE_REL */
>
> SEC("socket")
> __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)
> return 0;
> }
>
> -#endif
> +#endif /* CAN_USE_LOAD_ACQ_STORE_REL */
>
> char _license[] SEC("license") = "GPL";
Reviewed-by: Pu Lehui <pulehui at huawei.com>
More information about the linux-riscv
mailing list