Re: [PATCH v3 3/7] selftests/nolibc: add extra configs customize support

From: Zhangjin Wu
Date: Sun Jul 30 2023 - 14:03:00 EST


Hi,

> At last, here is it?
>
> # extra configs/ files appended to .config during the nolibc-test-config target
> # include common + architecture specific
> NOLIBC_TEST_CONFIG = nolibc-test-common.config nolibc-test-$(XARCH).config
>
> nolibc-test-config:
> $(Q)$(MAKE_KERNEL) mrproper
> $(Q)$(MAKE_KERNEL) $(or $(CONFIG),$(DEFCONFIG)) prepare

The 'prepare' should be removed, we have one in the end.

> $(Q)$(srctree)/scripts/kconfig/merge_config.sh -Q -O "$(objtree)" -m "$(KERNEL_CONFIG)" $(foreach c,$(NOLIBC_TEST_CONFIG),$(wildcard $(CURDIR)/configs/$c))
> $(Q)$(MAKE_KERNEL) olddefconfig

Oh, sorry, test shows, 'allnoconfig' worth a comment ;-)

'allnoconfig' is ~2x faster than 'olddefconfig', it is more
deterministic for it set all new symbols (the ones not specified in
.config) with no.

// scripts/kconfig/Makefile

@echo ' oldconfig - Update current config utilising a provided .config as base'
@echo ' defconfig - New config with default from ARCH supplied defconfig'
@echo ' allnoconfig - New config where all options are answered with no'
@echo ' allyesconfig - New config where all options are accepted with yes'
@echo ' olddefconfig - Same as oldconfig but sets new symbols to their'
@echo ' default value without prompting'


here is the result:

// with 'allnoconfig'
$ sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'; arch=ppc; time make tinyconfig kernel -C tools/testing/selftests/nolibc CONFIG=tinyconfig XARCH=$arch O=$PWD/kernel-$arch
real 3m37.337s
user 3m11.576s
sys 0m16.899s

// with 'olddefconfig'
$ sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'; arch=ppc; time make tinyconfig kernel -C tools/testing/selftests/nolibc CONFIG=tinyconfig XARCH=$arch O=$PWD/kernel-$arch
real 5m28.759s
user 4m47.873s
sys 0m30.115s

// with 'defconfig'


Both merge_tools.sh and tinyconfig target use 'allnoconfig', the usage
is clear enough, no risk:

scripts/kconfig/merge_config.sh:

# Use the merged file as the starting point for:
# alldefconfig: Fills in any missing symbols with Kconfig default
# allnoconfig: Fills in any missing symbols with # CONFIG_* is not set
make KCONFIG_ALLCONFIG=$TMP_FILE $OUTPUT_ARG $ALLTARGET


scripts/kconfig/Makefile:

tinyconfig:
$(Q)KCONFIG_ALLCONFIG=kernel/configs/tiny-base.config $(MAKE) -f $(srctree)/Makefile allnoconfig
$(Q)$(MAKE) -f $(srctree)/Makefile tiny.config


And also since I have carefully test 'allnoconfig' for all of the nolibc
supported architectures, it is not good to waste time to test
'olddefconfig'. 'allnoconfig' is also more deterministic than
'olddefconfig' since it only enable the options specified by us
explicitly, so, no new symbols will be randomly enabled.

I plan to add more comments before 'nolibc-test-config':

# kernel config for nolibc-test
#
# - delete the current configuration and all generated files via 'mrproper' target
# - generate .config via '$(CONFIG)' or '$(DEFCONFIG_$(XARCH))' target
# - merge extra config options from $(NOLIBC_TEST_CONFIG) files to .config
# - use merged .config as base and fills in any missing symbols with '# CONFIG_* is not set' via 'allnoconfig' target
# - prepare things we need to do before we recursively start building the kernel via 'prepare' target
#

nolibc-test-config:
$(Q)$(MAKE_KERNEL) mrproper
$(Q)$(MAKE_KERNEL) $(or $(CONFIG),$(DEFCONFIG))
$(Q)$(srctree)/scripts/kconfig/merge_config.sh -Q -O "$(objtree)" -m "$(KERNEL_CONFIG)" $(foreach c,$(NOLIBC_TEST_CONFIG),$(wildcard $(CURDIR)/configs/$c))
$(Q)$(MAKE_KERNEL) KCONFIG_ALLCONFIG=$(KERNEL_CONFIG) allnoconfig
$(Q)$(MAKE_KERNEL) prepare

> $(Q)$(MAKE_KERNEL) prepare
>
> defconfig: nolibc-test-config
>
> The last line still depends on your confirm.
>
> Without more issues, I will renew this patchset as v4, thanks very much!
>
> (will update the XARCH patch to get your confirm in another reply too)
>
> Best regards,
> Zhangjin