From: "Ricardo B. Marlière" <rbm@suse.com>
To: <bot+bpf-ci@kernel.org>, <rbm@suse.com>, <ast@kernel.org>,
<daniel@iogearbox.net>, <andrii@kernel.org>,
<martin.lau@linux.dev>, <eddyz87@gmail.com>, <memxor@gmail.com>,
<song@kernel.org>, <yonghong.song@linux.dev>, <jolsa@kernel.org>,
<shuah@kernel.org>, <nathan@kernel.org>,
<nick.desaulniers+lkml@gmail.com>, <morbo@google.com>,
<justinstitt@google.com>
Cc: <bpf@vger.kernel.org>, <linux-kselftest@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <llvm@lists.linux.dev>,
<alan.maguire@oracle.com>, <martin.lau@kernel.org>,
<clm@meta.com>, <ihor.solodrai@linux.dev>
Subject: Re: [PATCH bpf-next v10 02/11] selftests/bpf: Fix test_kmods KDIR to honor O= and distro kernels
Date: Thu, 30 Apr 2026 11:09:14 -0300 [thread overview]
Message-ID: <DI6JRYWASEYN.3I8Q81ZPUE1VE@suse.com> (raw)
In-Reply-To: <d1297f1c857e5430af42dcb3e4d05c7ddaff08470a43893cac0fbcb83ec51666@mail.kernel.org>
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
next prev parent reply other threads:[~2026-04-30 14:09 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
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 13:30 ` bot+bpf-ci
2026-04-30 14:09 ` Ricardo B. Marlière [this message]
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 ` [PATCH bpf-next v10 04/11] selftests/bpf: Avoid rebuilds when running emit_tests 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
2026-04-30 13:30 ` bot+bpf-ci
2026-04-30 15:04 ` Ricardo B. Marlière
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
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
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 ` [PATCH bpf-next v10 09/11] selftests/bpf: Tolerate benchmark build failures 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 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DI6JRYWASEYN.3I8Q81ZPUE1VE@suse.com \
--to=rbm@suse.com \
--cc=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bot+bpf-ci@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clm@meta.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=justinstitt@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=martin.lau@kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox