public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kconfig: always use user input symbols
@ 2017-05-19 15:08 Tycho Andersen
  2017-05-19 17:29 ` Geert Uytterhoeven
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Tycho Andersen @ 2017-05-19 15:08 UTC (permalink / raw)
  To: Yann E . MORIN; +Cc: linux-kbuild, linux-kernel, Tycho Andersen, Roman Zippel

...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.

Signed-off-by: Tycho Andersen <tycho@docker.com>
CC: Roman Zippel <zippel@linux-m68k.org>
---
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(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 297b079..3537090 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -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:
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 20136ff..27fca39 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -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);
-- 
2.9.3

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

* Re: [PATCH] kconfig: always use user input symbols
  2017-05-19 15:08 [PATCH] kconfig: always use user input symbols Tycho Andersen
@ 2017-05-19 17:29 ` Geert Uytterhoeven
  2017-05-19 18:09   ` Tycho Andersen
  2017-05-22  6:53 ` kbuild test robot
  2017-05-22  7:48 ` kbuild test robot
  2 siblings, 1 reply; 5+ messages in thread
From: Geert Uytterhoeven @ 2017-05-19 17:29 UTC (permalink / raw)
  To: Tycho Andersen
  Cc: Yann E . MORIN, linux-kbuild, linux-kernel@vger.kernel.org,
	Roman Zippel

Hi Tycho,

On Fri, May 19, 2017 at 5:08 PM, Tycho Andersen <tycho@docker.com> wrote:
> ...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.

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 -- geert@linux-m68k.org

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

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

* Re: [PATCH] kconfig: always use user input symbols
  2017-05-19 17:29 ` Geert Uytterhoeven
@ 2017-05-19 18:09   ` Tycho Andersen
  0 siblings, 0 replies; 5+ messages in thread
From: Tycho Andersen @ 2017-05-19 18:09 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Yann E . MORIN, linux-kbuild, linux-kernel@vger.kernel.org,
	Roman Zippel

Hi Geert,

On Fri, May 19, 2017 at 07:29:05PM +0200, Geert Uytterhoeven wrote:
> Hi Tycho,
> 
> On Fri, May 19, 2017 at 5:08 PM, Tycho Andersen <tycho@docker.com> wrote:
> > ...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.
> 
> 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

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

* Re: [PATCH] kconfig: always use user input symbols
  2017-05-19 15:08 [PATCH] kconfig: always use user input symbols Tycho Andersen
  2017-05-19 17:29 ` Geert Uytterhoeven
@ 2017-05-22  6:53 ` kbuild test robot
  2017-05-22  7:48 ` kbuild test robot
  2 siblings, 0 replies; 5+ messages in thread
From: kbuild test robot @ 2017-05-22  6:53 UTC (permalink / raw)
  To: Tycho Andersen
  Cc: kbuild-all, Yann E . MORIN, linux-kbuild, linux-kernel,
	Tycho Andersen, Roman Zippel

[-- Attachment #1: Type: text/plain, Size: 3882 bytes --]

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 <hpa@linux.intel.com>
:::::: CC: H. Peter Anvin <hpa@linux.intel.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 73686 bytes --]

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

* Re: [PATCH] kconfig: always use user input symbols
  2017-05-19 15:08 [PATCH] kconfig: always use user input symbols Tycho Andersen
  2017-05-19 17:29 ` Geert Uytterhoeven
  2017-05-22  6:53 ` kbuild test robot
@ 2017-05-22  7:48 ` kbuild test robot
  2 siblings, 0 replies; 5+ messages in thread
From: kbuild test robot @ 2017-05-22  7:48 UTC (permalink / raw)
  To: Tycho Andersen
  Cc: kbuild-all, Yann E . MORIN, linux-kbuild, linux-kernel,
	Tycho Andersen, Roman Zippel

[-- Attachment #1: Type: text/plain, Size: 5044 bytes --]

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 <srostedt@redhat.com>
:::::: CC: Thomas Gleixner <tglx@linutronix.de>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 43551 bytes --]

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

end of thread, other threads:[~2017-05-22  7:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-19 15:08 [PATCH] kconfig: always use user input symbols Tycho Andersen
2017-05-19 17:29 ` Geert Uytterhoeven
2017-05-19 18:09   ` Tycho Andersen
2017-05-22  6:53 ` kbuild test robot
2017-05-22  7:48 ` kbuild test robot

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