> selftests/bpf: Test raw_tp test_run ctx padding for tail calls
TL;DR: The new selftest uses "#pragma clang loop", which bpf-gcc doesn't
recognise. The -Werror build may then fail for test_progs-bpf_gcc. Suggest
bpf_compiler.h's __pragma_loop_unroll_full instead.
> diff --git a/tools/testing/selftests/bpf/progs/tailcall_raw_tp_ctx.c b/tools/testing/selftests/bpf/progs/tailcall_raw_tp_ctx.c
> new file mode 100644
> index 000000000000..e8380d19892a
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/progs/tailcall_raw_tp_ctx.c
> @@ -0,0 +1,37 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <linux/bpf.h>
> +#include <bpf/bpf_helpers.h>
[ ... ]
> +SEC("raw_tracepoint/sched_switch")
> +int target(void *ctx)
> +{
> + __u64 *a = ctx;
> +
[ ... ]
> +#pragma clang loop unroll(full)
> + for (int i = 1; i < 12; i++) {
> + if (a[i])
> + return 1;
> + }
> + return 42;
> +}
Will this build with bpf-gcc? The selftests also compile every progs/*.c
for test_progs-bpf_gcc, with -Wall -Werror in BPF_CFLAGS, and GCC does not
recognise "#pragma clang loop":
error: ignoring '#pragma clang loop' [-Werror=unknown-pragmas]
If tailcall_raw_tp_ctx.bpf.o fails to build, tailcall_raw_tp_ctx.skel.h is
missing and prog_tests/tailcalls.c, which now includes it, cannot compile
for that runner.
Even if GCC only warned, the loop would not be forced to unroll, and a
non-unrolled loop would index ctx through a variable pointer, which the
verifier rejects for PTR_TO_CTX.
Commit 52dbd67dff5d ("bpf: Abstract loop unrolling pragmas in BPF
selftests") added bpf_compiler.h for this reason, and progs/test_skb_ctx.c
uses __pragma_loop_unroll_full for a similar loop over ctx fields.
Should this include "bpf_compiler.h" and use __pragma_loop_unroll_full
instead?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/47503569594