Skip to contentSkip to conversation

selftests/bpf: Tolerate libarena skeleton failures under BPF_STRICT_BUILD=0

PATCH In review HyeongJun An 5 participants 7 messages Sep 11 – Sep 12

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: Tolerate libarena skeleton failures under BPF_STRICT_BUILD=0

The Makefile documents BPF_STRICT_BUILD=0 as tolerating any BPF object, skeleton, test object or benchmark failure so that the remaining tests still build. Every skeleton rule honours that through
$(if $(PERMISSIVE),...), except the three that build the libarena skeletons. Those invoke a sub-make with no guard, so a libarena failure is fatal even in permissive mode.

With a libarena source that fails to compile, BPF_STRICT_BUILD=0 stops at

make: *** [libarena/libarena.skel.h] Error 2

while an ordinary program failing the same way prints SKIP-BPF and the build carries on.

Guard the three sub-makes the way the other skeleton rules are guarded. The build then prints SKIP-SKEL and continues, and test_progs, test_progs-no_alu32, test_progs-cpuv4 and bench all link. Nothing downstream needs a change, because the missing skeleton drops out through the existing permissive paths and libarena.test.o is reported as SKIP-TEST. The default BPF_STRICT_BUILD=1 still fails on the same input.

Fixes a6850fa388f6 ("selftests/bpf: Add BPF_STRICT_BUILD toggle")
Assisted-by Claude:claude-opus-5
---
 tools/testing/selftests/bpf/Makefile | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/Makefile +6 -3
index 7ea5ba1df29e..a9951774e5c8 100644
@@ -835,17 +835,20 @@ LIBARENA_SKEL := libarena/libarena.skel.h
 LIBARENA_BENCH_SKEL := libarena/libarena_bench.skel.h
 
 $(LIBARENA_SKEL): $(INCLUDE_DIR)/vmlinux.h $(BPFOBJ) $(LIBARENA_BPF_DEPS)
-	+$(MAKE) -C libarena libarena.skel.h $(LIBARENA_MAKE_ARGS)
+	+$(MAKE) -C libarena libarena.skel.h $(LIBARENA_MAKE_ARGS) $(if $(PERMISSIVE),|| \
+		printf '  %-12s %s\n' 'SKIP-SKEL' '$(notdir $@)' 1>&2)
 
 $(LIBARENA_BENCH_SKEL): $(INCLUDE_DIR)/vmlinux.h $(BPFOBJ) $(LIBARENA_BENCH_BPF_DEPS) | $(LIBARENA_SKEL)
-	+$(MAKE) -C libarena benchmarks $(LIBARENA_MAKE_ARGS)
+	+$(MAKE) -C libarena benchmarks $(LIBARENA_MAKE_ARGS) $(if $(PERMISSIVE),|| \
+		printf '  %-12s %s\n' 'SKIP-SKEL' '$(notdir $@)' 1>&2)
 
 ifneq ($(CLANG_HAS_ARENA_ASAN),)
 LIBARENA_ASAN_SKEL := libarena/libarena_asan.skel.h
 CFLAGS += -DHAS_BPF_ARENA_ASAN
 
 $(LIBARENA_ASAN_SKEL): $(INCLUDE_DIR)/vmlinux.h $(BPFOBJ) $(LIBARENA_BPF_DEPS)
-	+$(MAKE) -C libarena libarena_asan.skel.h $(LIBARENA_MAKE_ARGS)
+	+$(MAKE) -C libarena libarena_asan.skel.h $(LIBARENA_MAKE_ARGS) $(if $(PERMISSIVE),|| \
+		printf '  %-12s %s\n' 'SKIP-SKEL' '$(notdir $@)' 1>&2)
 endif
 
 # Define test_progs test runner.

base-commit: af0b84a9215d951d16f26b7ee34353b970cf5d4e

Signature · 1 line
2.43.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] The permissive fallback for libarena sub-makes does not remove the target file on failure, leaving…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The permissive fallback for libarena sub-makes does not remove the target file on failure, leaving a corrupted or empty skeleton header that permanently breaks incremental builds.
- [Medium] The bench executable fails to link and is completely skipped when the libarena benchmark skeleton generation fails, contradicting the commit message's claim that 'bench all link'. --

commit 03a9a4a189e91e03941dfb620bf2f4bda1071094
Author: HyeongJun An <[email protected]>

selftests/bpf: Tolerate libarena skeleton failures under BPF_STRICT_BUILD=0

This patch modifies the libarena skeleton build rules to respect BPF_STRICT_BUILD=0, allowing the build to continue if the libarena skeletons fail to generate. It adds permissive fallback logic to the three libarena sub-makes.

Quoted 2 lines

The build then prints SKIP-SKEL and continues, and test_progs, test_progs-no_alu32, test_progs-cpuv4 and bench all link.

[Severity: Medium]
Is this claim about bench linking successfully accurate when the benchmark skeleton fails?

Looking at the bench target in the Makefile, it has a hardcoded dependency on $(OUTPUT)/bench_libarena.o. The link command unconditionally passes all objects to the compiler:

$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(filter %.a %.o,$^) $(LDLIBS) -o $@ ...

If the libarena benchmark skeleton fails under permissive mode, bench_libarena.o will be missing. Because the link command doesn't filter out skipped benchmark objects, won't this cause the entire bench executable to fail to link and trigger SKIP-LINK instead?

tools/testing/selftests/bpf/Makefile LIBARENA_SKEL := libarena/libarena.skel.h · line 839

Quoted 11 lines
tools/testing/selftests/bpf/Makefile +2 -1
index 7ea5ba1df29e3..a9951774e5c85 100644
@@ -835,17 +835,20 @@ LIBARENA_SKEL := libarena/libarena.skel.h
 LIBARENA_BENCH_SKEL := libarena/libarena_bench.skel.h
 
 $(LIBARENA_SKEL): $(INCLUDE_DIR)/vmlinux.h $(BPFOBJ) $(LIBARENA_BPF_DEPS)
-	+$(MAKE) -C libarena libarena.skel.h $(LIBARENA_MAKE_ARGS)
+	+$(MAKE) -C libarena libarena.skel.h $(LIBARENA_MAKE_ARGS) $(if $(PERMISSIVE),|| \
+		printf '  %-12s %s\n' 'SKIP-SKEL' '$(notdir $@)' 1>&2)

[Severity: High]
Does this missing cleanup leave behind a corrupted skeleton header?

In other permissive fallback rules, ($(RM) $@; printf ...) is used to ensure the target file is removed on failure. Because shell redirection in the sub-make might truncate the skeleton header before bpftool runs, could an error leave a 0-byte or incomplete file behind?

If the file isn't explicitly removed here, won't subsequent incremental builds attempt to use the corrupted skeleton header instead of rebuilding it?

[ ... ]

tools/testing/selftests/bpf/Makefile LIBARENA_SKEL := libarena/libarena.skel.h · line 843

Quoted 4 lines
tools/testing/selftests/bpf/Makefile +2 -1
 $(LIBARENA_BENCH_SKEL): $(INCLUDE_DIR)/vmlinux.h $(BPFOBJ) $(LIBARENA_BENCH_BPF_DEPS) | $(LIBARENA_SKEL)
-	+$(MAKE) -C libarena benchmarks $(LIBARENA_MAKE_ARGS)
+	+$(MAKE) -C libarena benchmarks $(LIBARENA_MAKE_ARGS) $(if $(PERMISSIVE),|| \
+		printf '  %-12s %s\n' 'SKIP-SKEL' '$(notdir $@)' 1>&2)

[Severity: High]
Similarly, should this fallback also remove the target file with $(RM) $@ to prevent breaking future incremental builds with a corrupted libarena_bench.skel.h?

[ ... ]

tools/testing/selftests/bpf/Makefile LIBARENA_SKEL := libarena/libarena.skel.h · line 851

Quoted 8 lines
tools/testing/selftests/bpf/Makefile +2 -1
 ifneq ($(CLANG_HAS_ARENA_ASAN),)
 LIBARENA_ASAN_SKEL := libarena/libarena_asan.skel.h
 CFLAGS += -DHAS_BPF_ARENA_ASAN
 
 $(LIBARENA_ASAN_SKEL): $(INCLUDE_DIR)/vmlinux.h $(BPFOBJ) $(LIBARENA_BPF_DEPS)
-	+$(MAKE) -C libarena libarena_asan.skel.h $(LIBARENA_MAKE_ARGS)
+	+$(MAKE) -C libarena libarena_asan.skel.h $(LIBARENA_MAKE_ARGS) $(if $(PERMISSIVE),|| \
+		printf '  %-12s %s\n' 'SKIP-SKEL' '$(notdir $@)' 1>&2)

[Severity: High]
Does this fallback need the same target cleanup for libarena_asan.skel.h?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to HyeongJun An
The Fixes: tag points to a6850fa388f6 which introduced BPF_STRICT_BUILD, but the inconsistency where other skeleton rules use PERMISSIVE while libarena rules don't was actually introduced by commit…
Quoted 21 lines

The Makefile documents BPF_STRICT_BUILD=0 as tolerating any BPF object, skeleton, test object or benchmark failure so that the remaining tests still build. Every skeleton rule honours that through
$(if $(PERMISSIVE),...), except the three that build the libarena skeletons. Those invoke a sub-make with no guard, so a libarena failure is fatal even in permissive mode.

With a libarena source that fails to compile, BPF_STRICT_BUILD=0 stops at

make: *** [libarena/libarena.skel.h] Error 2

while an ordinary program failing the same way prints SKIP-BPF and the build carries on.

Guard the three sub-makes the way the other skeleton rules are guarded. The build then prints SKIP-SKEL and continues, and test_progs, test_progs-no_alu32, test_progs-cpuv4 and bench all link. Nothing downstream needs a change, because the missing skeleton drops out through the existing permissive paths and libarena.test.o is reported as SKIP-TEST. The default BPF_STRICT_BUILD=1 still fails on the same input.

Quoted 3 lines
Fixes a6850fa388f6 ("selftests/bpf: Add BPF_STRICT_BUILD toggle")
Assisted-by Claude:claude-opus-5

The Fixes: tag points to a6850fa388f6 which introduced BPF_STRICT_BUILD, but the inconsistency where other skeleton rules use PERMISSIVE while libarena rules don't was actually introduced by commit 7e729028d7ff. That commit added PERMISSIVE guards to most skeleton generation rules but missed the three libarena skeleton rules. Should the tag be:

Fixes 7e729028d7ff ("adding ci files")

---
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/34611055093

Acked-by on v1 1/1
#3 lore raw
In reply to HyeongJun An
Quoted 8 lines · HyeongJun An

The Makefile documents BPF_STRICT_BUILD=0 as tolerating any BPF object, skeleton, test object or benchmark failure so that the remaining tests still build. Every skeleton rule honours that through
$(if $(PERMISSIVE),...), except the three that build the libarena skeletons. Those invoke a sub-make with no guard, so a libarena failure is fatal even in permissive mode.

With a libarena source that fails to compile, BPF_STRICT_BUILD=0 stops at

Under which circumstances does this happen to you? I missed this because I was using defconfig + DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT + DEBUG_INFO_BTF + BPF_SYSCALL + BPF_JIT

Quoted 6 lines

make: *** [libarena/libarena.skel.h] Error 2

while an ordinary program failing the same way prints SKIP-BPF and the build carries on.

Quoted 8 lines

Guard the three sub-makes the way the other skeleton rules are guarded. The build then prints SKIP-SKEL and continues, and test_progs, test_progs-no_alu32, test_progs-cpuv4 and bench all link. Nothing downstream needs a change, because the missing skeleton drops out through the existing permissive paths and libarena.test.o is reported as SKIP-TEST. The default BPF_STRICT_BUILD=1 still fails on the same input.

Fixes a6850fa388f6 ("selftests/bpf: Add BPF_STRICT_BUILD toggle")
Quoted 36 lines
Assisted-by Claude:claude-opus-5
---
 tools/testing/selftests/bpf/Makefile | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/Makefile +6 -3
index 7ea5ba1df29e..a9951774e5c8 100644
@@ -835,17 +835,20 @@ LIBARENA_SKEL := libarena/libarena.skel.h
 LIBARENA_BENCH_SKEL := libarena/libarena_bench.skel.h
 
 $(LIBARENA_SKEL): $(INCLUDE_DIR)/vmlinux.h $(BPFOBJ) $(LIBARENA_BPF_DEPS)
-	+$(MAKE) -C libarena libarena.skel.h $(LIBARENA_MAKE_ARGS)
+	+$(MAKE) -C libarena libarena.skel.h $(LIBARENA_MAKE_ARGS) $(if $(PERMISSIVE),|| \
+		printf '  %-12s %s\n' 'SKIP-SKEL' '$(notdir $@)' 1>&2)
 
 $(LIBARENA_BENCH_SKEL): $(INCLUDE_DIR)/vmlinux.h $(BPFOBJ) $(LIBARENA_BENCH_BPF_DEPS) | $(LIBARENA_SKEL)
-	+$(MAKE) -C libarena benchmarks $(LIBARENA_MAKE_ARGS)
+	+$(MAKE) -C libarena benchmarks $(LIBARENA_MAKE_ARGS) $(if $(PERMISSIVE),|| \
+		printf '  %-12s %s\n' 'SKIP-SKEL' '$(notdir $@)' 1>&2)
 
 ifneq ($(CLANG_HAS_ARENA_ASAN),)
 LIBARENA_ASAN_SKEL := libarena/libarena_asan.skel.h
 CFLAGS += -DHAS_BPF_ARENA_ASAN
 
 $(LIBARENA_ASAN_SKEL): $(INCLUDE_DIR)/vmlinux.h $(BPFOBJ) $(LIBARENA_BPF_DEPS)
-	+$(MAKE) -C libarena libarena_asan.skel.h $(LIBARENA_MAKE_ARGS)
+	+$(MAKE) -C libarena libarena_asan.skel.h $(LIBARENA_MAKE_ARGS) $(if $(PERMISSIVE),|| \
+		printf '  %-12s %s\n' 'SKIP-SKEL' '$(notdir $@)' 1>&2)
 endif
 
 # Define test_progs test runner.

base-commit: af0b84a9215d951d16f26b7ee34353b970cf5d4e

#4 lore raw
Quoted 3 lines · Ricardo B. Marlière (SUSE)

Under which circumstances does this happen to you? I missed this because I was using defconfig + DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT + DEBUG_INFO_BTF + BPF_SYSCALL + BPF_JIT

Building against the distro kernel's BTF rather than one from the tree. On Ubuntu 6.17, /sys/kernel/btf/vmlinux carries no bpf_kfunc DECL_TAGs, so the vmlinux.h generated from it has 5 __ksym declarations where a tree-built kernel gives 269, and all six libarena BPF sources fail on undeclared bpf_preempt_disable, bpf_preempt_enable and bpf_stream_vprintk. It seems that is why you did not run into it with a kernel you built yourself.

Thanks for the ack. I checked what the two bots raised and they are both right, including the Fixes: tag, so the patch needs more work than this.

HyeongJun

maintainer
#5 lore raw
In reply to HyeongJun An
Quoted 21 lines · HyeongJun An

The Makefile documents BPF_STRICT_BUILD=0 as tolerating any BPF object, skeleton, test object or benchmark failure so that the remaining tests still build. Every skeleton rule honours that through
$(if $(PERMISSIVE),...), except the three that build the libarena skeletons. Those invoke a sub-make with no guard, so a libarena failure is fatal even in permissive mode.

With a libarena source that fails to compile, BPF_STRICT_BUILD=0 stops at

make: *** [libarena/libarena.skel.h] Error 2

while an ordinary program failing the same way prints SKIP-BPF and the build carries on.

Guard the three sub-makes the way the other skeleton rules are guarded. The build then prints SKIP-SKEL and continues, and test_progs, test_progs-no_alu32, test_progs-cpuv4 and bench all link. Nothing downstream needs a change, because the missing skeleton drops out through the existing permissive paths and libarena.test.o is reported as SKIP-TEST. The default BPF_STRICT_BUILD=1 still fails on the same input.

Quoted 4 lines
Fixes a6850fa388f6 ("selftests/bpf: Add BPF_STRICT_BUILD toggle")
Assisted-by Claude:claude-opus-5

---

Why is this change necessary?
The whole PERMISSIVE thing is quite ugly and I regret not being involved in it's review.

...

#6 lore raw
Quoted 3 lines · Eduard Zingerman

Why is this change necessary?
The whole PERMISSIVE thing is quite ugly and I regret not being involved in it's review.

I hit it building selftests against the distro kernel's BTF rather than one from the tree. On Ubuntu 6.17 that vmlinux.h has 5 __ksym declarations against 269 from a tree-built kernel, and all six libarena sources fail on undeclared bpf_preempt_disable, bpf_preempt_enable and bpf_stream_vprintk. BPF_STRICT_BUILD=0 looked like the switch for that, and the build still stopped at libarena while every other skeleton was skipped.

The patch only makes the three libarena rules consistent with the other skeleton rules. I don't have a strong opinion on PERMISSIVE itself, so if it is going away or being reworked, please drop this rather than take it.

HyeongJun