* [PATCH bpf-next v10 01/11] selftests/bpf: Add BPF_STRICT_BUILD toggle
2026-04-30 12:53 [PATCH bpf-next v10 00/11] selftests/bpf: Tolerate partial builds across kernel configs Ricardo B. Marlière
@ 2026-04-30 12:53 ` Ricardo B. Marlière
2026-04-30 12:53 ` [PATCH bpf-next v10 02/11] selftests/bpf: Fix test_kmods KDIR to honor O= and distro kernels Ricardo B. Marlière
` (9 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Ricardo B. Marlière @ 2026-04-30 12:53 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi,
Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt
Cc: bpf, linux-kselftest, linux-kernel, llvm, Alan Maguire,
Ricardo B. Marliere
Distro kernels often lack BTF types or kernel features required by some BPF
selftests, causing the build to abort on the first failure and preventing
the remaining tests from running.
Add BPF_STRICT_BUILD (default 1) to control build failure tolerance. When
set to 0, the PERMISSIVE make variable is assigned a non-empty value that
subsequent Makefile rules use to make individual build steps non-fatal.
When set to 1 (the default), the build fails on any error, preserving the
existing behavior for CI and direct builds.
Users can opt in to permissive mode on the command line:
make -C tools/testing/selftests \
TARGETS=bpf SKIP_TARGETS= BPF_STRICT_BUILD=0
Suggested-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
tools/testing/selftests/bpf/Makefile | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 97ee61f2ade5..6094fe99b5f6 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -44,6 +44,12 @@ SKIP_LLVM ?=
SKIP_LIBBFD ?=
SKIP_CRYPTO ?=
+# When BPF_STRICT_BUILD is 1, any BPF object, skeleton, test object, or
+# benchmark compilation failure is fatal. Set to 0 to tolerate failures
+# and continue building the remaining tests.
+BPF_STRICT_BUILD ?= 1
+PERMISSIVE := $(filter 0,$(BPF_STRICT_BUILD))
+
ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
--
2.54.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH bpf-next v10 02/11] selftests/bpf: Fix test_kmods KDIR to honor O= and distro kernels
2026-04-30 12:53 [PATCH bpf-next v10 00/11] selftests/bpf: Tolerate partial builds across kernel configs Ricardo B. Marlière
2026-04-30 12:53 ` [PATCH bpf-next v10 01/11] selftests/bpf: Add BPF_STRICT_BUILD toggle Ricardo B. Marlière
@ 2026-04-30 12:53 ` Ricardo B. Marlière
2026-04-30 13:30 ` bot+bpf-ci
2026-04-30 12:53 ` [PATCH bpf-next v10 03/11] selftests/bpf: Tolerate BPF and skeleton generation failures Ricardo B. Marlière
` (8 subsequent siblings)
10 siblings, 1 reply; 20+ messages in thread
From: Ricardo B. Marlière @ 2026-04-30 12:53 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi,
Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt
Cc: bpf, linux-kselftest, linux-kernel, llvm, Alan Maguire,
Ricardo B. Marliere
test_kmods/Makefile always pointed KDIR at the kernel source tree root,
ignoring O= and KBUILD_OUTPUT. On distro kernels where the source tree has
not been built, the Makefile had no fallback and would fail
unconditionally.
When O= or KBUILD_OUTPUT is set and points at a prepared kernel build
directory (one containing Module.symvers), pass it through so kbuild can
locate the correct build infrastructure (scripts, Kconfig, etc.). Note
that the module artifacts themselves still land in the M= directory,
which is test_kmods/; O= only controls where kbuild finds its build
infrastructure. Fall back to /lib/modules/$(uname -r)/build when neither
an explicit valid build directory nor an in-tree Module.symvers is
present.
A selftests-only O= value (one that does not contain Module.symvers, e.g.
a private output directory) is intentionally not treated as a kernel
build directory. Without this guard, a user invoking
"make -C tools/testing/selftests/bpf O=/tmp/out" would have test_kmods
try to use /tmp/out as the kernel build dir and fail.
The parent bpf/Makefile resolves O= and KBUILD_OUTPUT to absolute paths
before invoking the test_kmods sub-make. Without this, $(abspath ...)
inside test_kmods/Makefile would resolve relative paths against the
sub-make's CWD (test_kmods/) rather than the user's invocation directory.
When O= is passed to kbuild, also pass KBUILD_OUTPUT=$(KMOD_O_VALID)
explicitly. The parent invocation lifts KBUILD_OUTPUT into MAKEFLAGS as
a command-line variable, which would otherwise suppress kbuild's own
"KBUILD_OUTPUT := $(O)" assignment and cause it to use the inherited
KBUILD_OUTPUT instead of the validated O=.
Guard both all and clean against a missing KDIR so the step is silently
skipped rather than fatal. Make the parent Makefile's cp conditional so it
does not abort when modules were not built.
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
tools/testing/selftests/bpf/Makefile | 10 +++++----
tools/testing/selftests/bpf/test_kmods/Makefile | 30 ++++++++++++++++++++++---
2 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 6094fe99b5f6..cc6ee7a2df93 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -296,13 +296,15 @@ $(OUTPUT)/sign-file: ../../../../scripts/sign-file.c
# subst() turns the rule into a pattern matching rule
$(addprefix test_kmods/,$(subst .ko,%ko,$(TEST_KMODS))): $(VMLINUX_BTF) $(RESOLVE_BTFIDS) $(wildcard test_kmods/Makefile test_kmods/*.[ch])
$(Q)$(RM) test_kmods/*.ko test_kmods/*.mod.o # force re-compilation
- $(Q)$(MAKE) $(submake_extras) -C test_kmods \
- RESOLVE_BTFIDS=$(RESOLVE_BTFIDS) \
+ $(Q)$(MAKE) $(submake_extras) -C test_kmods \
+ $(if $(O),O=$(abspath $(O))) \
+ $(if $(KBUILD_OUTPUT),KBUILD_OUTPUT=$(abspath $(KBUILD_OUTPUT)))\
+ RESOLVE_BTFIDS=$(RESOLVE_BTFIDS) \
EXTRA_CFLAGS='' EXTRA_LDFLAGS=''
$(TEST_KMOD_TARGETS): $(addprefix test_kmods/,$(TEST_KMODS))
$(call msg,MOD,,$@)
- $(Q)cp test_kmods/$(@F) $@
+ $(Q)$(if $(PERMISSIVE),if [ -f test_kmods/$(@F) ]; then )cp test_kmods/$(@F) $@$(if $(PERMISSIVE),; fi)
DEFAULT_BPFTOOL := $(HOST_SCRATCH_DIR)/sbin/bpftool
@@ -718,7 +720,7 @@ $(TRUNNER_LIB_OBJS): $(TRUNNER_OUTPUT)/%.o:$(TOOLSDIR)/lib/%.c
$(TRUNNER_BINARY)-extras: $(TRUNNER_EXTRA_FILES) | $(TRUNNER_OUTPUT)
ifneq ($2:$(OUTPUT),:$(shell pwd))
$$(call msg,EXT-COPY,$(TRUNNER_BINARY),$(TRUNNER_EXTRA_FILES))
- $(Q)rsync -aq $$^ $(TRUNNER_OUTPUT)/
+ $(Q)rsync -aq $(if $(PERMISSIVE),--ignore-missing-args) $$^ $(TRUNNER_OUTPUT)/
endif
# some X.test.o files have runtime dependencies on Y.bpf.o files
diff --git a/tools/testing/selftests/bpf/test_kmods/Makefile b/tools/testing/selftests/bpf/test_kmods/Makefile
index 63c4d3f6a12f..031c7454ce65 100644
--- a/tools/testing/selftests/bpf/test_kmods/Makefile
+++ b/tools/testing/selftests/bpf/test_kmods/Makefile
@@ -1,5 +1,16 @@
TEST_KMOD_DIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
-KDIR ?= $(abspath $(TEST_KMOD_DIR)/../../../../..)
+SRCTREE_KDIR := $(abspath $(TEST_KMOD_DIR)/../../../../..)
+# Honor O=/KBUILD_OUTPUT only if they point at a prepared kernel build
+# directory (one containing Module.symvers); otherwise treat the value as a
+# selftests-only output directory and fall back to in-tree or distro headers.
+# The parent bpf/Makefile resolves O=/KBUILD_OUTPUT to absolute paths before
+# invoking this sub-make so relative paths still anchor to the user's
+# invocation directory.
+KMOD_O := $(or $(O),$(KBUILD_OUTPUT))
+KMOD_O_VALID := $(if $(KMOD_O),$(if $(wildcard $(KMOD_O)/Module.symvers),$(KMOD_O)))
+KDIR ?= $(if $(KMOD_O_VALID),$(SRCTREE_KDIR), \
+ $(if $(wildcard $(SRCTREE_KDIR)/Module.symvers),$(SRCTREE_KDIR), \
+ /lib/modules/$(shell uname -r)/build))
ifeq ($(V),1)
Q =
@@ -14,8 +25,21 @@ $(foreach m,$(MODULES),$(eval obj-m += $(m:.ko=.o)))
CFLAGS_bpf_testmod.o = -I$(src)
+# When BPF_STRICT_BUILD != 0, a missing KDIR is fatal (the default).
+# When permissive, skip silently.
+PERMISSIVE := $(filter 0,$(BPF_STRICT_BUILD))
+
all:
- $(Q)$(MAKE) -C $(KDIR) M=$(TEST_KMOD_DIR) modules
+ifeq ($(PERMISSIVE),)
+ $(Q)$(MAKE) -C $(KDIR) $(if $(KMOD_O_VALID),O=$(KMOD_O_VALID) KBUILD_OUTPUT=$(KMOD_O_VALID),KBUILD_OUTPUT=) \
+ M=$(TEST_KMOD_DIR) modules
+else ifneq ("$(wildcard $(KDIR))", "")
+ $(Q)$(MAKE) -C $(KDIR) $(if $(KMOD_O_VALID),O=$(KMOD_O_VALID) KBUILD_OUTPUT=$(KMOD_O_VALID),KBUILD_OUTPUT=) \
+ M=$(TEST_KMOD_DIR) modules
+endif
clean:
- $(Q)$(MAKE) -C $(KDIR) M=$(TEST_KMOD_DIR) clean
+ifneq ("$(wildcard $(KDIR))", "")
+ $(Q)$(MAKE) -C $(KDIR) $(if $(KMOD_O_VALID),O=$(KMOD_O_VALID) KBUILD_OUTPUT=$(KMOD_O_VALID),KBUILD_OUTPUT=) \
+ M=$(TEST_KMOD_DIR) clean
+endif
--
2.54.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH bpf-next v10 02/11] selftests/bpf: Fix test_kmods KDIR to honor O= and distro kernels
2026-04-30 12:53 ` [PATCH bpf-next v10 02/11] selftests/bpf: Fix test_kmods KDIR to honor O= and distro kernels Ricardo B. Marlière
@ 2026-04-30 13:30 ` bot+bpf-ci
2026-04-30 14:09 ` Ricardo B. Marlière
0 siblings, 1 reply; 20+ messages in thread
From: bot+bpf-ci @ 2026-04-30 13:30 UTC (permalink / raw)
To: rbm, ast, daniel, andrii, martin.lau, eddyz87, memxor, song,
yonghong.song, jolsa, shuah, nathan, nick.desaulniers+lkml, morbo,
justinstitt
Cc: bpf, linux-kselftest, linux-kernel, llvm, alan.maguire, rbm, ast,
andrii, daniel, martin.lau, eddyz87, yonghong.song, clm,
ihor.solodrai
[-- Attachment #1: Type: text/plain, Size: 2740 bytes --]
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 6094fe99b5f6..cc6ee7a2df93 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
[ ... ]
> diff --git a/tools/testing/selftests/bpf/test_kmods/Makefile b/tools/testing/selftests/bpf/test_kmods/Makefile
> index 63c4d3f6a12f..031c7454ce65 100644
> --- a/tools/testing/selftests/bpf/test_kmods/Makefile
> +++ b/tools/testing/selftests/bpf/test_kmods/Makefile
> @@ -1,5 +1,16 @@
> TEST_KMOD_DIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
> -KDIR ?= $(abspath $(TEST_KMOD_DIR)/../../../../..)
> +SRCTREE_KDIR := $(abspath $(TEST_KMOD_DIR)/../../../../..)
> +# Honor O=/KBUILD_OUTPUT only if they point at a prepared kernel build
> +# directory (one containing Module.symvers); otherwise treat the value as a
> +# selftests-only output directory and fall back to in-tree or distro headers.
> +# The parent bpf/Makefile resolves O=/KBUILD_OUTPUT to absolute paths before
> +# invoking this sub-make so relative paths still anchor to the user's
> +# invocation directory.
> +KMOD_O := $(or $(O),$(KBUILD_OUTPUT))
> +KMOD_O_VALID := $(if $(KMOD_O),$(if $(wildcard $(KMOD_O)/Module.symvers),$(KMOD_O)))
> +KDIR ?= $(if $(KMOD_O_VALID),$(SRCTREE_KDIR), \
> + $(if $(wildcard $(SRCTREE_KDIR)/Module.symvers),$(SRCTREE_KDIR), \
> + /lib/modules/$(shell uname -r)/build))
Will falling back to the host kernel headers cause compilation errors
when building in-tree test modules like bpf_testmod?
Since bpf_testmod relies heavily on internal BPF structures,
experimental macros, and kfuncs that change frequently between kernel
releases, compiling it against /lib/modules/$(uname -r)/build on a
system where the running kernel does not exactly match the upstream
source tree will likely fail.
If the host headers are present, the permissive skip check further down
in the file will pass since the directory exists. Because the
compilation failure is not ignored by the parent bpf/Makefile, won't
this abort the entire BPF selftests build with confusing C compilation
errors instead of silently skipping the unconfigured kernel tree?
Should in-tree test modules avoid falling back to host distro headers to
prevent these version mismatches?
This was raised by Sashiko AI reviewer in v9:
https://lore.kernel.org/bpf/20260429194107.806B7C19425@smtp.kernel.org/
The issue was acknowledged in v9 but has not been addressed in v10.
[ ... ]
---
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/25167006036
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH bpf-next v10 02/11] selftests/bpf: Fix test_kmods KDIR to honor O= and distro kernels
2026-04-30 13:30 ` bot+bpf-ci
@ 2026-04-30 14:09 ` Ricardo B. Marlière
0 siblings, 0 replies; 20+ messages in thread
From: Ricardo B. Marlière @ 2026-04-30 14:09 UTC (permalink / raw)
To: bot+bpf-ci, rbm, ast, daniel, andrii, martin.lau, eddyz87, memxor,
song, yonghong.song, jolsa, shuah, nathan, nick.desaulniers+lkml,
morbo, justinstitt
Cc: bpf, linux-kselftest, linux-kernel, llvm, alan.maguire,
martin.lau, clm, ihor.solodrai
On Thu Apr 30, 2026 at 10:30 AM -03, bot+bpf-ci wrote:
>> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
>> index 6094fe99b5f6..cc6ee7a2df93 100644
>> --- a/tools/testing/selftests/bpf/Makefile
>> +++ b/tools/testing/selftests/bpf/Makefile
>
> [ ... ]
>
>> diff --git a/tools/testing/selftests/bpf/test_kmods/Makefile b/tools/testing/selftests/bpf/test_kmods/Makefile
>> index 63c4d3f6a12f..031c7454ce65 100644
>> --- a/tools/testing/selftests/bpf/test_kmods/Makefile
>> +++ b/tools/testing/selftests/bpf/test_kmods/Makefile
>> @@ -1,5 +1,16 @@
>> TEST_KMOD_DIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
>> -KDIR ?= $(abspath $(TEST_KMOD_DIR)/../../../../..)
>> +SRCTREE_KDIR := $(abspath $(TEST_KMOD_DIR)/../../../../..)
>> +# Honor O=/KBUILD_OUTPUT only if they point at a prepared kernel build
>> +# directory (one containing Module.symvers); otherwise treat the value as a
>> +# selftests-only output directory and fall back to in-tree or distro headers.
>> +# The parent bpf/Makefile resolves O=/KBUILD_OUTPUT to absolute paths before
>> +# invoking this sub-make so relative paths still anchor to the user's
>> +# invocation directory.
>> +KMOD_O := $(or $(O),$(KBUILD_OUTPUT))
>> +KMOD_O_VALID := $(if $(KMOD_O),$(if $(wildcard $(KMOD_O)/Module.symvers),$(KMOD_O)))
>> +KDIR ?= $(if $(KMOD_O_VALID),$(SRCTREE_KDIR), \
>> + $(if $(wildcard $(SRCTREE_KDIR)/Module.symvers),$(SRCTREE_KDIR), \
>> + /lib/modules/$(shell uname -r)/build))
>
> Will falling back to the host kernel headers cause compilation errors
> when building in-tree test modules like bpf_testmod?
>
> Since bpf_testmod relies heavily on internal BPF structures,
> experimental macros, and kfuncs that change frequently between kernel
> releases, compiling it against /lib/modules/$(uname -r)/build on a
> system where the running kernel does not exactly match the upstream
> source tree will likely fail.
This is only the fallback case (inspired by livepatch collection which uses
this KDIR as default), the targeted invocation for this series is
something like:
make -C /lib/modules/$(uname -r)/source/tools/testing/selftests \
O=/lib/modules/$(uname -r)/build SKIP_TARGETS= TARGETS=bpf \
BPF_STRICT_BUILD=0
The usual in-tree way of building vmlinux and then the selftests strictly
would keep the same current behavior.
>
> If the host headers are present, the permissive skip check further down
> in the file will pass since the directory exists. Because the
> compilation failure is not ignored by the parent bpf/Makefile, won't
> this abort the entire BPF selftests build with confusing C compilation
> errors instead of silently skipping the unconfigured kernel tree?
>
> Should in-tree test modules avoid falling back to host distro headers to
> prevent these version mismatches?
Without the fallback, a user running from a tree matched to their installed
kernel but without a prior in-tree build would lose bpf_testmod. Small
niche, but the workaround (O=/lib/modules/$(uname -r)/build) might not be
obvious. The fallback covers them at zero cost to everyone else, so I think
it should stay.
>
> This was raised by Sashiko AI reviewer in v9:
>
> https://lore.kernel.org/bpf/20260429194107.806B7C19425@smtp.kernel.org/
>
> The issue was acknowledged in v9 but has not been addressed in v10.
>
> [ ... ]
>
>
> ---
> 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/25167006036
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH bpf-next v10 03/11] selftests/bpf: Tolerate BPF and skeleton generation failures
2026-04-30 12:53 [PATCH bpf-next v10 00/11] selftests/bpf: Tolerate partial builds across kernel configs Ricardo B. Marlière
2026-04-30 12:53 ` [PATCH bpf-next v10 01/11] selftests/bpf: Add BPF_STRICT_BUILD toggle Ricardo B. Marlière
2026-04-30 12:53 ` [PATCH bpf-next v10 02/11] selftests/bpf: Fix test_kmods KDIR to honor O= and distro kernels Ricardo B. Marlière
@ 2026-04-30 12:53 ` Ricardo B. Marlière
2026-04-30 12:53 ` [PATCH bpf-next v10 04/11] selftests/bpf: Avoid rebuilds when running emit_tests Ricardo B. Marlière
` (7 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Ricardo B. Marlière @ 2026-04-30 12:53 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi,
Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt
Cc: bpf, linux-kselftest, linux-kernel, llvm, Alan Maguire,
Ricardo B. Marliere
Some BPF programs cannot be built on distro kernels because required BTF
types or features are missing. A single failure currently aborts the
selftests/bpf build.
Make BPF object and skeleton generation best effort in permissive mode:
emit SKIP-BPF or SKIP-SKEL to stderr, remove failed outputs so downstream
rules can detect absence, and continue with remaining tests. Apply the same
tolerance to linked skeletons (TRUNNER_BPF_SKELS_LINKED), which depend on
multiple .bpf.o files and abort the build when any dependency is missing.
Note that progress messages (GEN-SKEL, LINK-BPF) are also redirected to
stderr as a side effect of rewriting the recipes into single-shell
pipelines; the $(call msg,...) macro is a make-recipe construct that cannot
be used inside an &&-chained shell command sequence.
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
tools/testing/selftests/bpf/Makefile | 108 +++++++++++++++++++++++------------
1 file changed, 73 insertions(+), 35 deletions(-)
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index cc6ee7a2df93..b104c687dcf0 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -485,22 +485,26 @@ $(OUTPUT)/cgroup_getset_retval_hooks.o: cgroup_getset_retval_hooks.h
# $4 - binary name
define CLANG_BPF_BUILD_RULE
$(call msg,CLNG-BPF,$4,$2)
- $(Q)$(CLANG) $3 -O2 $(BPF_TARGET_ENDIAN) -c $1 -mcpu=v3 -o $2
+ $(Q)$(CLANG) $3 -O2 $(BPF_TARGET_ENDIAN) -c $1 -mcpu=v3 -o $2 $(if $(PERMISSIVE),|| \
+ ($(RM) $2; printf ' %-12s %s\n' 'SKIP-BPF' '$(notdir $2)' 1>&2))
endef
# Similar to CLANG_BPF_BUILD_RULE, but with disabled alu32
define CLANG_NOALU32_BPF_BUILD_RULE
$(call msg,CLNG-BPF,$4,$2)
- $(Q)$(CLANG) $3 -O2 $(BPF_TARGET_ENDIAN) -c $1 -mcpu=v2 -o $2
+ $(Q)$(CLANG) $3 -O2 $(BPF_TARGET_ENDIAN) -c $1 -mcpu=v2 -o $2 $(if $(PERMISSIVE),|| \
+ ($(RM) $2; printf ' %-12s %s\n' 'SKIP-BPF' '$(notdir $2)' 1>&2))
endef
# Similar to CLANG_BPF_BUILD_RULE, but with cpu-v4
define CLANG_CPUV4_BPF_BUILD_RULE
$(call msg,CLNG-BPF,$4,$2)
- $(Q)$(CLANG) $3 -O2 $(BPF_TARGET_ENDIAN) -c $1 -mcpu=v4 -o $2
+ $(Q)$(CLANG) $3 -O2 $(BPF_TARGET_ENDIAN) -c $1 -mcpu=v4 -o $2 $(if $(PERMISSIVE),|| \
+ ($(RM) $2; printf ' %-12s %s\n' 'SKIP-BPF' '$(notdir $2)' 1>&2))
endef
# Build BPF object using GCC
define GCC_BPF_BUILD_RULE
$(call msg,GCC-BPF,$4,$2)
- $(Q)$(BPF_GCC) $3 -DBPF_NO_PRESERVE_ACCESS_INDEX -Wno-attributes -O2 -c $1 -o $2
+ $(Q)$(BPF_GCC) $3 -DBPF_NO_PRESERVE_ACCESS_INDEX -Wno-attributes -O2 -c $1 -o $2 $(if $(PERMISSIVE),|| \
+ ($(RM) $2; printf ' %-12s %s\n' 'SKIP-BPF' '$(notdir $2)' 1>&2))
endef
SKEL_BLACKLIST := btf__% test_pinning_invalid.c test_sk_assign.c
@@ -607,47 +611,81 @@ $(TRUNNER_BPF_OBJS): $(TRUNNER_OUTPUT)/%.bpf.o: \
$$($$<-$2-CFLAGS),$(TRUNNER_BINARY))
$(TRUNNER_BPF_SKELS): %.skel.h: %.bpf.o $(BPFTOOL) | $(TRUNNER_OUTPUT)
- $$(call msg,GEN-SKEL,$(TRUNNER_BINARY),$$@)
- $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked1.o) $$<
- $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked2.o) $$(<:.o=.linked1.o)
- $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked3.o) $$(<:.o=.linked2.o)
- $(Q)diff $$(<:.o=.linked2.o) $$(<:.o=.linked3.o)
- $(Q)$$(BPFTOOL) gen skeleton $$(<:.o=.linked3.o) name $$(notdir $$(<:.bpf.o=)) > $$@
- $(Q)$$(BPFTOOL) gen subskeleton $$(<:.o=.linked3.o) name $$(notdir $$(<:.bpf.o=)) > $$(@:.skel.h=.subskel.h)
- $(Q)rm -f $$(<:.o=.linked1.o) $$(<:.o=.linked2.o) $$(<:.o=.linked3.o)
+ $(Q)$(if $(PERMISSIVE),if [ ! -f $$< ]; then \
+ $$(RM) $$@ $$(@:.skel.h=.subskel.h); \
+ printf ' %-12s %s\n' 'SKIP-SKEL' '$$(notdir $$@)' 1>&2; \
+ exit 0; \
+ fi;) \
+ printf ' %-12s %s\n' 'GEN-SKEL' '[$(TRUNNER_BINARY)] $$(notdir $$@)' 1>&2; \
+ $$(BPFTOOL) gen object $$(<:.o=.linked1.o) $$< && \
+ $$(BPFTOOL) gen object $$(<:.o=.linked2.o) $$(<:.o=.linked1.o) && \
+ $$(BPFTOOL) gen object $$(<:.o=.linked3.o) $$(<:.o=.linked2.o) && \
+ diff $$(<:.o=.linked2.o) $$(<:.o=.linked3.o) && \
+ $$(BPFTOOL) gen skeleton $$(<:.o=.linked3.o) name $$(notdir $$(<:.bpf.o=)) > $$@ && \
+ $$(BPFTOOL) gen subskeleton $$(<:.o=.linked3.o) name $$(notdir $$(<:.bpf.o=)) > $$(@:.skel.h=.subskel.h) $(if $(PERMISSIVE),|| { \
+ $$(RM) $$@ $$(@:.skel.h=.subskel.h); \
+ printf ' %-12s %s\n' 'SKIP-SKEL' '$$(notdir $$@)' 1>&2; \
+ }) && \
+ rm -f $$(<:.o=.linked1.o) $$(<:.o=.linked2.o) $$(<:.o=.linked3.o)
$(TRUNNER_BPF_LSKELS): %.lskel.h: %.bpf.o $(BPFTOOL) | $(TRUNNER_OUTPUT)
- $$(call msg,GEN-SKEL,$(TRUNNER_BINARY),$$@)
- $(Q)$$(BPFTOOL) gen object $$(<:.o=.llinked1.o) $$<
- $(Q)$$(BPFTOOL) gen object $$(<:.o=.llinked2.o) $$(<:.o=.llinked1.o)
- $(Q)$$(BPFTOOL) gen object $$(<:.o=.llinked3.o) $$(<:.o=.llinked2.o)
- $(Q)diff $$(<:.o=.llinked2.o) $$(<:.o=.llinked3.o)
- $(Q)$$(BPFTOOL) gen skeleton -L $$(<:.o=.llinked3.o) name $$(notdir $$(<:.bpf.o=_lskel)) > $$@
- $(Q)rm -f $$(<:.o=.llinked1.o) $$(<:.o=.llinked2.o) $$(<:.o=.llinked3.o)
+ $(Q)$(if $(PERMISSIVE),if [ ! -f $$< ]; then \
+ $$(RM) $$@; \
+ printf ' %-12s %s\n' 'SKIP-SKEL' '$$(notdir $$@)' 1>&2; \
+ exit 0; \
+ fi;) \
+ printf ' %-12s %s\n' 'GEN-SKEL' '[$(TRUNNER_BINARY)] $$(notdir $$@)' 1>&2; \
+ $$(BPFTOOL) gen object $$(<:.o=.llinked1.o) $$< && \
+ $$(BPFTOOL) gen object $$(<:.o=.llinked2.o) $$(<:.o=.llinked1.o) && \
+ $$(BPFTOOL) gen object $$(<:.o=.llinked3.o) $$(<:.o=.llinked2.o) && \
+ diff $$(<:.o=.llinked2.o) $$(<:.o=.llinked3.o) && \
+ $$(BPFTOOL) gen skeleton -L $$(<:.o=.llinked3.o) name $$(notdir $$(<:.bpf.o=_lskel)) > $$@ $(if $(PERMISSIVE),|| { \
+ $$(RM) $$@; \
+ printf ' %-12s %s\n' 'SKIP-SKEL' '$$(notdir $$@)' 1>&2; \
+ }) && \
+ rm -f $$(<:.o=.llinked1.o) $$(<:.o=.llinked2.o) $$(<:.o=.llinked3.o)
$(TRUNNER_BPF_LSKELS_SIGNED): %.lskel.h: %.bpf.o $(BPFTOOL) | $(TRUNNER_OUTPUT)
- $$(call msg,GEN-SKEL,$(TRUNNER_BINARY) (signed),$$@)
- $(Q)$$(BPFTOOL) gen object $$(<:.o=.llinked1.o) $$<
- $(Q)$$(BPFTOOL) gen object $$(<:.o=.llinked2.o) $$(<:.o=.llinked1.o)
- $(Q)$$(BPFTOOL) gen object $$(<:.o=.llinked3.o) $$(<:.o=.llinked2.o)
- $(Q)diff $$(<:.o=.llinked2.o) $$(<:.o=.llinked3.o)
- $(Q)$$(BPFTOOL) gen skeleton $(LSKEL_SIGN) $$(<:.o=.llinked3.o) name $$(notdir $$(<:.bpf.o=_lskel)) > $$@
- $(Q)rm -f $$(<:.o=.llinked1.o) $$(<:.o=.llinked2.o) $$(<:.o=.llinked3.o)
+ $(Q)$(if $(PERMISSIVE),if [ ! -f $$< ]; then \
+ $$(RM) $$@; \
+ printf ' %-12s %s\n' 'SKIP-SKEL' '$$(notdir $$@)' 1>&2; \
+ exit 0; \
+ fi;) \
+ printf ' %-12s %s\n' 'GEN-SKEL' '[$(TRUNNER_BINARY) (signed)] $$(notdir $$@)' 1>&2; \
+ $$(BPFTOOL) gen object $$(<:.o=.llinked1.o) $$< && \
+ $$(BPFTOOL) gen object $$(<:.o=.llinked2.o) $$(<:.o=.llinked1.o) && \
+ $$(BPFTOOL) gen object $$(<:.o=.llinked3.o) $$(<:.o=.llinked2.o) && \
+ diff $$(<:.o=.llinked2.o) $$(<:.o=.llinked3.o) && \
+ $$(BPFTOOL) gen skeleton $(LSKEL_SIGN) $$(<:.o=.llinked3.o) name $$(notdir $$(<:.bpf.o=_lskel)) > $$@ $(if $(PERMISSIVE),|| { \
+ $$(RM) $$@; \
+ printf ' %-12s %s\n' 'SKIP-SKEL' '$$(notdir $$@)' 1>&2; \
+ }) && \
+ rm -f $$(<:.o=.llinked1.o) $$(<:.o=.llinked2.o) $$(<:.o=.llinked3.o)
$(LINKED_BPF_OBJS): %: $(TRUNNER_OUTPUT)/%
# .SECONDEXPANSION here allows to correctly expand %-deps variables as prerequisites
.SECONDEXPANSION:
$(TRUNNER_BPF_SKELS_LINKED): $(TRUNNER_OUTPUT)/%: $$$$(%-deps) $(BPFTOOL) | $(TRUNNER_OUTPUT)
- $$(call msg,LINK-BPF,$(TRUNNER_BINARY),$$(@:.skel.h=.bpf.o))
- $(Q)$$(BPFTOOL) gen object $$(@:.skel.h=.linked1.o) $$(addprefix $(TRUNNER_OUTPUT)/,$$($$(@F)-deps))
- $(Q)$$(BPFTOOL) gen object $$(@:.skel.h=.linked2.o) $$(@:.skel.h=.linked1.o)
- $(Q)$$(BPFTOOL) gen object $$(@:.skel.h=.linked3.o) $$(@:.skel.h=.linked2.o)
- $(Q)diff $$(@:.skel.h=.linked2.o) $$(@:.skel.h=.linked3.o)
- $$(call msg,GEN-SKEL,$(TRUNNER_BINARY),$$@)
- $(Q)$$(BPFTOOL) gen skeleton $$(@:.skel.h=.linked3.o) name $$(notdir $$(@:.skel.h=)) > $$@
- $(Q)$$(BPFTOOL) gen subskeleton $$(@:.skel.h=.linked3.o) name $$(notdir $$(@:.skel.h=)) > $$(@:.skel.h=.subskel.h)
- $(Q)rm -f $$(@:.skel.h=.linked1.o) $$(@:.skel.h=.linked2.o) $$(@:.skel.h=.linked3.o)
+ $(Q)$(if $(PERMISSIVE),for f in $$(addprefix $(TRUNNER_OUTPUT)/,$$($$(@F)-deps)); do \
+ if [ ! -f $$$$f ]; then \
+ $$(RM) $$@ $$(@:.skel.h=.subskel.h); \
+ printf ' %-12s %s\n' 'SKIP-SKEL' '$$(notdir $$@)' 1>&2; \
+ exit 0; \
+ fi; \
+ done;) \
+ printf ' %-12s %s\n' 'LINK-BPF' '[$(TRUNNER_BINARY)] $$(notdir $$(@:.skel.h=.bpf.o))' 1>&2; \
+ $$(BPFTOOL) gen object $$(@:.skel.h=.linked1.o) $$(addprefix $(TRUNNER_OUTPUT)/,$$($$(@F)-deps)) && \
+ $$(BPFTOOL) gen object $$(@:.skel.h=.linked2.o) $$(@:.skel.h=.linked1.o) && \
+ $$(BPFTOOL) gen object $$(@:.skel.h=.linked3.o) $$(@:.skel.h=.linked2.o) && \
+ diff $$(@:.skel.h=.linked2.o) $$(@:.skel.h=.linked3.o) && \
+ printf ' %-12s %s\n' 'GEN-SKEL' '[$(TRUNNER_BINARY)] $$(notdir $$@)' 1>&2 && \
+ $$(BPFTOOL) gen skeleton $$(@:.skel.h=.linked3.o) name $$(notdir $$(@:.skel.h=)) > $$@ && \
+ $$(BPFTOOL) gen subskeleton $$(@:.skel.h=.linked3.o) name $$(notdir $$(@:.skel.h=)) > $$(@:.skel.h=.subskel.h) $(if $(PERMISSIVE),|| { \
+ $$(RM) $$@ $$(@:.skel.h=.subskel.h); \
+ printf ' %-12s %s\n' 'SKIP-SKEL' '$$(notdir $$@)' 1>&2; \
+ }) && \
+ rm -f $$(@:.skel.h=.linked1.o) $$(@:.skel.h=.linked2.o) $$(@:.skel.h=.linked3.o)
# When the compiler generates a %.d file, only skel basenames (not
# full paths) are specified as prerequisites for corresponding %.o
--
2.54.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH bpf-next v10 04/11] selftests/bpf: Avoid rebuilds when running emit_tests
2026-04-30 12:53 [PATCH bpf-next v10 00/11] selftests/bpf: Tolerate partial builds across kernel configs Ricardo B. Marlière
` (2 preceding siblings ...)
2026-04-30 12:53 ` [PATCH bpf-next v10 03/11] selftests/bpf: Tolerate BPF and skeleton generation failures Ricardo B. Marlière
@ 2026-04-30 12:53 ` Ricardo B. Marlière
2026-04-30 12:53 ` [PATCH bpf-next v10 05/11] selftests/bpf: Make skeleton headers order-only prerequisites of .test.d Ricardo B. Marlière
` (6 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Ricardo B. Marlière @ 2026-04-30 12:53 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi,
Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt
Cc: bpf, linux-kselftest, linux-kernel, llvm, Alan Maguire,
Ricardo B. Marliere
emit_tests is used while installing selftests to generate the kselftest
list. Pulling in .d files for this goal can trigger BPF rebuild rules and
mix build output into list generation.
Skip dependency file inclusion for emit_tests, like clean goals, so list
generation stays side-effect free. Also add emit_tests to
NON_CHECK_FEAT_TARGETS so that feature detection is skipped; without this,
Makefile.feature's $(info) output leaks into stdout and corrupts the test
list captured by the top-level selftests Makefile.
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
tools/testing/selftests/bpf/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index b104c687dcf0..9a4d8bea0c18 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -170,7 +170,7 @@ endef
include ../lib.mk
-NON_CHECK_FEAT_TARGETS := clean docs-clean
+NON_CHECK_FEAT_TARGETS := clean docs-clean emit_tests
CHECK_FEAT := $(filter-out $(NON_CHECK_FEAT_TARGETS),$(or $(MAKECMDGOALS), "none"))
ifneq ($(CHECK_FEAT),)
FEATURE_USER := .selftests
@@ -732,7 +732,7 @@ $(TRUNNER_TEST_OBJS:.o=.d): $(TRUNNER_OUTPUT)/%.test.d: \
$(TRUNNER_BPF_SKELS_LINKED) \
$$(BPFOBJ) | $(TRUNNER_OUTPUT)
-ifeq ($(filter clean docs-clean,$(MAKECMDGOALS)),)
+ifeq ($(filter clean docs-clean emit_tests,$(MAKECMDGOALS)),)
include $(wildcard $(TRUNNER_TEST_OBJS:.o=.d))
endif
--
2.54.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH bpf-next v10 05/11] selftests/bpf: Make skeleton headers order-only prerequisites of .test.d
2026-04-30 12:53 [PATCH bpf-next v10 00/11] selftests/bpf: Tolerate partial builds across kernel configs Ricardo B. Marlière
` (3 preceding siblings ...)
2026-04-30 12:53 ` [PATCH bpf-next v10 04/11] selftests/bpf: Avoid rebuilds when running emit_tests Ricardo B. Marlière
@ 2026-04-30 12:53 ` Ricardo B. Marlière
2026-04-30 13:30 ` bot+bpf-ci
2026-04-30 12:53 ` [PATCH bpf-next v10 06/11] selftests/bpf: Tolerate test file compilation failures Ricardo B. Marlière
` (5 subsequent siblings)
10 siblings, 1 reply; 20+ messages in thread
From: Ricardo B. Marlière @ 2026-04-30 12:53 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi,
Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt
Cc: bpf, linux-kselftest, linux-kernel, llvm, Alan Maguire,
Ricardo B. Marliere
The .test.d dependency files are generated by the C preprocessor and list
the headers each test file actually #includes. Skeleton headers appear in
those generated lists, so the .test.o -> .skel.h dependency is already
tracked by the .d file content.
Making skeletons order-only prerequisites of .test.d means that a missing
or skipped skeleton does not prevent .test.d generation, and regenerating a
skeleton does not force .test.d to be recreated. This avoids unnecessary
recompilation and, more importantly, avoids build errors when a skeleton
was intentionally skipped due to a BPF compilation failure.
$$(BPFOBJ) is intentionally kept as a normal prerequisite: a libbpf
rebuild legitimately invalidates .test.d, since libbpf header changes
can affect the headers .test.o sees. Only the skeleton headers are
moved to order-only.
Note that adding a new BPF skeleton via a modified existing local header
still works correctly: GNU make builds order-only prerequisites that do
not exist (the order-only qualifier only suppresses timestamp-driven
rebuilds, not existence-driven builds), so a brand-new .skel.h listed in
TRUNNER_BPF_SKELS is generated even when .test.d is otherwise up to date.
The modified local header invalidates .test.o through the previously
included .d content, forcing a recompile that regenerates .test.d with
the new .skel.h dependency captured by gcc -MMD.
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
tools/testing/selftests/bpf/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 9a4d8bea0c18..608e6dff0392 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -726,11 +726,11 @@ $(TRUNNER_TEST_OBJS): $(TRUNNER_OUTPUT)/%.test.o: \
$(TRUNNER_TEST_OBJS:.o=.d): $(TRUNNER_OUTPUT)/%.test.d: \
$(TRUNNER_TESTS_DIR)/%.c \
$(TRUNNER_EXTRA_HDRS) \
+ $$(BPFOBJ) | $(TRUNNER_OUTPUT) \
$(TRUNNER_BPF_SKELS) \
$(TRUNNER_BPF_LSKELS) \
$(TRUNNER_BPF_LSKELS_SIGNED) \
- $(TRUNNER_BPF_SKELS_LINKED) \
- $$(BPFOBJ) | $(TRUNNER_OUTPUT)
+ $(TRUNNER_BPF_SKELS_LINKED)
ifeq ($(filter clean docs-clean emit_tests,$(MAKECMDGOALS)),)
include $(wildcard $(TRUNNER_TEST_OBJS:.o=.d))
--
2.54.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH bpf-next v10 05/11] selftests/bpf: Make skeleton headers order-only prerequisites of .test.d
2026-04-30 12:53 ` [PATCH bpf-next v10 05/11] selftests/bpf: Make skeleton headers order-only prerequisites of .test.d Ricardo B. Marlière
@ 2026-04-30 13:30 ` bot+bpf-ci
2026-04-30 15:04 ` Ricardo B. Marlière
0 siblings, 1 reply; 20+ messages in thread
From: bot+bpf-ci @ 2026-04-30 13:30 UTC (permalink / raw)
To: rbm, ast, daniel, andrii, martin.lau, eddyz87, memxor, song,
yonghong.song, jolsa, shuah, nathan, nick.desaulniers+lkml, morbo,
justinstitt
Cc: bpf, linux-kselftest, linux-kernel, llvm, alan.maguire, rbm, ast,
andrii, daniel, martin.lau, eddyz87, yonghong.song, clm,
ihor.solodrai
[-- Attachment #1: Type: text/plain, Size: 2162 bytes --]
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 9a4d8bea0c18..608e6dff0392 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -726,11 +726,11 @@ $(TRUNNER_TEST_OBJS): $(TRUNNER_OUTPUT)/%.test.o: \
> $(TRUNNER_TEST_OBJS:.o=.d): $(TRUNNER_OUTPUT)/%.test.d: \
> $(TRUNNER_TESTS_DIR)/%.c \
> $(TRUNNER_EXTRA_HDRS) \
> + $$(BPFOBJ) | $(TRUNNER_OUTPUT) \
> $(TRUNNER_BPF_SKELS) \
> $(TRUNNER_BPF_LSKELS) \
> $(TRUNNER_BPF_LSKELS_SIGNED) \
> - $(TRUNNER_BPF_SKELS_LINKED) \
> - $$(BPFOBJ) | $(TRUNNER_OUTPUT)
> + $(TRUNNER_BPF_SKELS_LINKED)
sashiko-bot raised concerns in v9 about the assumption regarding GNU
Make's behavior with order-only prerequisites. The commit message claims
that "GNU make builds order-only prerequisites that do not exist," but is
this correct in the scenario described?
If .test.d already exists and its regular prerequisites are not newer, Make
ignores order-only prerequisites completely. Since the generated .d files
only declare dependencies for .test.o and not for .test.d itself, modifying
a local header to include a new skeleton doesn't mark .test.d as out-of-date.
Could this introduce a race condition or build failures for newly added BPF
skeletons? The new skeleton might not be generated before compilation, causing
a missing file error when building .test.o.
Additionally, if the new skeleton is concurrently being generated for another
test that correctly tracks it, Make won't enforce dependency ordering for the
modified test. This could result in gcc reading a partially written .skel.h
file.
This concern from v9 was not addressed in v10.
Reference: https://lore.kernel.org/bpf/20260429202343.CB842C2BCFA@smtp.kernel.org/
Reviewer: sashiko-bot@kernel.org
Date: Wed, 29 Apr 2026 20:23:42 +0000
---
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/25167006036
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH bpf-next v10 05/11] selftests/bpf: Make skeleton headers order-only prerequisites of .test.d
2026-04-30 13:30 ` bot+bpf-ci
@ 2026-04-30 15:04 ` Ricardo B. Marlière
0 siblings, 0 replies; 20+ messages in thread
From: Ricardo B. Marlière @ 2026-04-30 15:04 UTC (permalink / raw)
To: bot+bpf-ci, rbm, ast, daniel, andrii, martin.lau, eddyz87, memxor,
song, yonghong.song, jolsa, shuah, nathan, nick.desaulniers+lkml,
morbo, justinstitt
Cc: bpf, linux-kselftest, linux-kernel, llvm, alan.maguire,
martin.lau, clm, ihor.solodrai
On Thu Apr 30, 2026 at 10:30 AM -03, bot+bpf-ci wrote:
>> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
>> index 9a4d8bea0c18..608e6dff0392 100644
>> --- a/tools/testing/selftests/bpf/Makefile
>> +++ b/tools/testing/selftests/bpf/Makefile
>> @@ -726,11 +726,11 @@ $(TRUNNER_TEST_OBJS): $(TRUNNER_OUTPUT)/%.test.o: \
>> $(TRUNNER_TEST_OBJS:.o=.d): $(TRUNNER_OUTPUT)/%.test.d: \
>> $(TRUNNER_TESTS_DIR)/%.c \
>> $(TRUNNER_EXTRA_HDRS) \
>> + $$(BPFOBJ) | $(TRUNNER_OUTPUT) \
>> $(TRUNNER_BPF_SKELS) \
>> $(TRUNNER_BPF_LSKELS) \
>> $(TRUNNER_BPF_LSKELS_SIGNED) \
>> - $(TRUNNER_BPF_SKELS_LINKED) \
>> - $$(BPFOBJ) | $(TRUNNER_OUTPUT)
>> + $(TRUNNER_BPF_SKELS_LINKED)
>
> sashiko-bot raised concerns in v9 about the assumption regarding GNU
> Make's behavior with order-only prerequisites. The commit message claims
> that "GNU make builds order-only prerequisites that do not exist," but is
> this correct in the scenario described?
>
> If .test.d already exists and its regular prerequisites are not newer, Make
> ignores order-only prerequisites completely. Since the generated .d files
> only declare dependencies for .test.o and not for .test.d itself, modifying
> a local header to include a new skeleton doesn't mark .test.d as out-of-date.
Alright so this seems to be false. A small counter example below
(disclaimer: also LLM output).
/tmp/oo.mk:
# Reproduces the bot's exact scenario from tools/testing/selftests/bpf:
# .test.o : .c | .test.d (existing rule)
# .test.d : .c | <skel headers> (this patch's change)
# Setup mimics a previous build: .test.o, .test.d, the .c file, and a
# local header all exist on disk; the .d already records that .test.o
# depends on the local header (this is what gcc -MMD captured during the
# previous compile). The local header is then touched -- as if a
# developer had just added a new #include to it -- so .test.o becomes
# timestamp-out-of-date. Crucially, .test.d's own normal prereqs (just
# .c) have NOT been touched, so .test.d is itself "up-to-date": this is
# the bot's exact precondition. A new .skel.h is listed in the
# order-only chain but does not exist on disk yet. The bot claims make
# will silently skip building it. Below shows make builds it anyway.
$(shell rm -rf /tmp/oo; mkdir -p /tmp/oo; \
touch /tmp/oo/foo.c /tmp/oo/local.h; \
printf '%s\n' '/tmp/oo/foo.test.o: /tmp/oo/foo.c /tmp/oo/local.h' \
> /tmp/oo/foo.test.d; \
touch /tmp/oo/foo.test.o; \
sleep 0.1; \
touch /tmp/oo/local.h)
-include /tmp/oo/foo.test.d
/tmp/oo/foo.test.o: /tmp/oo/foo.c | /tmp/oo/foo.test.d
@cat /tmp/oo/new.skel.h >/dev/null && touch $@
@echo " TEST-OBJ $@"
/tmp/oo/foo.test.d: /tmp/oo/foo.c | /tmp/oo/new.skel.h
/tmp/oo/new.skel.h:
@echo "/* generated */" > $@
@echo " GEN-SKEL $@"
Then run it:
$ make -f /tmp/oo.mk /tmp/oo/foo.test.o
GEN-SKEL /tmp/oo/new.skel.h
TEST-OBJ /tmp/oo/foo.test.o
If the order-only chain were skipped at the up-to-date /tmp/oo/foo.test.d,
then /tmp/oo/new.skel.h would never be created, the recipe's cat would fail
with "No such file or directory", and make would abort with Error 1 instead
of relinking /tmp/oo/foo.test.o -- the same failure mode hypothesised for
the real .test.o case. That does not happen.
>
> Could this introduce a race condition or build failures for newly added BPF
> skeletons? The new skeleton might not be generated before compilation, causing
> a missing file error when building .test.o.
>
> Additionally, if the new skeleton is concurrently being generated for another
> test that correctly tracks it, Make won't enforce dependency ordering for the
> modified test. This could result in gcc reading a partially written .skel.h
> file.
With this patch every .test.d entry treats skel headers as order-only, so
there is no "test that does correctly track it" to race against -- the
premise does not hold.
>
> This concern from v9 was not addressed in v10.
>
> Reference: https://lore.kernel.org/bpf/20260429202343.CB842C2BCFA@smtp.kernel.org/
> Reviewer: sashiko-bot@kernel.org
> Date: Wed, 29 Apr 2026 20:23:42 +0000
>
>
> ---
> 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/25167006036
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH bpf-next v10 06/11] selftests/bpf: Tolerate test file compilation failures
2026-04-30 12:53 [PATCH bpf-next v10 00/11] selftests/bpf: Tolerate partial builds across kernel configs Ricardo B. Marlière
` (4 preceding siblings ...)
2026-04-30 12:53 ` [PATCH bpf-next v10 05/11] selftests/bpf: Make skeleton headers order-only prerequisites of .test.d Ricardo B. Marlière
@ 2026-04-30 12:53 ` Ricardo B. Marlière
2026-04-30 13:30 ` bot+bpf-ci
2026-04-30 12:53 ` [PATCH bpf-next v10 07/11] selftests/bpf: Skip tests whose objects were not built Ricardo B. Marlière
` (4 subsequent siblings)
10 siblings, 1 reply; 20+ messages in thread
From: Ricardo B. Marlière @ 2026-04-30 12:53 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi,
Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt
Cc: bpf, linux-kselftest, linux-kernel, llvm, Alan Maguire,
Ricardo B. Marliere
Individual test files may fail to compile when headers or kernel features
required by that test are absent. Currently this aborts the entire build.
Make the per-test compilation non-fatal: remove the output object on
failure and print a SKIP-TEST marker to stderr. Guard the BTFIDS
post-processing step so it is skipped when the object file is absent. The
linker step will later ignore absent objects, allowing the remaining tests
to build and run.
Group cd and CC in a sub-shell so a cd failure cannot leak into the
error-handling branch and operate in the original working directory; use
$@ (absolute path) for $(RM) so it cannot match an unrelated file there.
Replace the $(call msg,...) in the BTFIDS block with a plain printf
(the msg macro expands to @printf, which is a make-recipe construct and
is invalid inside a shell if-then-fi body) and gate the printf on $(V)
so verbose mode does not double-print the line that the recipe shell
already echoes.
Restrict tolerance to test_progs and its flavors via an inlined
$(if $(filter test_progs%,$1),$(if $(PERMISSIVE),...)) check: runners
with strong cross-object references (e.g. test_maps) would link-fail
with a partial object set, so they keep strict semantics even when
BPF_STRICT_BUILD=0. The check is inlined rather than stored in a helper
variable so $1 is substituted at $(call) time and the per-runner result
is baked into each recipe.
Note on bisectability: this change is gated entirely behind PERMISSIVE
for test_progs%, so default builds (BPF_STRICT_BUILD!=0) compile and
run identically at every commit in the series. Bisecting in PERMISSIVE
mode at this commit still requires the next two patches ("selftests/bpf:
Skip tests whose objects were not built" and "selftests/bpf: Allow
test_progs to link with a partial object set") to avoid the linker
rejecting missing objects and the runtime aborting on NULL function
pointers.
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
tools/testing/selftests/bpf/Makefile | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 608e6dff0392..9becc077eb23 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -588,6 +588,12 @@ endef
# $2 - test runner extra "flavor" (e.g., no_alu32, cpuv4, bpf_gcc, etc)
define DEFINE_TEST_RUNNER_RULES
+# Permissive build behaviour (skip-on-failure compile, partial-link) only
+# applies to test_progs and its flavors; runners that use strong cross-object
+# references (e.g. test_maps) keep strict semantics even when permissive.
+# The check is inlined per-runner so $1 is substituted at $(call) time and
+# the result is baked into each rule's recipe.
+
ifeq ($($(TRUNNER_OUTPUT)-dir),)
$(TRUNNER_OUTPUT)-dir := y
$(TRUNNER_OUTPUT):
@@ -717,11 +723,14 @@ $(TRUNNER_TEST_OBJS): $(TRUNNER_OUTPUT)/%.test.o: \
$(TRUNNER_TESTS_DIR)/%.c \
| $(TRUNNER_OUTPUT)/%.test.d
$$(call msg,TEST-OBJ,$(TRUNNER_BINARY),$$@)
- $(Q)cd $$(@D) && $$(CC) -I. $$(CFLAGS) -MMD -MT $$@ -c $(CURDIR)/$$< $$(LDLIBS) -o $$(@F)
+ $(Q)(cd $$(@D) && $$(CC) -I. $$(CFLAGS) -MMD -MT $$@ -c $(CURDIR)/$$< $$(LDLIBS) -o $$(@F)) $(if $(filter test_progs%,$1),$(if $(PERMISSIVE),|| \
+ ($(RM) $$@; printf ' %-12s %s\n' 'SKIP-TEST' '$$(notdir $$@)' 1>&2)))
$$(if $$(TEST_NEEDS_BTFIDS), \
- $$(call msg,BTFIDS,$(TRUNNER_BINARY),$$@) \
+ $(Q)if [ -f $$@ ]; then \
+ $(if $(V),true,printf ' %-8s%s %s\n' "BTFIDS" " [$(TRUNNER_BINARY)]" "$$(notdir $$@)"); \
$(RESOLVE_BTFIDS) --btf $(TRUNNER_OUTPUT)/btf_data.bpf.o $$@; \
- $(RESOLVE_BTFIDS) --patch_btfids $$@.BTF_ids $$@)
+ $(RESOLVE_BTFIDS) --patch_btfids $$@.BTF_ids $$@; \
+ fi)
$(TRUNNER_TEST_OBJS:.o=.d): $(TRUNNER_OUTPUT)/%.test.d: \
$(TRUNNER_TESTS_DIR)/%.c \
--
2.54.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH bpf-next v10 06/11] selftests/bpf: Tolerate test file compilation failures
2026-04-30 12:53 ` [PATCH bpf-next v10 06/11] selftests/bpf: Tolerate test file compilation failures Ricardo B. Marlière
@ 2026-04-30 13:30 ` bot+bpf-ci
0 siblings, 0 replies; 20+ messages in thread
From: bot+bpf-ci @ 2026-04-30 13:30 UTC (permalink / raw)
To: rbm, ast, daniel, andrii, martin.lau, eddyz87, memxor, song,
yonghong.song, jolsa, shuah, nathan, nick.desaulniers+lkml, morbo,
justinstitt
Cc: bpf, linux-kselftest, linux-kernel, llvm, alan.maguire, rbm, ast,
andrii, daniel, martin.lau, eddyz87, yonghong.song, clm,
ihor.solodrai
[-- Attachment #1: Type: text/plain, Size: 2103 bytes --]
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 608e6dff0392..9becc077eb23 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
[ ... ]
> @@ -717,11 +723,14 @@ $(TRUNNER_TEST_OBJS): $(TRUNNER_OUTPUT)/%.test.o: \
> $(TRUNNER_TESTS_DIR)/%.c \
> | $(TRUNNER_OUTPUT)/%.test.d
> $$(call msg,TEST-OBJ,$(TRUNNER_BINARY),$$@)
> - $(Q)cd $$(@D) && $$(CC) -I. $$(CFLAGS) -MMD -MT $$@ -c $(CURDIR)/$$< $$(LDLIBS) -o $$(@F)
> + $(Q)(cd $$(@D) && $$(CC) -I. $$(CFLAGS) -MMD -MT $$@ -c $(CURDIR)/$$< $$(LDLIBS) -o $$(@F)) $(if $(filter test_progs%,$1),$(if $(PERMISSIVE),|| \
> + ($(RM) $$@; printf ' %-12s %s\n' 'SKIP-TEST' '$$(notdir $$@)' 1>&2)))
> $$(if $$(TEST_NEEDS_BTFIDS), \
> - $$(call msg,BTFIDS,$(TRUNNER_BINARY),$$@) \
> + $(Q)if [ -f $$@ ]; then \
> + $(if $(V),true,printf ' %-8s%s %s\n' "BTFIDS" " [$(TRUNNER_BINARY)]" "$$(notdir $$@)"); \
> $(RESOLVE_BTFIDS) --btf $(TRUNNER_OUTPUT)/btf_data.bpf.o $$@; \
> - $(RESOLVE_BTFIDS) --patch_btfids $$@.BTF_ids $$@)
> + $(RESOLVE_BTFIDS) --patch_btfids $$@.BTF_ids $$@; \
> + fi)
Does this condition correctly handle V=0 or V=2?
In GNU Make, the $(if) function evaluates to true if the condition expands
to any non-empty string. If a user sets make V=0, $(V) expands to the
string "0", which Make considers true.
Consequently, $(if $(V),true,printf ...) will execute true;, silencing the
BTFIDS output entirely. The standard msg macro used for other compilation
steps explicitly checks ifeq ($(V),1).
This results in inconsistent behavior where V=0 correctly prints brief
messages like TEST-OBJ but silently skips BTFIDS.
Could this explicitly check for "1", such as using
$(if $(filter 1,$(V)),true,printf ...) to accurately match the behavior of
the msg macro?
---
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/25167006036
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH bpf-next v10 07/11] selftests/bpf: Skip tests whose objects were not built
2026-04-30 12:53 [PATCH bpf-next v10 00/11] selftests/bpf: Tolerate partial builds across kernel configs Ricardo B. Marlière
` (5 preceding siblings ...)
2026-04-30 12:53 ` [PATCH bpf-next v10 06/11] selftests/bpf: Tolerate test file compilation failures Ricardo B. Marlière
@ 2026-04-30 12:53 ` Ricardo B. Marlière
2026-04-30 13:30 ` bot+bpf-ci
2026-04-30 12:53 ` [PATCH bpf-next v10 08/11] selftests/bpf: Allow test_progs to link with a partial object set Ricardo B. Marlière
` (3 subsequent siblings)
10 siblings, 1 reply; 20+ messages in thread
From: Ricardo B. Marlière @ 2026-04-30 12:53 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi,
Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt
Cc: bpf, linux-kselftest, linux-kernel, llvm, Alan Maguire,
Ricardo B. Marliere
When both run_test and run_serial_test are NULL (because the corresponding
.test.o was not compiled), mark the test as not built instead of fatally
aborting.
Report these tests as "SKIP (not built)" in per-test output and include
them in the skip count so they remain visible in CI results and JSON
output. The summary line shows the not-built count when nonzero:
Summary: 50/55 PASSED, 5 SKIPPED (3 not built), 0 FAILED
Tests filtered out by -t/-n remain invisible as before; only genuinely
unbuilt tests are surfaced.
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
tools/testing/selftests/bpf/test_progs.c | 53 +++++++++++++++++++++++++++-----
tools/testing/selftests/bpf/test_progs.h | 1 +
2 files changed, 46 insertions(+), 8 deletions(-)
diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
index cc14b13e23fe..7ba82974ee78 100644
--- a/tools/testing/selftests/bpf/test_progs.c
+++ b/tools/testing/selftests/bpf/test_progs.c
@@ -165,6 +165,8 @@ struct prog_test_def {
void (*run_test)(void);
void (*run_serial_test)(void);
bool should_run;
+ bool not_built;
+ bool selected;
bool need_cgroup_cleanup;
bool should_tmon;
};
@@ -372,6 +374,8 @@ static void print_test_result(const struct prog_test_def *test, const struct tes
fprintf(env.stdout_saved, "#%-*d %s:", TEST_NUM_WIDTH, test->test_num, test->test_name);
if (test_state->error_cnt)
fprintf(env.stdout_saved, "FAIL");
+ else if (test->not_built)
+ fprintf(env.stdout_saved, "SKIP (not built)");
else if (!skipped_cnt)
fprintf(env.stdout_saved, "OK");
else if (skipped_cnt == subtests_cnt || !subtests_cnt)
@@ -1641,6 +1645,7 @@ static void calculate_summary_and_print_errors(struct test_env *env)
json_writer_t *w = NULL;
for (i = 0; i < prog_test_cnt; i++) {
+ struct prog_test_def *test = &prog_test_defs[i];
struct test_state *state = &test_states[i];
if (!state->tested)
@@ -1651,7 +1656,7 @@ static void calculate_summary_and_print_errors(struct test_env *env)
if (state->error_cnt)
fail_cnt++;
- else
+ else if (!test->not_built)
succ_cnt++;
}
@@ -1700,8 +1705,13 @@ static void calculate_summary_and_print_errors(struct test_env *env)
if (env->json)
fclose(env->json);
- printf("Summary: %d/%d PASSED, %d SKIPPED, %d FAILED\n",
- succ_cnt, sub_succ_cnt, skip_cnt, fail_cnt);
+ if (env->not_built_cnt)
+ printf("Summary: %d/%d PASSED, %d SKIPPED (%d not built), %d FAILED\n",
+ succ_cnt, sub_succ_cnt, skip_cnt, env->not_built_cnt,
+ fail_cnt);
+ else
+ printf("Summary: %d/%d PASSED, %d SKIPPED, %d FAILED\n",
+ succ_cnt, sub_succ_cnt, skip_cnt, fail_cnt);
env->succ_cnt = succ_cnt;
env->sub_succ_cnt = sub_succ_cnt;
@@ -1772,6 +1782,19 @@ static void server_main(void)
run_one_test(i);
}
+ /* mark not-built tests as skipped */
+ for (int i = 0; i < prog_test_cnt; i++) {
+ struct prog_test_def *test = &prog_test_defs[i];
+ struct test_state *state = &test_states[i];
+
+ if (test->not_built && test->selected) {
+ state->tested = true;
+ state->skip_cnt = 1;
+ env.not_built_cnt++;
+ print_test_result(test, state);
+ }
+ }
+
/* generate summary */
fflush(stderr);
fflush(stdout);
@@ -2046,15 +2069,20 @@ int main(int argc, char **argv)
struct prog_test_def *test = &prog_test_defs[i];
test->test_num = i + 1;
- test->should_run = should_run(&env.test_selector,
- test->test_num, test->test_name);
+ test->selected = should_run(&env.test_selector,
+ test->test_num, test->test_name);
+ test->should_run = test->selected;
- if ((test->run_test == NULL && test->run_serial_test == NULL) ||
- (test->run_test != NULL && test->run_serial_test != NULL)) {
+ if (test->run_test && test->run_serial_test) {
fprintf(stderr, "Test %d:%s must have either test_%s() or serial_test_%sl() defined.\n",
test->test_num, test->test_name, test->test_name, test->test_name);
exit(EXIT_ERR_SETUP_INFRA);
}
+ if (!test->run_test && !test->run_serial_test) {
+ test->not_built = true;
+ test->should_run = false;
+ continue;
+ }
if (test->should_run)
test->should_tmon = should_tmon(&env.tmon_selector, test->test_name);
}
@@ -2106,9 +2134,18 @@ int main(int argc, char **argv)
for (i = 0; i < prog_test_cnt; i++) {
struct prog_test_def *test = &prog_test_defs[i];
+ struct test_state *state = &test_states[i];
- if (!test->should_run)
+ if (!test->should_run) {
+ if (test->not_built && test->selected &&
+ !env.get_test_cnt && !env.list_test_names) {
+ state->tested = true;
+ state->skip_cnt = 1;
+ env.not_built_cnt++;
+ print_test_result(test, state);
+ }
continue;
+ }
if (env.get_test_cnt) {
env.succ_cnt++;
diff --git a/tools/testing/selftests/bpf/test_progs.h b/tools/testing/selftests/bpf/test_progs.h
index 37955a8ad385..2cf950afcd85 100644
--- a/tools/testing/selftests/bpf/test_progs.h
+++ b/tools/testing/selftests/bpf/test_progs.h
@@ -125,6 +125,7 @@ struct test_env {
int sub_succ_cnt; /* successful sub-tests */
int fail_cnt; /* total failed tests + sub-tests */
int skip_cnt; /* skipped tests */
+ int not_built_cnt; /* tests not built */
int saved_netns_fd;
int workers; /* number of worker process */
--
2.54.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH bpf-next v10 07/11] selftests/bpf: Skip tests whose objects were not built
2026-04-30 12:53 ` [PATCH bpf-next v10 07/11] selftests/bpf: Skip tests whose objects were not built Ricardo B. Marlière
@ 2026-04-30 13:30 ` bot+bpf-ci
2026-04-30 15:52 ` Ricardo B. Marlière
0 siblings, 1 reply; 20+ messages in thread
From: bot+bpf-ci @ 2026-04-30 13:30 UTC (permalink / raw)
To: rbm, ast, daniel, andrii, martin.lau, eddyz87, memxor, song,
yonghong.song, jolsa, shuah, nathan, nick.desaulniers+lkml, morbo,
justinstitt
Cc: bpf, linux-kselftest, linux-kernel, llvm, alan.maguire, rbm, ast,
andrii, daniel, martin.lau, eddyz87, yonghong.song, clm,
ihor.solodrai
[-- Attachment #1: Type: text/plain, Size: 2857 bytes --]
> diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
> index cc14b13e23fe..7ba82974ee78 100644
> --- a/tools/testing/selftests/bpf/test_progs.c
> +++ b/tools/testing/selftests/bpf/test_progs.c
[ ... ]
> @@ -2046,15 +2069,20 @@ int main(int argc, char **argv)
> struct prog_test_def *test = &prog_test_defs[i];
>
> test->test_num = i + 1;
> - test->should_run = should_run(&env.test_selector,
> - test->test_num, test->test_name);
> + test->selected = should_run(&env.test_selector,
> + test->test_num, test->test_name);
> + test->should_run = test->selected;
>
> - if ((test->run_test == NULL && test->run_serial_test == NULL) ||
> - (test->run_test != NULL && test->run_serial_test != NULL)) {
> + if (test->run_test && test->run_serial_test) {
> fprintf(stderr, "Test %d:%s must have either test_%s() or serial_test_%sl() defined.\n",
> test->test_num, test->test_name, test->test_name, test->test_name);
> exit(EXIT_ERR_SETUP_INFRA);
> }
> + if (!test->run_test && !test->run_serial_test) {
> + test->not_built = true;
> + test->should_run = false;
> + continue;
> + }
> if (test->should_run)
> test->should_tmon = should_tmon(&env.tmon_selector, test->test_name);
> }
> @@ -2106,9 +2134,18 @@ int main(int argc, char **argv)
>
> for (i = 0; i < prog_test_cnt; i++) {
> struct prog_test_def *test = &prog_test_defs[i];
> + struct test_state *state = &test_states[i];
>
> - if (!test->should_run)
> + if (!test->should_run) {
> + if (test->not_built && test->selected &&
> + !env.get_test_cnt && !env.list_test_names) {
> + state->tested = true;
> + state->skip_cnt = 1;
> + env.not_built_cnt++;
> + print_test_result(test, state);
> + }
> continue;
> + }
When test->should_run is false (which it is for unbuilt tests due to the
code above setting test->should_run = false), the continue statement skips
the env.get_test_cnt and env.list_test_names blocks that follow.
Won't this completely omit unbuilt tests from the output of --list (-l) and
--count modes? The code only prints unbuilt tests when !env.get_test_cnt &&
!env.list_test_names is true.
If CI systems use test_progs -l to discover and distribute tests across
parallel jobs, they won't be aware of unbuilt tests. Could this undermine
the stated goal of keeping unbuilt tests visible in CI results?
Reference: sashiko-bot raised this concern in v10 discussion at
https://lore.kernel.org/bpf/20260430131344.B40DDC2BCB3@smtp.kernel.org/
>
> if (env.get_test_cnt) {
> env.succ_cnt++;
[ ... ]
---
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/25167006036
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH bpf-next v10 07/11] selftests/bpf: Skip tests whose objects were not built
2026-04-30 13:30 ` bot+bpf-ci
@ 2026-04-30 15:52 ` Ricardo B. Marlière
0 siblings, 0 replies; 20+ messages in thread
From: Ricardo B. Marlière @ 2026-04-30 15:52 UTC (permalink / raw)
To: bot+bpf-ci, rbm, ast, daniel, andrii, martin.lau, eddyz87, memxor,
song, yonghong.song, jolsa, shuah, nathan, nick.desaulniers+lkml,
morbo, justinstitt
Cc: bpf, linux-kselftest, linux-kernel, llvm, alan.maguire,
martin.lau, clm, ihor.solodrai
On Thu Apr 30, 2026 at 10:30 AM -03, bot+bpf-ci wrote:
>> diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
>> index cc14b13e23fe..7ba82974ee78 100644
>> --- a/tools/testing/selftests/bpf/test_progs.c
>> +++ b/tools/testing/selftests/bpf/test_progs.c
>
> [ ... ]
>
>> @@ -2046,15 +2069,20 @@ int main(int argc, char **argv)
>> struct prog_test_def *test = &prog_test_defs[i];
>>
>> test->test_num = i + 1;
>> - test->should_run = should_run(&env.test_selector,
>> - test->test_num, test->test_name);
>> + test->selected = should_run(&env.test_selector,
>> + test->test_num, test->test_name);
>> + test->should_run = test->selected;
>>
>> - if ((test->run_test == NULL && test->run_serial_test == NULL) ||
>> - (test->run_test != NULL && test->run_serial_test != NULL)) {
>> + if (test->run_test && test->run_serial_test) {
>> fprintf(stderr, "Test %d:%s must have either test_%s() or serial_test_%sl() defined.\n",
>> test->test_num, test->test_name, test->test_name, test->test_name);
>> exit(EXIT_ERR_SETUP_INFRA);
>> }
>> + if (!test->run_test && !test->run_serial_test) {
>> + test->not_built = true;
>> + test->should_run = false;
>> + continue;
>> + }
>> if (test->should_run)
>> test->should_tmon = should_tmon(&env.tmon_selector, test->test_name);
>> }
>> @@ -2106,9 +2134,18 @@ int main(int argc, char **argv)
>>
>> for (i = 0; i < prog_test_cnt; i++) {
>> struct prog_test_def *test = &prog_test_defs[i];
>> + struct test_state *state = &test_states[i];
>>
>> - if (!test->should_run)
>> + if (!test->should_run) {
>> + if (test->not_built && test->selected &&
>> + !env.get_test_cnt && !env.list_test_names) {
>> + state->tested = true;
>> + state->skip_cnt = 1;
>> + env.not_built_cnt++;
>> + print_test_result(test, state);
>> + }
>> continue;
>> + }
>
> When test->should_run is false (which it is for unbuilt tests due to the
> code above setting test->should_run = false), the continue statement skips
> the env.get_test_cnt and env.list_test_names blocks that follow.
>
> Won't this completely omit unbuilt tests from the output of --list (-l) and
> --count modes? The code only prints unbuilt tests when !env.get_test_cnt &&
> !env.list_test_names is true.
It makes no sense to count and list tests that can't be run.
>
> If CI systems use test_progs -l to discover and distribute tests across
> parallel jobs, they won't be aware of unbuilt tests. Could this undermine
> the stated goal of keeping unbuilt tests visible in CI results?
Only if the CI in question sets BPF_STRICT_BUILD=0, which is not usually
the case and if opted-in then the user will know that some tests might not
appear and be counted.
>
> Reference: sashiko-bot raised this concern in v10 discussion at
> https://lore.kernel.org/bpf/20260430131344.B40DDC2BCB3@smtp.kernel.org/
>
>>
>> if (env.get_test_cnt) {
>> env.succ_cnt++;
>
> [ ... ]
>
>
> ---
> 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/25167006036
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH bpf-next v10 08/11] selftests/bpf: Allow test_progs to link with a partial object set
2026-04-30 12:53 [PATCH bpf-next v10 00/11] selftests/bpf: Tolerate partial builds across kernel configs Ricardo B. Marlière
` (6 preceding siblings ...)
2026-04-30 12:53 ` [PATCH bpf-next v10 07/11] selftests/bpf: Skip tests whose objects were not built Ricardo B. Marlière
@ 2026-04-30 12:53 ` Ricardo B. Marlière
2026-04-30 12:53 ` [PATCH bpf-next v10 09/11] selftests/bpf: Tolerate benchmark build failures Ricardo B. Marlière
` (2 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Ricardo B. Marlière @ 2026-04-30 12:53 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi,
Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt
Cc: bpf, linux-kselftest, linux-kernel, llvm, Alan Maguire,
Ricardo B. Marliere
When individual test files are skipped due to compilation failures, their
.test.o files are absent. The linker step currently lists all expected
.test.o files as explicit prerequisites, so make considers any missing one
an error.
In permissive mode, declare the test objects that already exist on disk
(via parse-time $(wildcard ...)) as normal prerequisites of the binary so
that modifications to a test source still trigger a relink, and keep the
full TRUNNER_TEST_OBJS list as order-only prerequisites so that initial
fresh builds still produce them and missing objects do not abort the link.
The recipe filter is split per mode: in permissive mode it combines a
recipe-time $(wildcard ...) (which catches objects freshly produced via
the order-only path on a fresh build) with $(filter-out
$(TRUNNER_TEST_OBJS),$^) (which keeps the non-test inputs from $^ but
drops the parse-time wildcard duplicates). This avoids passing the same
.test.o twice to the linker while still presenting test objects before
libbpf.a so that GNU ld, which scans static archives left-to-right, pulls
in archive members referenced exclusively by test objects (e.g.
ring_buffer__new from ringbuf.c). In default (strict) mode the recipe
remains the simple $(filter %.a %.o,$^) since TRUNNER_TEST_OBJS is part
of $^ exactly once.
Gate the partial-link behavior on $(if $(filter test_progs%,$1),...) so
it only applies to test_progs and its flavors. test_maps and similar
runners using strong cross-object references would link-fail with a
partial set and intentionally retain strict link semantics.
Note: adding a brand-new test_*.c file in permissive mode requires
removing the binary (or a clean rebuild) before the new test is linked
in, because the parse-time $(wildcard ...) is evaluated when the Makefile
is read and will not yet see the new .test.o. This is acceptable since
permissive mode targets tolerant CI builds rather than incremental
development.
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
tools/testing/selftests/bpf/Makefile | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 9becc077eb23..a64e822dc540 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -773,14 +773,15 @@ endif
# some X.test.o files have runtime dependencies on Y.bpf.o files
$(OUTPUT)/$(TRUNNER_BINARY): | $(TRUNNER_BPF_OBJS)
-$(OUTPUT)/$(TRUNNER_BINARY): $(TRUNNER_TEST_OBJS) \
+$(OUTPUT)/$(TRUNNER_BINARY): $(if $(filter test_progs%,$1),$(if $(PERMISSIVE),$$(wildcard $(TRUNNER_TEST_OBJS)),$(TRUNNER_TEST_OBJS)),$(TRUNNER_TEST_OBJS)) \
$(TRUNNER_EXTRA_OBJS) $$(BPFOBJ) \
$(TRUNNER_LIB_OBJS) \
$(TRUNNER_BPFTOOL) \
$(OUTPUT)/veristat \
- | $(TRUNNER_BINARY)-extras
+ | $(TRUNNER_BINARY)-extras \
+ $(if $(filter test_progs%,$1),$(if $(PERMISSIVE),$(TRUNNER_TEST_OBJS)))
$$(call msg,BINARY,,$$@)
- $(Q)$$(CC) $$(CFLAGS) $$(filter %.a %.o,$$^) $$(LDLIBS) $$(LLVM_LDLIBS) $$(LDFLAGS) $$(LLVM_LDFLAGS) -o $$@
+ $(Q)$$(CC) $$(CFLAGS) $(if $(filter test_progs%,$1),$(if $(PERMISSIVE),$$(filter %.a %.o,$$(wildcard $(TRUNNER_TEST_OBJS)) $$(filter-out $(TRUNNER_TEST_OBJS),$$^)),$$(filter %.a %.o,$$^)),$$(filter %.a %.o,$$^)) $$(LDLIBS) $$(LLVM_LDLIBS) $$(LDFLAGS) $$(LLVM_LDFLAGS) -o $$@
$(Q)ln -sf $(if $2,..,.)/tools/build/bpftool/$(USE_BOOTSTRAP)bpftool \
$(OUTPUT)/$(if $2,$2/)bpftool
--
2.54.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH bpf-next v10 09/11] selftests/bpf: Tolerate benchmark build failures
2026-04-30 12:53 [PATCH bpf-next v10 00/11] selftests/bpf: Tolerate partial builds across kernel configs Ricardo B. Marlière
` (7 preceding siblings ...)
2026-04-30 12:53 ` [PATCH bpf-next v10 08/11] selftests/bpf: Allow test_progs to link with a partial object set Ricardo B. Marlière
@ 2026-04-30 12:53 ` Ricardo B. Marlière
2026-04-30 12:53 ` [PATCH bpf-next v10 10/11] selftests/bpf: Provide weak definitions for cross-test functions Ricardo B. Marlière
2026-04-30 12:53 ` [PATCH bpf-next v10 11/11] selftests/bpf: Tolerate missing files during install Ricardo B. Marlière
10 siblings, 0 replies; 20+ messages in thread
From: Ricardo B. Marlière @ 2026-04-30 12:53 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi,
Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt
Cc: bpf, linux-kselftest, linux-kernel, llvm, Alan Maguire,
Ricardo B. Marliere
Benchmark objects depend on skeletons that may be missing when some BPF
programs fail to build. In that case, benchmark object compilation or final
bench linking should not abort the full selftests/bpf build.
Keep both steps non-fatal, emit SKIP-BENCH or SKIP-LINK, and remove failed
outputs so stale objects or binaries are not reused by later incremental
builds. Note that because bench.c statically references every benchmark via
extern symbols, partial linking is not possible: if any single benchmark
object fails, the entire bench binary is skipped. This is by design -- the
error handler catches all compilation failures including genuine ones, but
those are caught by full-config CI runs.
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
tools/testing/selftests/bpf/Makefile | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index a64e822dc540..0559742137e3 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -945,7 +945,8 @@ $(OUTPUT)/test_cpp: test_cpp.cpp $(OUTPUT)/test_core_extern.skel.h $(BPFOBJ)
# Benchmark runner
$(OUTPUT)/bench_%.o: benchs/bench_%.c bench.h $(BPFOBJ)
$(call msg,CC,,$@)
- $(Q)$(CC) $(CFLAGS) -O2 -c $(filter %.c,$^) $(LDLIBS) -o $@
+ $(Q)$(CC) $(CFLAGS) -O2 -c $(filter %.c,$^) $(LDLIBS) -o $@ $(if $(PERMISSIVE),|| \
+ ($(RM) $@; printf ' %-12s %s\n' 'SKIP-BENCH' '$(notdir $@)' 1>&2))
$(OUTPUT)/bench_rename.o: $(OUTPUT)/test_overhead.skel.h
$(OUTPUT)/bench_trigger.o: $(OUTPUT)/trigger_bench.skel.h
$(OUTPUT)/bench_ringbufs.o: $(OUTPUT)/ringbuf_bench.skel.h \
@@ -988,7 +989,8 @@ $(OUTPUT)/bench: $(OUTPUT)/bench.o \
$(OUTPUT)/usdt_2.o \
#
$(call msg,BINARY,,$@)
- $(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(filter %.a %.o,$^) $(LDLIBS) -o $@
+ $(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(filter %.a %.o,$^) $(LDLIBS) -o $@ $(if $(PERMISSIVE),|| \
+ ($(RM) $@; printf ' %-12s %s\n' 'SKIP-LINK' '$(notdir $@) (some benchmarks may have been skipped)' 1>&2))
# This works around GCC warning about snprintf truncating strings like:
#
--
2.54.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH bpf-next v10 10/11] selftests/bpf: Provide weak definitions for cross-test functions
2026-04-30 12:53 [PATCH bpf-next v10 00/11] selftests/bpf: Tolerate partial builds across kernel configs Ricardo B. Marlière
` (8 preceding siblings ...)
2026-04-30 12:53 ` [PATCH bpf-next v10 09/11] selftests/bpf: Tolerate benchmark build failures Ricardo B. Marlière
@ 2026-04-30 12:53 ` Ricardo B. Marlière
2026-04-30 13:30 ` bot+bpf-ci
2026-04-30 12:53 ` [PATCH bpf-next v10 11/11] selftests/bpf: Tolerate missing files during install Ricardo B. Marlière
10 siblings, 1 reply; 20+ messages in thread
From: Ricardo B. Marlière @ 2026-04-30 12:53 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi,
Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt
Cc: bpf, linux-kselftest, linux-kernel, llvm, Alan Maguire,
Ricardo B. Marliere
Some test files reference functions defined in other translation units that
may not be compiled when skeletons are missing. Replace forward
declarations of uprobe_multi_func_{1,2,3}() with weak no-op stubs so the
linker resolves them regardless of which objects are present.
Move stack_mprotect() from test_lsm.c into testing_helpers.c so it is
always available. The previous weak-stub approach returned 0, which would
cause callers expecting -1/EPERM to fail their assertions
deterministically. Having the real implementation in a shared utility
avoids this problem entirely.
Include <alloca.h> for alloca() so the build does not rely on glibc's
implicit declaration via <stdlib.h>.
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
.../testing/selftests/bpf/prog_tests/bpf_cookie.c | 17 +++++++++++------
tools/testing/selftests/bpf/prog_tests/iters.c | 2 --
tools/testing/selftests/bpf/prog_tests/test_lsm.c | 22 ----------------------
tools/testing/selftests/bpf/testing_helpers.c | 18 ++++++++++++++++++
tools/testing/selftests/bpf/testing_helpers.h | 1 +
5 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c b/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c
index 35adc3f6d443..5a864cd8ad1b 100644
--- a/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c
+++ b/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c
@@ -252,10 +252,17 @@ static void kprobe_multi_attach_api_subtest(void)
kprobe_multi__destroy(skel);
}
-/* defined in prog_tests/uprobe_multi_test.c */
-void uprobe_multi_func_1(void);
-void uprobe_multi_func_2(void);
-void uprobe_multi_func_3(void);
+/*
+ * Weak uprobe target stubs. noinline is required because
+ * uprobe_multi_test_run() takes their addresses to configure the BPF
+ * program's attachment points; an inlined function has no stable
+ * address in the binary to probe. The strong definitions in
+ * uprobe_multi_test.c take precedence when that translation unit is
+ * linked.
+ */
+noinline __weak void uprobe_multi_func_1(void) {}
+noinline __weak void uprobe_multi_func_2(void) {}
+noinline __weak void uprobe_multi_func_3(void) {}
static void uprobe_multi_test_run(struct uprobe_multi *skel)
{
@@ -574,8 +581,6 @@ static void tracing_subtest(struct test_bpf_cookie *skel)
close(fmod_ret_fd);
}
-int stack_mprotect(void);
-
static void lsm_subtest(struct test_bpf_cookie *skel)
{
__u64 cookie;
diff --git a/tools/testing/selftests/bpf/prog_tests/iters.c b/tools/testing/selftests/bpf/prog_tests/iters.c
index a539980a2fbe..c0b6082f345a 100644
--- a/tools/testing/selftests/bpf/prog_tests/iters.c
+++ b/tools/testing/selftests/bpf/prog_tests/iters.c
@@ -202,8 +202,6 @@ static void subtest_task_iters(void)
iters_task__destroy(skel);
}
-extern int stack_mprotect(void);
-
static void subtest_css_task_iters(void)
{
struct iters_css_task *skel = NULL;
diff --git a/tools/testing/selftests/bpf/prog_tests/test_lsm.c b/tools/testing/selftests/bpf/prog_tests/test_lsm.c
index bdc4fc06bc5a..d7495efd4a56 100644
--- a/tools/testing/selftests/bpf/prog_tests/test_lsm.c
+++ b/tools/testing/selftests/bpf/prog_tests/test_lsm.c
@@ -5,36 +5,14 @@
*/
#include <test_progs.h>
-#include <sys/mman.h>
#include <sys/wait.h>
#include <unistd.h>
-#include <malloc.h>
-#include <stdlib.h>
#include "lsm.skel.h"
#include "lsm_tailcall.skel.h"
char *CMD_ARGS[] = {"true", NULL};
-#define GET_PAGE_ADDR(ADDR, PAGE_SIZE) \
- (char *)(((unsigned long) (ADDR + PAGE_SIZE)) & ~(PAGE_SIZE-1))
-
-int stack_mprotect(void)
-{
- void *buf;
- long sz;
- int ret;
-
- sz = sysconf(_SC_PAGESIZE);
- if (sz < 0)
- return sz;
-
- buf = alloca(sz * 3);
- ret = mprotect(GET_PAGE_ADDR(buf, sz), sz,
- PROT_READ | PROT_WRITE | PROT_EXEC);
- return ret;
-}
-
int exec_cmd(int *monitored_pid)
{
int child_pid, child_status;
diff --git a/tools/testing/selftests/bpf/testing_helpers.c b/tools/testing/selftests/bpf/testing_helpers.c
index 6fbe1e995660..c970e7793dfc 100644
--- a/tools/testing/selftests/bpf/testing_helpers.c
+++ b/tools/testing/selftests/bpf/testing_helpers.c
@@ -5,6 +5,8 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <sys/mman.h>
+#include <alloca.h>
#include <bpf/bpf.h>
#include <bpf/libbpf.h>
#include "disasm.h"
@@ -516,3 +518,19 @@ bool is_jit_enabled(void)
return enabled;
}
+
+int stack_mprotect(void)
+{
+ void *buf;
+ long sz;
+ int ret;
+
+ sz = sysconf(_SC_PAGESIZE);
+ if (sz < 0)
+ return sz;
+
+ buf = alloca(sz * 3);
+ ret = mprotect((void *)(((unsigned long)(buf + sz)) & ~(sz - 1)), sz,
+ PROT_READ | PROT_WRITE | PROT_EXEC);
+ return ret;
+}
diff --git a/tools/testing/selftests/bpf/testing_helpers.h b/tools/testing/selftests/bpf/testing_helpers.h
index 2ca2356a0b58..2edc6fb7fc52 100644
--- a/tools/testing/selftests/bpf/testing_helpers.h
+++ b/tools/testing/selftests/bpf/testing_helpers.h
@@ -59,5 +59,6 @@ struct bpf_insn;
int get_xlated_program(int fd_prog, struct bpf_insn **buf, __u32 *cnt);
int testing_prog_flags(void);
bool is_jit_enabled(void);
+int stack_mprotect(void);
#endif /* __TESTING_HELPERS_H */
--
2.54.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH bpf-next v10 10/11] selftests/bpf: Provide weak definitions for cross-test functions
2026-04-30 12:53 ` [PATCH bpf-next v10 10/11] selftests/bpf: Provide weak definitions for cross-test functions Ricardo B. Marlière
@ 2026-04-30 13:30 ` bot+bpf-ci
0 siblings, 0 replies; 20+ messages in thread
From: bot+bpf-ci @ 2026-04-30 13:30 UTC (permalink / raw)
To: rbm, ast, daniel, andrii, martin.lau, eddyz87, memxor, song,
yonghong.song, jolsa, shuah, nathan, nick.desaulniers+lkml, morbo,
justinstitt
Cc: bpf, linux-kselftest, linux-kernel, llvm, alan.maguire, rbm, ast,
andrii, daniel, martin.lau, eddyz87, yonghong.song, clm,
ihor.solodrai
[-- Attachment #1: Type: text/plain, Size: 2438 bytes --]
> diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c b/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c
> index 35adc3f6d443..5a864cd8ad1b 100644
> --- a/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c
> +++ b/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c
> @@ -252,10 +252,17 @@ static void kprobe_multi_attach_api_subtest(void)
> kprobe_multi__destroy(skel);
> }
>
> -/* defined in prog_tests/uprobe_multi_test.c */
> -void uprobe_multi_func_1(void);
> -void uprobe_multi_func_2(void);
> -void uprobe_multi_func_3(void);
> +/*
> + * Weak uprobe target stubs. noinline is required because
> + * uprobe_multi_test_run() takes their addresses to configure the BPF
> + * program's attachment points; an inlined function has no stable
> + * address in the binary to probe. The strong definitions in
> + * uprobe_multi_test.c take precedence when that translation unit is
> + * linked.
> + */
> +noinline __weak void uprobe_multi_func_1(void) {}
> +noinline __weak void uprobe_multi_func_2(void) {}
> +noinline __weak void uprobe_multi_func_3(void) {}
Can compiler optimization passes like Identical Code Folding (ICF) merge
these three structurally identical weak stub functions into a single
memory address?
If they are folded into a single address, bpf_program__attach_uprobe_multi()
would attach three separate uprobes to the exact same offset, each with a
different cookie. Calling any of the functions would then execute the shared
address, triggering all three uprobes simultaneously:
uprobe_multi_test_run() {
uprobe_multi_func_1(); // triggers all 3 uprobes
uprobe_multi_func_2(); // triggers all 3 uprobes
uprobe_multi_func_3(); // triggers all 3 uprobes
}
This would increment the BPF program counters multiple times per call,
causing assertions like:
ASSERT_EQ(skel->bss->uprobe_multi_func_1_result, 1, ...);
to fail deterministically, as the result would be 3 instead of 1.
Would it make sense to make these stubs structurally unique, perhaps by
adding unique inline assembly to each?
This concern was raised by sashiko-bot@kernel.org in v9:
https://lore.kernel.org/bpf/20260429212931.44DD4C19425@smtp.kernel.org/
[ ... ]
---
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/25167006036
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH bpf-next v10 11/11] selftests/bpf: Tolerate missing files during install
2026-04-30 12:53 [PATCH bpf-next v10 00/11] selftests/bpf: Tolerate partial builds across kernel configs Ricardo B. Marlière
` (9 preceding siblings ...)
2026-04-30 12:53 ` [PATCH bpf-next v10 10/11] selftests/bpf: Provide weak definitions for cross-test functions Ricardo B. Marlière
@ 2026-04-30 12:53 ` Ricardo B. Marlière
10 siblings, 0 replies; 20+ messages in thread
From: Ricardo B. Marlière @ 2026-04-30 12:53 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi,
Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt
Cc: bpf, linux-kselftest, linux-kernel, llvm, Alan Maguire,
Ricardo B. Marliere
With partial builds, some TEST_GEN_FILES entries can be absent at install
time. rsync treats missing source arguments as fatal and aborts kselftest
installation.
Override INSTALL_SINGLE_RULE in selftests/bpf to use --ignore-missing-args,
while keeping the existing bpf-specific INSTALL_RULE extension logic. Also
add --ignore-missing-args to the TEST_INST_SUBDIRS rsync loop so that
subdirectories with no .bpf.o files (e.g. when a test runner flavor was
skipped) do not abort installation.
Note that the INSTALL_SINGLE_RULE override applies globally to all file
categories including static source files (TEST_PROGS, TEST_FILES). These
are version-controlled and should always be present, so the practical risk
is negligible.
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
tools/testing/selftests/bpf/Makefile | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 0559742137e3..459008486b89 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -1023,12 +1023,23 @@ EXTRA_CLEAN := $(SCRATCH_DIR) $(HOST_SCRATCH_DIR) \
# Delete partially updated (corrupted) files on error
.DELETE_ON_ERROR:
+# When permissive, tell rsync to ignore missing source arguments so that
+# partial builds do not abort installation.
+ifneq ($(PERMISSIVE),)
+override define INSTALL_SINGLE_RULE
+ $(if $(INSTALL_LIST),@mkdir -p $(INSTALL_PATH))
+ $(if $(INSTALL_LIST),rsync -a --copy-unsafe-links --ignore-missing-args $(INSTALL_LIST) $(INSTALL_PATH)/)
+endef
+endif
+
DEFAULT_INSTALL_RULE := $(INSTALL_RULE)
override define INSTALL_RULE
$(DEFAULT_INSTALL_RULE)
- @for DIR in $(TEST_INST_SUBDIRS); do \
- mkdir -p $(INSTALL_PATH)/$$DIR; \
- rsync -a $(OUTPUT)/$$DIR/*.bpf.o $(INSTALL_PATH)/$$DIR;\
+ @for DIR in $(TEST_INST_SUBDIRS); do \
+ mkdir -p $(INSTALL_PATH)/$$DIR; \
+ rsync -a $(if $(PERMISSIVE),--ignore-missing-args) \
+ $(OUTPUT)/$$DIR/*.bpf.o \
+ $(INSTALL_PATH)/$$DIR; \
done
endef
--
2.54.0
^ permalink raw reply related [flat|nested] 20+ messages in thread