kconfig: always use user input symbols
PATCH 1/1 kconfig: always use user input symbols
...regardless of visibility.
When a symbol that is not visible by default (e.g. PNFS_FLEXFILE_LAYOUT) has a default value, it is impossible to set the value to something not the default:
~/packages/linux render-symbol-inputs grep FLEXFILE .config CONFIG_PNFS_FLEXFILE_LAYOUT=y
~/packages/linux render-symbol-inputs make oldconfig scripts/kconfig/conf --oldconfig Kconfig ~/packages/linux render-symbol-inputs grep FLEXFILE .config CONFIG_PNFS_FLEXFILE_LAYOUT=m
There are two reasons for this: the symbol's user input value is only considered when it is visible (hunks 2 and 3), and the user values are explicitly ignored (hunk 1) if the symbols are not visible.
It's not clear to me why hunk 1 exists. I'm sure it solve some problem, but I'm not sure why we would ever want to discard user input values, and causes a problem exactly as the comment describes.
---
I don't know much about how kconfig works, I just noticed this when trying to do some automatic merging of configs. My main goal is to build a kernel without modules, but after a merge and running make oldconfig, some symbols always come back set as modules.
--- scripts/kconfig/confdata.c | 7 ------- scripts/kconfig/symbol.c | 32 ++++++++++++++++++-------------- 2 files changed, 18 insertions(+), 21 deletions(-)
scripts/kconfig/confdata.c +0 -7
@@ -448,13 +448,6 @@ int conf_read(const char *name) for_all_symbols(i, sym) {if (sym_has_value (sym) && !sym_is_choice_value (sym)) { -/* Reset values of generates values, so they'll appear -* as new, if they should become visible, but that -* doesn't quite work if the Kconfig and the saved -* configuration disagree. -*/ -if (sym->visible == no && !conf_unsaved) - sym->flags &= ~SYMBOL_DEF_USER ;switch (sym->type) {case S_STRING :case S_INT :
scripts/kconfig/symbol.c +18 -14
@@ -386,17 +386,19 @@ void sym_calc_value(struct symbol *sym) prop =sym_get_choice_prop (sym); newval.tri = (prop_get_symbol (prop)->curr.val == sym) ? yes : no; }else { -if (sym->visible != no) { -/* if the symbol is visible use the user value -* if available, otherwise try the default value -*/ +/* If the user defined a value, let's not ignore it, +* even if the symbol is not visible. +*/ +if (sym_has_value (sym)) { sym->flags |=SYMBOL_WRITE ; -if (sym_has_value (sym)) { - newval.tri =EXPR_AND (sym->def[S_DEF_USER ].tri, - sym->visible); - goto calc_newval; - } + newval.tri = sym->def[S_DEF_USER ].tri; + goto calc_newval; } + +if (sym->visible != no) + sym->flags |=SYMBOL_WRITE ; + +/* otherwise, let's use the default */ if (sym->rev_dep.tri != no) sym->flags |=SYMBOL_WRITE ;if (!sym_is_choice (sym)) {
@@ -433,13 +435,15 @@ void sym_calc_value(struct symbol *sym)case S_STRING :case S_HEX :case S_INT : -if (sym->visible != no) { +if (sym_has_value (sym)) { sym->flags |=SYMBOL_WRITE ; -if (sym_has_value (sym)) { - newval.val = sym->def[S_DEF_USER ].val; -break ; - } + newval.val = sym->def[S_DEF_USER ].val; + goto calc_newval; } + +if (sym->visible != no) + sym->flags |=SYMBOL_WRITE ; + prop =sym_get_default_prop (sym);if (prop) {struct symbol *ds =prop_get_symbol (prop);
Signature · 1 line
2.9.3
Hi Tycho,
Quoted 13 lines · Tycho Andersen
...regardless of visibility.
When a symbol that is not visible by default (e.g.
PNFS_FLEXFILE_LAYOUT) has a default value, it is impossible to set the value to something not the default:~/packages/linux render-symbol-inputs grep FLEXFILE .config
CONFIG_PNFS_FLEXFILE_LAYOUT=y
~/packages/linux render-symbol-inputs make oldconfigscripts/kconfig/conf--oldconfigKconfig~/packages/linux render-symbol-inputs grep FLEXFILE .configCONFIG_PNFS_FLEXFILE_LAYOUT=m
Quoted 7 lines
There are two reasons for this: the symbol's user input value is only considered when it is visible (hunks 2 and 3), and the user values are explicitly ignored (hunk 1) if the symbols are not visible.
It's not clear to me why hunk 1 exists. I'm sure it solve some problem, but I'm not sure why we would ever want to discard user input values, and causes a problem exactly as the comment describes.
This is intentional. If a symbol is not visible, it's not meant to be changed by the user, as doing so may break things (at build or runtime).
E.g. running "make oldconfig" after a kernel upgrade may retain the old state of a variable, which is now invalid. Ignoring invisible symbols avoids this.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hi Geert,
Quoted 24 lines · Geert Uytterhoeven
Hi Tycho,
Quoted 13 lines · Tycho Andersen
...regardless of visibility.
When a symbol that is not visible by default (e.g.
PNFS_FLEXFILE_LAYOUT) has a default value, it is impossible to set the value to something not the default:~/packages/linux render-symbol-inputs grep FLEXFILE .config
CONFIG_PNFS_FLEXFILE_LAYOUT=y
~/packages/linux render-symbol-inputs make oldconfigscripts/kconfig/conf--oldconfigKconfig~/packages/linux render-symbol-inputs grep FLEXFILE .configCONFIG_PNFS_FLEXFILE_LAYOUT=mQuoted 7 lines
There are two reasons for this: the symbol's user input value is only considered when it is visible (hunks 2 and 3), and the user values are explicitly ignored (hunk 1) if the symbols are not visible.
It's not clear to me why hunk 1 exists. I'm sure it solve some problem, but I'm not sure why we would ever want to discard user input values, and causes a problem exactly as the comment describes.
Quoted 6 lines
This is intentional. If a symbol is not visible, it's not meant to be changed by the user, as doing so may break things (at build or runtime).
E.g. running "make oldconfig" after a kernel upgrade may retain the old state of a variable, which is now invalid. Ignoring invisible symbols avoids this.
Makes sense. Thanks!
Tycho
kbuild test robot
build boturl: https://github.com/0day-ci/linux/commits/Tycho-Andersen/kconfig-always-use-user-input-symbols/20170522-143552 config: i386-tinyconfig (attached as .config) compiler: gcc-6 (Debian 6.2.0-3)…
Hi Tycho,
[auto build test ERROR on linus/master]
[also build test ERROR on v4.12-rc2 next-20170522]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Tycho-Andersen/kconfig-always-use-user-input-symbols/20170522-143552
config: i386-tinyconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 All error/warnings (new ones prefixed by >>):
In file included from arch/x86/include/asm/bitops.h:16:0,
from include/linux/bitops.h:36,
from include/linux/kernel.h:10,
from include/asm-generic/bug.h:15,
from arch/x86/include/asm/bug.h:81,
from include/linux/bug.h:4,
from include/linux/page-flags.h:9,
from kernel/bounds.c:9:
arch/x86/include/asm/arch_hweight.h: In function '__arch_hweight64':
>> arch/x86/include/asm/arch_hweight.h:54:42: error: expected ':' or ')' before 'POPCNT64'
asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT)
^
arch/x86/include/asm/alternative.h:132:28: note: in definition of macro 'ALTINSTR_REPLACEMENT'
b_replacement(num)":\n\t" newinstr "\n" e_replacement(num) ":\n\t"
^~~~~~~~
>> arch/x86/include/asm/arch_hweight.h:54:7: note: in expansion of macro 'ALTERNATIVE'
asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT)
^~~~~~~~~~~ make[2]: *** [kernel/bounds.s] Error 1 make[2]: Target '__build' not remade because of errors. make[1]: *** [prepare0] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [sub-make] Error 2
vim +54 arch/x86/include/asm/arch_hweight.h
d61931d8 Borislav Petkov 2010-03-05 38 static inline unsigned int __arch_hweight8(unsigned int w)
d61931d8 Borislav Petkov 2010-03-05 39 {
d61931d8 Borislav Petkov 2010-03-05 40 return __arch_hweight32(w & 0xff);
d61931d8 Borislav Petkov 2010-03-05 41 }
d61931d8 Borislav Petkov 2010-03-05 42
d14edb16 Denys Vlasenko 2015-08-04 43 #ifdef CONFIG_X86_32
d61931d8 Borislav Petkov 2010-03-05 44 static inline unsigned long __arch_hweight64(__u64 w)
d61931d8 Borislav Petkov 2010-03-05 45 {
d61931d8 Borislav Petkov 2010-03-05 46 return __arch_hweight32((u32)w) +
d61931d8 Borislav Petkov 2010-03-05 47 __arch_hweight32((u32)(w >> 32));
d14edb16 Denys Vlasenko 2015-08-04 48 }
d61931d8 Borislav Petkov 2010-03-05 49 #else
d14edb16 Denys Vlasenko 2015-08-04 50 static __always_inline unsigned long __arch_hweight64(__u64 w)
d14edb16 Denys Vlasenko 2015-08-04 51 {
f5967101 Borislav Petkov 2016-05-30 52 unsigned long res;
d14edb16 Denys Vlasenko 2015-08-04 53
c59bd568 H. Peter Anvin 2010-05-17 @54 asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT)
d61931d8 Borislav Petkov 2010-03-05 55 : "="REG_OUT (res)
d61931d8 Borislav Petkov 2010-03-05 56 : REG_IN (w));
d61931d8 Borislav Petkov 2010-03-05 57
d61931d8 Borislav Petkov 2010-03-05 58 return res;
d61931d8 Borislav Petkov 2010-03-05 59 }
d14edb16 Denys Vlasenko 2015-08-04 60 #endif /* CONFIG_X86_32 */
d61931d8 Borislav Petkov 2010-03-05 61
d61931d8 Borislav Petkov 2010-03-05 62 #endif:::::: The code at line 54 was first introduced by commit
:::::: c59bd5688299cddb71183e156e7a3c1409b90df2 x86, hweight: Use a 32-bit popcnt for __arch_hweight32()
:::::: TO: H. Peter Anvin <[email protected]>
:::::: CC: H. Peter Anvin <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build boturl: https://github.com/0day-ci/linux/commits/Tycho-Andersen/kconfig-always-use-user-input-symbols/20170522-143552 config: x86_64-allyesdebian (attached as .config) compiler: gcc-6 (Debian 6.2.0-3)…
Hi Tycho,
[auto build test ERROR on linus/master]
[also build test ERROR on v4.12-rc2 next-20170522]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Tycho-Andersen/kconfig-always-use-user-input-symbols/20170522-143552
config: x86_64-allyesdebian (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 All errors (new ones prefixed by >>):
>> kernel/trace/trace_functions.c:265:2: error: unknown field 'selftest' specified in initializer
.selftest = trace_selftest_startup_function,
^
>> kernel/trace/trace_functions.c:265:14: error: 'trace_selftest_startup_function' undeclared here (not in a function)
.selftest = trace_selftest_startup_function,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
>> kernel/trace/trace_irqsoff.c:696:2: error: unknown field 'selftest' specified in initializer
.selftest = trace_selftest_startup_irqsoff,
^
>> kernel/trace/trace_irqsoff.c:696:17: error: 'trace_selftest_startup_irqsoff' undeclared here (not in a function)
.selftest = trace_selftest_startup_irqsoff,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
>> kernel/trace/trace_sched_wakeup.c:761:2: error: unknown field 'selftest' specified in initializer
.selftest = trace_selftest_startup_wakeup,
^
>> kernel/trace/trace_sched_wakeup.c:761:17: error: 'trace_selftest_startup_wakeup' undeclared here (not in a function) .selftest = trace_selftest_startup_wakeup,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/trace_sched_wakeup.c:781:2: error: unknown field 'selftest' specified in initializer
.selftest = trace_selftest_startup_wakeup,
^
kernel/trace/trace_sched_wakeup.c:801:2: error: unknown field 'selftest' specified in initializer
.selftest = trace_selftest_startup_wakeup,
^
--
>> kernel/trace/trace_nop.c:93:2: error: unknown field 'selftest' specified in initializer
.selftest = trace_selftest_startup_nop,
^
>> kernel/trace/trace_nop.c:93:14: error: 'trace_selftest_startup_nop' undeclared here (not in a function)
.selftest = trace_selftest_startup_nop,
^~~~~~~~~~~~~~~~~~~~~~~~~~
--
>> kernel/trace/trace_functions_graph.c:1487:2: error: unknown field 'selftest' specified in initializer
.selftest = trace_selftest_startup_function_graph,
^
>> kernel/trace/trace_functions_graph.c:1487:14: error: 'trace_selftest_startup_function_graph' undeclared here (not in a function) .selftest = trace_selftest_startup_function_graph,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +/selftest +265 kernel/trace/trace_functions.c
f555f1231 Anton Vorontsov 2012-07-09 249 return -EINVAL;
536149910 Steven Rostedt 2009-01-15 250 }
536149910 Steven Rostedt 2009-01-15 251
f555f1231 Anton Vorontsov 2012-07-09 252 return 0;
536149910 Steven Rostedt 2009-01-15 253 }
536149910 Steven Rostedt 2009-01-15 254
8f7689933 Steven Rostedt (Red Hat 2013-07-18 255) static struct tracer function_trace __tracer_data =
1b29b0188 Steven Rostedt 2008-05-12 256 {
3ce83aea8 Steven Rostedt 2008-10-06 257 .name = "function",
1b29b0188 Steven Rostedt 2008-05-12 258 .init = function_trace_init,
1b29b0188 Steven Rostedt 2008-05-12 259 .reset = function_trace_reset,
9036990d4 Steven Rostedt 2008-11-05 260 .start = function_trace_start,
536149910 Steven Rostedt 2009-01-15 261 .flags = &func_flags,
536149910 Steven Rostedt 2009-01-15 262 .set_flag = func_set_flag,
f20a58062 Steven Rostedt (Red Hat 2013-11-07 263) .allow_instances = true,
60a11774b Steven Rostedt 2008-05-12 264 #ifdef CONFIG_FTRACE_SELFTEST
60a11774b Steven Rostedt 2008-05-12 @265 .selftest = trace_selftest_startup_function,
60a11774b Steven Rostedt 2008-05-12 266 #endif
1b29b0188 Steven Rostedt 2008-05-12 267 };
1b29b0188 Steven Rostedt 2008-05-12 268
23b4ff3aa Steven Rostedt 2009-02-14 269 #ifdef CONFIG_DYNAMIC_FTRACE
fe014e24b Steven Rostedt (VMware 2017-04-03 270) static void update_traceon_count(struct ftrace_probe_ops *ops,
2290f2c58 Steven Rostedt (VMware 2017-04-20 271) unsigned long ip,
2290f2c58 Steven Rostedt (VMware 2017-04-20 272) struct trace_array *tr, bool on,
6e4443199 Steven Rostedt (VMware 2017-04-19 273) void *data):::::: The code at line 265 was first introduced by commit :::::: 60a11774b38fef1ab90b18c5353bd1c7c4d311c8 ftrace: add self-tests
:::::: TO: Steven Rostedt <[email protected]> :::::: CC: Thomas Gleixner <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation