A few cleanups and optimizations for the management of the kernel configuration.
Signed-off-by: Thomas Weißschuh linux@weissschuh.net --- Thomas Weißschuh (5): selftests/nolibc: drop custom EXTRACONFIG functionality selftests/nolibc: drop call to prepare target selftests/nolibc: drop call to mrproper target selftests/nolibc: execute defconfig before other targets selftests/nolibc: always keep test kernel configuration up to date
tools/testing/selftests/nolibc/Makefile | 17 +++++------------ tools/testing/selftests/nolibc/run-tests.sh | 5 +---- 2 files changed, 6 insertions(+), 16 deletions(-) --- base-commit: 60fe18237f72e3a186127658452dbb0992113cf7 change-id: 20250122-nolibc-config-d639e1612c93
Best regards,
kbuild already contains logic to merge predefines snippets into a defconfig file. This already works nicely with the current "defconfig" target. Make use of the snippet and drop the custom logic.
Signed-off-by: Thomas Weißschuh linux@weissschuh.net --- tools/testing/selftests/nolibc/Makefile | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 7d14a7c0cb62608f328b251495264517d333db2e..ba044c8a042ce345ff90bdd35569de4b5acd117d 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -82,7 +82,7 @@ DEFCONFIG_x86 = defconfig DEFCONFIG_arm64 = defconfig DEFCONFIG_arm = multi_v7_defconfig DEFCONFIG_mips32le = malta_defconfig -DEFCONFIG_mips32be = malta_defconfig +DEFCONFIG_mips32be = malta_defconfig generic/eb.config DEFCONFIG_ppc = pmac32_defconfig DEFCONFIG_ppc64 = powernv_be_defconfig DEFCONFIG_ppc64le = powernv_defconfig @@ -93,9 +93,6 @@ DEFCONFIG_s390 = defconfig DEFCONFIG_loongarch = defconfig DEFCONFIG = $(DEFCONFIG_$(XARCH))
-EXTRACONFIG_mips32be = -d CONFIG_CPU_LITTLE_ENDIAN -e CONFIG_CPU_BIG_ENDIAN -EXTRACONFIG = $(EXTRACONFIG_$(XARCH)) - # optional tests to run (default = all) TEST =
@@ -265,10 +262,6 @@ initramfs: nolibc-test
defconfig: $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) mrproper $(DEFCONFIG) prepare - $(Q)if [ -n "$(EXTRACONFIG)" ]; then \ - $(srctree)/scripts/config --file $(objtree)/.config $(EXTRACONFIG); \ - $(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) olddefconfig < /dev/null; \ - fi
kernel: $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(IMAGE_NAME) < /dev/null
The "prepare" target does not need to be run manually. kbuild knows when to use it on its own and the target is not even documented.
Signed-off-by: Thomas Weißschuh linux@weissschuh.net --- tools/testing/selftests/nolibc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index ba044c8a042ce345ff90bdd35569de4b5acd117d..464165e3d9175d283ec0ed14765df29427b6de38 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -261,7 +261,7 @@ initramfs: nolibc-test $(Q)cp nolibc-test initramfs/init
defconfig: - $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) mrproper $(DEFCONFIG) prepare + $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) mrproper $(DEFCONFIG)
kernel: $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(IMAGE_NAME) < /dev/null
"mrproper" unnecessarily cleans a lot of files. kbuild is smart enough to handle changed configurations, so the cleanup is not necessary and only leads to excessive rebuilds.
Signed-off-by: Thomas Weißschuh linux@weissschuh.net --- tools/testing/selftests/nolibc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 464165e3d9175d283ec0ed14765df29427b6de38..d3afb71b4c6b7fc51b89f034c826692e76122864 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -261,7 +261,7 @@ initramfs: nolibc-test $(Q)cp nolibc-test initramfs/init
defconfig: - $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) mrproper $(DEFCONFIG) + $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(DEFCONFIG)
kernel: $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(IMAGE_NAME) < /dev/null
Some targets use the test kernel configuration. Executing defconfig in the same make invocation as those targets results in errors as the configuration may be in an inconsistent state during reconfiguration. Avoid this by introducing ordering dependencies between the defconfig and some other targets.
Signed-off-by: Thomas Weißschuh linux@weissschuh.net --- tools/testing/selftests/nolibc/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index d3afb71b4c6b7fc51b89f034c826692e76122864..b74fa74e5ce296f032bec76ce9b3f5a3debe2b40 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -217,7 +217,7 @@ all: run
sysroot: sysroot/$(ARCH)/include
-sysroot/$(ARCH)/include: +sysroot/$(ARCH)/include: | defconfig $(Q)rm -rf sysroot/$(ARCH) sysroot/sysroot $(QUIET_MKDIR)mkdir -p sysroot $(Q)$(MAKE) -C $(srctree) outputmakefile @@ -263,10 +263,10 @@ initramfs: nolibc-test defconfig: $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(DEFCONFIG)
-kernel: +kernel: | defconfig $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(IMAGE_NAME) < /dev/null
-kernel-standalone: initramfs +kernel-standalone: initramfs | defconfig $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(IMAGE_NAME) CONFIG_INITRAMFS_SOURCE=$(CURDIR)/initramfs < /dev/null
# run the tests after building the kernel
Avoid using a stale test kernel configuration by always synchronizing it to the current source tree. kbuild is smart enough to avoid spurious rebuilds.
Signed-off-by: Thomas Weißschuh linux@weissschuh.net --- tools/testing/selftests/nolibc/run-tests.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/tools/testing/selftests/nolibc/run-tests.sh b/tools/testing/selftests/nolibc/run-tests.sh index 9c5160c5388122deeeb59ecfced7633000d69b10..664f92e1c5500f726ab33247321b96e8602ce185 100755 --- a/tools/testing/selftests/nolibc/run-tests.sh +++ b/tools/testing/selftests/nolibc/run-tests.sh @@ -158,9 +158,6 @@ test_arch() { MAKE=(make -j"${nproc}" XARCH="${arch}" CROSS_COMPILE="${cross_compile}" LLVM="${llvm}" O="${build_dir}")
mkdir -p "$build_dir" - if [ "$test_mode" = "system" ] && [ ! -f "${build_dir}/.config" ]; then - swallow_output "${MAKE[@]}" defconfig - fi case "$test_mode" in 'system') test_target=run @@ -173,7 +170,7 @@ test_arch() { exit 1 esac printf '%-15s' "$arch:" - swallow_output "${MAKE[@]}" CFLAGS_EXTRA="$CFLAGS_EXTRA" "$test_target" V=1 + swallow_output "${MAKE[@]}" CFLAGS_EXTRA="$CFLAGS_EXTRA" defconfig "$test_target" V=1 cp run.out run.out."${arch}" "${MAKE[@]}" report | grep passed }
Hi Thomas!
On Wed, Jan 22, 2025 at 07:41:48PM +0100, Thomas Weißschuh wrote:
@@ -173,7 +170,7 @@ test_arch() { exit 1 esac printf '%-15s' "$arch:"
- swallow_output "${MAKE[@]}" CFLAGS_EXTRA="$CFLAGS_EXTRA" "$test_target" V=1
- swallow_output "${MAKE[@]}" CFLAGS_EXTRA="$CFLAGS_EXTRA" defconfig "$test_target" V=1
Just a question, are you certain that dependencies between $test_target and defconfig are always properly handled ? I'm asking because "make -j" is something valid, and we wouldn't want defconfig to run in parallel with test_target. For real sequencing (and making sure targets run in the correct order), I normally prefer to run them one at a time. Here you could simply prepend the defconfig line before the original one and get these guarantees (and also make them explicit). That's also less edit when copy-pasting from the terminal to the shell when trying to debug.
Just my few cents ;-) Willy
Hi Willy!
On 2025-01-22 19:52:06+0100, Willy Tarreau wrote:
On Wed, Jan 22, 2025 at 07:41:48PM +0100, Thomas Weißschuh wrote:
@@ -173,7 +170,7 @@ test_arch() { exit 1 esac printf '%-15s' "$arch:"
- swallow_output "${MAKE[@]}" CFLAGS_EXTRA="$CFLAGS_EXTRA" "$test_target" V=1
- swallow_output "${MAKE[@]}" CFLAGS_EXTRA="$CFLAGS_EXTRA" defconfig "$test_target" V=1
Just a question, are you certain that dependencies between $test_target and defconfig are always properly handled ? I'm asking because "make -j" is something valid, and we wouldn't want defconfig to run in parallel with test_target.
"make -j" is not only valid but used by run-tests.sh always. The sequencing is explicitly enforced in patch 4.
For real sequencing (and making sure targets run in the correct order), I normally prefer to run them one at a time. Here you could simply prepend the defconfig line before the original one and get these guarantees (and also make them explicit). That's also less edit when copy-pasting from the terminal to the shell when trying to debug.
Sounds fine to me, too. That would remove the need for patch 4, but I'd like to keep it anyways.
Thomas
On Wed, Jan 22, 2025 at 08:00:28PM +0100, Thomas Weißschuh wrote:
Hi Willy!
On 2025-01-22 19:52:06+0100, Willy Tarreau wrote:
On Wed, Jan 22, 2025 at 07:41:48PM +0100, Thomas Weißschuh wrote:
@@ -173,7 +170,7 @@ test_arch() { exit 1 esac printf '%-15s' "$arch:"
- swallow_output "${MAKE[@]}" CFLAGS_EXTRA="$CFLAGS_EXTRA" "$test_target" V=1
- swallow_output "${MAKE[@]}" CFLAGS_EXTRA="$CFLAGS_EXTRA" defconfig "$test_target" V=1
Just a question, are you certain that dependencies between $test_target and defconfig are always properly handled ? I'm asking because "make -j" is something valid, and we wouldn't want defconfig to run in parallel with test_target.
"make -j" is not only valid but used by run-tests.sh always. The sequencing is explicitly enforced in patch 4.
I learned something today, I didn't know about order-only rules.
For real sequencing (and making sure targets run in the correct order), I normally prefer to run them one at a time. Here you could simply prepend the defconfig line before the original one and get these guarantees (and also make them explicit). That's also less edit when copy-pasting from the terminal to the shell when trying to debug.
Sounds fine to me, too. That would remove the need for patch 4, but I'd like to keep it anyways.
Agreed!
Willy
linux-kselftest-mirror@lists.linaro.org