kconfig: Make KCONFIG_ALLCONFIG work with randconfig.
PATCH 1/1 kconfig: Make KCONFIG_ALLCONFIG work with randconfig.
Adrian mentioned a few weeks ago that KCONFIG_ALLCONFIG is the way to go to ensure that things like allyes/allmod/allnoconfig work with a constrained set of symbols, with the implication that this holds true for randconfig as well.
While allyes/mod/noconfigs do seem to work fine with KCONFIG_ALLCONFIG provisions, randconfig tramples all over the provided values at perhaps not surprisingly, random.
Debugging this a bit, there seemed to be two issues:
- SYMBOL_DEF and SYMBOL_DEF_USER overlap, which made def_sym->flags the same regardless of whether we came from an KCONFIG_ALLCONFIG path or not.
- clobbering of the fixed value in conf_choice() by way of random() def assignment.
While I don't pretend to have any idea what I'm doing in Kconfig, changing SYMBOL_DEF_USER to reuse the SYMBOL_DEF3 bit (and thereby separating it from SYMBOL_DEF) in addition to checking the def_sym flag before randomly assigning a new value ended up fixing things up.
---
scripts/kconfig/conf.c | 9 ++++++++- scripts/kconfig/expr.h | 3 +-- 2 files changed, 9 insertions(+), 3 deletions(-)
scripts/kconfig/conf.c +8 -1
@@ -374,7 +374,14 @@ static int conf_choice(struct menu *menu)continue ;break ;case set_random: - def = (random () % cnt) +1 ; +/* +* Defined symbols need to be honoured even in +* the randomization case, or else symbols set +* via the KCONFIG_ALLCONFIG path are clobbered. +* - PFM. +*/ +if (!(def_sym->flags &SYMBOL_DEF )) + def = (random () % cnt) +1 ;case set_default:case set_yes:case set_mod:
scripts/kconfig/expr.h +1 -2
@@ -95,9 +95,8 @@ struct symbol {#define SYMBOL_CHECKED 0x2000#define SYMBOL_WARNED 0x8000#define SYMBOL_DEF 0x10000 -#define SYMBOL_DEF_USER 0x10000#define SYMBOL_DEF_AUTO 0x20000 -#define SYMBOL_DEF3 0x40000 +#define SYMBOL_DEF_USER 0x40000#define SYMBOL_DEF4 0x80000#define SYMBOL_MAXLENGTH 256
Hi,
Quoted 4 lines · Paul Mundt
Adrian mentioned a few weeks ago that
KCONFIG_ALLCONFIGis the way to go to ensure that things like allyes/allmod/allnoconfig work with a constrained set of symbols, with the implication that this holds true for randconfig as well.
BTW another possibility is to use all{no,mod,yes,random,}.config.
Quoted 3 lines
While allyes/mod/noconfigs do seem to work fine with
KCONFIG_ALLCONFIGprovisions, randconfig tramples all over the provided values at perhaps not surprisingly, random.
Please be careful with such broad statements, there is only an issue with choice values.
Quoted 5 lines
Debugging this a bit, there seemed to be two issues:
-
SYMBOL_DEFandSYMBOL_DEF_USERoverlap, which madedef_sym->flagsthe same regardless of whether we came from anKCONFIG_ALLCONFIGpath or not.
Look at how SYMBOL_DEF is used in confdata.c.
Quoted 2 lines
- clobbering of the fixed value in
conf_choice()by way ofrandom()def assignment.
Simply add a test for is_new there.
bye, Roman
Quoted 8 lines · Roman Zippel
Quoted 3 lines · Paul Mundt
While allyes/mod/noconfigs do seem to work fine with
KCONFIG_ALLCONFIGprovisions, randconfig tramples all over the provided values at perhaps not surprisingly, random.Please be careful with such broad statements, there is only an issue with choice values.
Ok, I'll rephrase, '100% of the provided values I tested with were being randomly clobbered'. Is that better? Broken is broken, whether it applies to a small subset of symbols or not.
Quoted 8 lines
Quoted 5 lines
Debugging this a bit, there seemed to be two issues:
-
SYMBOL_DEFandSYMBOL_DEF_USERoverlap, which madedef_sym->flagsthe same regardless of whether we came from anKCONFIG_ALLCONFIGpath or not.Look at how
SYMBOL_DEFis used inconfdata.c.
Ah, ok. I was just trying to find something I could test that would be different for the KCONFIG_ALLCONFIG path, but it seems like is_new is a much cleaner solution for this, thanks for pointing it out!
Updated patch follows.
---
scripts/kconfig/conf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/kconfig/conf.c +2 -1
@@ -374,7 +374,8 @@ static int conf_choice(struct menu *menu)continue ;break ;case set_random: - def = (random () % cnt) +1 ; +if (is_new) + def = (random () % cnt) +1 ;case set_default:case set_yes:case set_mod: