public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] selftests/nolibc: test kernel configuration cleanups
@ 2025-01-22 18:41 Thomas Weißschuh
  2025-01-22 18:41 ` [PATCH 1/5] selftests/nolibc: drop custom EXTRACONFIG functionality Thomas Weißschuh
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Thomas Weißschuh @ 2025-01-22 18:41 UTC (permalink / raw)
  To: Willy Tarreau, Shuah Khan
  Cc: linux-kselftest, linux-kernel, Thomas Weißschuh

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,
-- 
Thomas Weißschuh <linux@weissschuh.net>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/5] selftests/nolibc: drop custom EXTRACONFIG functionality
  2025-01-22 18:41 [PATCH 0/5] selftests/nolibc: test kernel configuration cleanups Thomas Weißschuh
@ 2025-01-22 18:41 ` Thomas Weißschuh
  2025-01-22 18:41 ` [PATCH 2/5] selftests/nolibc: drop call to prepare target Thomas Weißschuh
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Thomas Weißschuh @ 2025-01-22 18:41 UTC (permalink / raw)
  To: Willy Tarreau, Shuah Khan
  Cc: linux-kselftest, linux-kernel, Thomas Weißschuh

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

-- 
2.48.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/5] selftests/nolibc: drop call to prepare target
  2025-01-22 18:41 [PATCH 0/5] selftests/nolibc: test kernel configuration cleanups Thomas Weißschuh
  2025-01-22 18:41 ` [PATCH 1/5] selftests/nolibc: drop custom EXTRACONFIG functionality Thomas Weißschuh
@ 2025-01-22 18:41 ` Thomas Weißschuh
  2025-01-22 18:41 ` [PATCH 3/5] selftests/nolibc: drop call to mrproper target Thomas Weißschuh
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Thomas Weißschuh @ 2025-01-22 18:41 UTC (permalink / raw)
  To: Willy Tarreau, Shuah Khan
  Cc: linux-kselftest, linux-kernel, Thomas Weißschuh

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

-- 
2.48.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/5] selftests/nolibc: drop call to mrproper target
  2025-01-22 18:41 [PATCH 0/5] selftests/nolibc: test kernel configuration cleanups Thomas Weißschuh
  2025-01-22 18:41 ` [PATCH 1/5] selftests/nolibc: drop custom EXTRACONFIG functionality Thomas Weißschuh
  2025-01-22 18:41 ` [PATCH 2/5] selftests/nolibc: drop call to prepare target Thomas Weißschuh
@ 2025-01-22 18:41 ` Thomas Weißschuh
  2025-01-22 18:41 ` [PATCH 4/5] selftests/nolibc: execute defconfig before other targets Thomas Weißschuh
  2025-01-22 18:41 ` [PATCH 5/5] selftests/nolibc: always keep test kernel configuration up to date Thomas Weißschuh
  4 siblings, 0 replies; 9+ messages in thread
From: Thomas Weißschuh @ 2025-01-22 18:41 UTC (permalink / raw)
  To: Willy Tarreau, Shuah Khan
  Cc: linux-kselftest, linux-kernel, Thomas Weißschuh

"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

-- 
2.48.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/5] selftests/nolibc: execute defconfig before other targets
  2025-01-22 18:41 [PATCH 0/5] selftests/nolibc: test kernel configuration cleanups Thomas Weißschuh
                   ` (2 preceding siblings ...)
  2025-01-22 18:41 ` [PATCH 3/5] selftests/nolibc: drop call to mrproper target Thomas Weißschuh
@ 2025-01-22 18:41 ` Thomas Weißschuh
  2025-01-22 18:41 ` [PATCH 5/5] selftests/nolibc: always keep test kernel configuration up to date Thomas Weißschuh
  4 siblings, 0 replies; 9+ messages in thread
From: Thomas Weißschuh @ 2025-01-22 18:41 UTC (permalink / raw)
  To: Willy Tarreau, Shuah Khan
  Cc: linux-kselftest, linux-kernel, Thomas Weißschuh

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

-- 
2.48.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 5/5] selftests/nolibc: always keep test kernel configuration up to date
  2025-01-22 18:41 [PATCH 0/5] selftests/nolibc: test kernel configuration cleanups Thomas Weißschuh
                   ` (3 preceding siblings ...)
  2025-01-22 18:41 ` [PATCH 4/5] selftests/nolibc: execute defconfig before other targets Thomas Weißschuh
@ 2025-01-22 18:41 ` Thomas Weißschuh
  2025-01-22 18:52   ` Willy Tarreau
  4 siblings, 1 reply; 9+ messages in thread
From: Thomas Weißschuh @ 2025-01-22 18:41 UTC (permalink / raw)
  To: Willy Tarreau, Shuah Khan
  Cc: linux-kselftest, linux-kernel, Thomas Weißschuh

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
 }

-- 
2.48.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 5/5] selftests/nolibc: always keep test kernel configuration up to date
  2025-01-22 18:41 ` [PATCH 5/5] selftests/nolibc: always keep test kernel configuration up to date Thomas Weißschuh
@ 2025-01-22 18:52   ` Willy Tarreau
  2025-01-22 19:00     ` Thomas Weißschuh
  0 siblings, 1 reply; 9+ messages in thread
From: Willy Tarreau @ 2025-01-22 18:52 UTC (permalink / raw)
  To: Thomas Weißschuh; +Cc: Shuah Khan, linux-kselftest, linux-kernel

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 5/5] selftests/nolibc: always keep test kernel configuration up to date
  2025-01-22 18:52   ` Willy Tarreau
@ 2025-01-22 19:00     ` Thomas Weißschuh
  2025-01-22 22:14       ` Willy Tarreau
  0 siblings, 1 reply; 9+ messages in thread
From: Thomas Weißschuh @ 2025-01-22 19:00 UTC (permalink / raw)
  To: Willy Tarreau; +Cc: Shuah Khan, linux-kselftest, linux-kernel

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 5/5] selftests/nolibc: always keep test kernel configuration up to date
  2025-01-22 19:00     ` Thomas Weißschuh
@ 2025-01-22 22:14       ` Willy Tarreau
  0 siblings, 0 replies; 9+ messages in thread
From: Willy Tarreau @ 2025-01-22 22:14 UTC (permalink / raw)
  To: Thomas Weißschuh; +Cc: Shuah Khan, linux-kselftest, linux-kernel

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-01-22 22:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-22 18:41 [PATCH 0/5] selftests/nolibc: test kernel configuration cleanups Thomas Weißschuh
2025-01-22 18:41 ` [PATCH 1/5] selftests/nolibc: drop custom EXTRACONFIG functionality Thomas Weißschuh
2025-01-22 18:41 ` [PATCH 2/5] selftests/nolibc: drop call to prepare target Thomas Weißschuh
2025-01-22 18:41 ` [PATCH 3/5] selftests/nolibc: drop call to mrproper target Thomas Weißschuh
2025-01-22 18:41 ` [PATCH 4/5] selftests/nolibc: execute defconfig before other targets Thomas Weißschuh
2025-01-22 18:41 ` [PATCH 5/5] selftests/nolibc: always keep test kernel configuration up to date Thomas Weißschuh
2025-01-22 18:52   ` Willy Tarreau
2025-01-22 19:00     ` Thomas Weißschuh
2025-01-22 22:14       ` Willy Tarreau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox