Re: [PATCH v4 2/4] selftests/livepatch: clean the test modules without a kernel build directory
From: Petr Mladek
Date: Mon Nov 23 2026 - 05:23:25 EST
On Tue 2026-11-10 11:10:48, Sasha Levin wrote:
> "make clean" removes the test modules only when KDIR exists, and KDIR
> defaults to the build directory of the running kernel. Modules built
> for another kernel are therefore left in the source tree by a plain
> "make clean" on a machine without the running kernel's devel files,
> for example after building them as KernelCI does:
>
> make -C tools/testing/selftests O=<kernel> KDIR=<kernel> TARGETS=livepatch
The two parameters "O=<kernel> KDIR=<kernel>" do not make much sense
to me. The command starts compiling other selftests. I get:
$> make -C tools/testing/selftests O=<kernel> KDIR=<kernel> TARGETS=livepatch
Makefile:4: *** Package alsa not found, please install alsa development package or add directory containing `alsa.pc` in PKG_CONFIG_PATH. Stop.
test_execve.c:4:10: fatal error: cap-ng.h: No such file or directory
4 | #include <cap-ng.h>
| ^~~~~~~~~~
compilation terminated.
make[1]: *** [../lib.mk:226: /prace/ai/kernel/linux-livepatching/tools/testing/selftests/capabilities/test_execve] Error 1
/usr/bin/ld.bfd: cannot find -lcap: No such file or directory
collect2: error: ld returned 1 exit status
It works well when I omit the two parameters:
$> make -C tools/testing/selftests TARGETS=livepatch
make: Entering directory '/prace/ai/kernel/linux-livepatching/tools/testing/selftests'
CC test_klp-call_getpid
env -u KBUILD_OUTPUT make -C /prace/ai/kernel/linux-livepatching modules KBUILD_EXTMOD=/prace/ai/kernel/linux-livepatching/tools/testing/selftests/livepatch/test_modules
CC [M] test_klp_atomic_replace.o
CC [M] test_klp_callbacks_busy.o
Are these parameters really used by the KernelCI?
Could you please provide link to a build log?
> make -C tools/testing/selftests TARGETS=livepatch clean
>
> Removing external modules does not need a configured kernel. Clean
> them through the kernel source tree that contains the selftests, and
> do not pass on O= or KBUILD_OUTPUT, which the kernel Makefile would
> take as its build directory.
> --- a/tools/testing/selftests/livepatch/test_modules/Makefile
> +++ b/tools/testing/selftests/livepatch/test_modules/Makefile
> @@ -32,8 +32,11 @@ ifdef BUILD_TEST_MODS
> $(Q)$(MAKE) -C $(KDIR) modules KBUILD_EXTMOD=$(TESTMODS_DIR)
> endif
>
> -# Ensure that KDIR exists, otherwise skip the clean target
> +# Cleaning external modules needs no configured kernel, so clean them
> +# through the kernel source tree that contains this directory. The kernel
> +# Makefile would take an O= or KBUILD_OUTPUT passed on from the selftests
> +# build as its build directory, so drop them.
> +clean: MAKEOVERRIDES := $(filter-out O=% KBUILD_OUTPUT=%,$(MAKEOVERRIDES))
> clean:
> -ifneq ("$(wildcard $(KDIR))", "")
> - $(Q)$(MAKE) -C $(KDIR) clean KBUILD_EXTMOD=$(TESTMODS_DIR)
> -endif
> + $(Q)env -u KBUILD_OUTPUT $(MAKE) -C $(TESTMODS_DIR)/../../../../.. \
> + clean KBUILD_EXTMOD=$(TESTMODS_DIR)
Otherwise, the change seems to do the job.
So, maybe just the sample command in the commit message is wrong.
Best Regards,
Petr