From: sashiko-bot@kernel.org
To: "Ricardo B. Marlière" <rbm@suse.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v8 02/11] selftests/bpf: Fix test_kmods KDIR to honor O= and distro kernels
Date: Wed, 29 Apr 2026 03:53:39 +0000 [thread overview]
Message-ID: <20260429035339.D682FC19425@smtp.kernel.org> (raw)
In-Reply-To: <20260428-selftests-bpf_misconfig-v8-2-bf02cf97dbcb@suse.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Incorrect Kbuild variable precedence when both O= and KBUILD_OUTPUT= are set with different values.
--
commit 9fabc0968b75e1e4a5267d98394811c6db31a86e
Author: Ricardo B. Marlière <rbm@suse.com>
selftests/bpf: Fix test_kmods KDIR to honor O= and distro kernels
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, there was no fallback and the build would fail
unconditionally.
> diff --git a/tools/testing/selftests/bpf/test_kmods/Makefile b/tools/testing/selftests/bpf/test_kmods/Makefile
> index 63c4d3f6a12f..dcba595b4b99 100644
> --- a/tools/testing/selftests/bpf/test_kmods/Makefile
> +++ b/tools/testing/selftests/bpf/test_kmods/Makefile
[ ... ]
> @@ -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=) \
Will this cause an issue with Kbuild variable precedence if both O= and
KBUILD_OUTPUT= are set to different directories?
When a user provides both O= on the command line and KBUILD_OUTPUT= in the
environment, standard Kbuild prioritizes O=.
However, the parent bpf/Makefile passes KBUILD_OUTPUT explicitly on the
command line to this sub-make, upgrading it to a command-line variable
stored in MAKEFLAGS. This sub-make correctly evaluates
$(or $(O),$(KBUILD_OUTPUT)) to validate the O= directory, and calls the
kernel Makefile passing O=$(KMOD_O_VALID).
But because KBUILD_OUTPUT is also a command-line variable in MAKEFLAGS,
the kernel's top-level Makefile assignment "KBUILD_OUTPUT := $(O)" is
ignored by GNU Make. Consequently, the kernel build uses the directory
specified by KBUILD_OUTPUT rather than the validated O= directory. This
leads to a build failure if KBUILD_OUTPUT lacks the prepared build
infrastructure.
Could we explicitly override KBUILD_OUTPUT when KMOD_O_VALID is true?
Something like:
$(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=) \
Would the same explicit override for KBUILD_OUTPUT be needed here as well?
> + 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=) \
And also for the clean target?
> + M=$(TEST_KMOD_DIR) clean
> +endif
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260428-selftests-bpf_misconfig-v8-0-bf02cf97dbcb@suse.com?part=2
next prev parent reply other threads:[~2026-04-29 3:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-28 23:45 [PATCH bpf-next v8 00/11] selftests/bpf: Tolerate partial builds across kernel configs Ricardo B. Marlière
2026-04-28 23:45 ` [PATCH bpf-next v8 01/11] selftests/bpf: Add BPF_STRICT_BUILD toggle Ricardo B. Marlière
2026-04-28 23:45 ` [PATCH bpf-next v8 02/11] selftests/bpf: Fix test_kmods KDIR to honor O= and distro kernels Ricardo B. Marlière
2026-04-29 3:53 ` sashiko-bot [this message]
2026-04-28 23:45 ` [PATCH bpf-next v8 03/11] selftests/bpf: Tolerate BPF and skeleton generation failures Ricardo B. Marlière
2026-04-28 23:45 ` [PATCH bpf-next v8 04/11] selftests/bpf: Avoid rebuilds when running emit_tests Ricardo B. Marlière
2026-04-28 23:45 ` [PATCH bpf-next v8 05/11] selftests/bpf: Make skeleton headers order-only prerequisites of .test.d Ricardo B. Marlière
2026-04-29 4:24 ` sashiko-bot
2026-04-28 23:45 ` [PATCH bpf-next v8 06/11] selftests/bpf: Tolerate test file compilation failures Ricardo B. Marlière
2026-04-29 4:38 ` sashiko-bot
2026-04-28 23:45 ` [PATCH bpf-next v8 07/11] selftests/bpf: Skip tests whose objects were not built Ricardo B. Marlière
2026-04-28 23:45 ` [PATCH bpf-next v8 08/11] selftests/bpf: Allow test_progs to link with a partial object set Ricardo B. Marlière
2026-04-29 5:07 ` sashiko-bot
2026-04-28 23:45 ` [PATCH bpf-next v8 09/11] selftests/bpf: Tolerate benchmark build failures Ricardo B. Marlière
2026-04-28 23:45 ` [PATCH bpf-next v8 10/11] selftests/bpf: Provide weak definitions for cross-test functions Ricardo B. Marlière
2026-04-28 23:45 ` [PATCH bpf-next v8 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=20260429035339.D682FC19425@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=rbm@suse.com \
--cc=sashiko@lists.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.