Skip to contentSkip to conversation

gcc-plugins: Disable GCC_PLUGIN_CYC_COMPLEXITY for s390

PATCH NAK Guenter Roeck 4 participants 11 messages Feb 21, 2021 – Feb 24, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gcc-plugins: Disable GCC_PLUGIN_CYC_COMPLEXITY for s390

Commit 334ef6ed06fa ("init/Kconfig: make COMPILE_TEST depend on !S390") disabled COMPILE_TEST for s390. At the same time, "make allmodconfig/allyesconfig" for s390 is still supported. However, it generates thousands of compiler messages such as the following, making it highly impractical to run.

Cyclomatic Complexity 1 scripts/mod/devicetable-offsets.c:main Cyclomatic Complexity 1 scripts/mod/devicetable-offsets.c:_GLOBAL__sub_I_00100_0_main

Since GCC_PLUGIN_CYC_COMPLEXITY is primarily used for testing, disable it when building s390 images.

Cc Arnd Bergmann <[email protected]>
Cc Heiko Carstens <[email protected]>
Fixes 334ef6ed06fa ("init/Kconfig: make COMPILE_TEST depend on !S390")
---
 scripts/gcc-plugins/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/gcc-plugins/Kconfig +1 -1
index ab9eb4cbe33a..5e9bb500f443 100644
@@ -21,7 +21,7 @@ if GCC_PLUGINS
 
 config GCC_PLUGIN_CYC_COMPLEXITY
 	bool "Compute the cyclomatic complexity of a function" if EXPERT
-	depends on !COMPILE_TEST	# too noisy
+	depends on !COMPILE_TEST && !S390	# too noisy
 	help
 	  The complexity M of a function's control flow graph is defined as:
 	   M = E - N + 2P
Signature · 1 line
2.17.1
#1 lore raw
Quoted 24 lines · Guenter Roeck

Commit 334ef6ed06fa ("init/Kconfig: make COMPILE_TEST depend on !S390") disabled COMPILE_TEST for s390. At the same time, "make allmodconfig/allyesconfig" for s390 is still supported. However, it generates thousands of compiler messages such as the following, making it highly impractical to run.

Cyclomatic Complexity 1 scripts/mod/devicetable-offsets.c:main Cyclomatic Complexity 1 scripts/mod/devicetable-offsets.c:_GLOBAL__sub_I_00100_0_main

Since GCC_PLUGIN_CYC_COMPLEXITY is primarily used for testing, disable it when building s390 images.

Cc Arnd Bergmann <[email protected]>
Cc Heiko Carstens <[email protected]>
Fixes 334ef6ed06fa ("init/Kconfig: make COMPILE_TEST depend on !S390")
---
 scripts/gcc-plugins/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/gcc-plugins/Kconfig +0 -0
index ab9eb4cbe33a..5e9bb500f443 100644

scripts/gcc-plugins/Kconfig if GCC_PLUGINS · line 24

Quoted 5 lines
scripts/gcc-plugins/Kconfig +1 -1
@@ -21,7 +21,7 @@ if GCC_PLUGINS
 
 config GCC_PLUGIN_CYC_COMPLEXITY
 	bool "Compute the cyclomatic complexity of a function" if EXPERT
-	depends on !COMPILE_TEST	# too noisy
+	depends on !COMPILE_TEST && !S390	# too noisy

I don't see a reason to disable this in general for s390. COMPILE_TEST was only disabled for s390 because a lot of irrelevant configs didn't compile and it would cause a lot of unnecessary work to fix that.

However the !COMPILE_TEST dependency here looks more like it was misused in lack of a possibility to detect if the config was generated with allyesconfig/allmodconfig. Maybe that could be added somehow to Kconfig?

#2 lore raw
Quoted 35 lines · Heiko Carstens
Quoted 24 lines · Guenter Roeck

Commit 334ef6ed06fa ("init/Kconfig: make COMPILE_TEST depend on !S390") disabled COMPILE_TEST for s390. At the same time, "make allmodconfig/allyesconfig" for s390 is still supported. However, it generates thousands of compiler messages such as the following, making it highly impractical to run.

Cyclomatic Complexity 1 scripts/mod/devicetable-offsets.c:main Cyclomatic Complexity 1 scripts/mod/devicetable-offsets.c:_GLOBAL__sub_I_00100_0_main

Since GCC_PLUGIN_CYC_COMPLEXITY is primarily used for testing, disable it when building s390 images.

Cc Arnd Bergmann <[email protected]>
Cc Heiko Carstens <[email protected]>
Fixes 334ef6ed06fa ("init/Kconfig: make COMPILE_TEST depend on !S390")
---
 scripts/gcc-plugins/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/gcc-plugins/Kconfig +0 -0
index ab9eb4cbe33a..5e9bb500f443 100644

scripts/gcc-plugins/Kconfig if GCC_PLUGINS · line 24

Quoted 5 lines
scripts/gcc-plugins/Kconfig +1 -1
@@ -21,7 +21,7 @@ if GCC_PLUGINS
 
 config GCC_PLUGIN_CYC_COMPLEXITY
 	bool "Compute the cyclomatic complexity of a function" if EXPERT
-	depends on !COMPILE_TEST	# too noisy
+	depends on !COMPILE_TEST && !S390	# too noisy

I don't see a reason to disable this in general for s390. COMPILE_TEST was only disabled for s390 because a lot of irrelevant configs didn't compile and it would cause a lot of unnecessary work to fix that.

Quoted 5 lines

However the !COMPILE_TEST dependency here looks more like it was misused in lack of a possibility to detect if the config was generated with allyesconfig/allmodconfig. Maybe that could be added somehow to Kconfig?

That is what COMPILE_TEST used to be for. Not setting it for s390 doesn't just cause this config to be disabled. Lots of other compile tests for s390 are now disabled as well, and code which should be disabled is now enabled. Looking at it, I'd be a bit surprised if allmodconfig/ allyesconfig with COMPILE_TEST=y still builds for s390.

I agree that COMPILE_TEST it is being misused. However, I think what you'd be looking for is something like COMPILE_TEST_RANDCONFIG. FWIW, in my opinion, randconfig should not enable COMPILE_TEST to start with. But that is a different discussion.

Anyway, I can disable GCC_PLUGIN_CYC_COMPLEXITY manually in my own build tests, so this isn't that much of a problem for me, so feel free to drop this patch.

Guenter

#3 lore raw
Quoted 54 lines · Guenter Roeck
Quoted 35 lines · Heiko Carstens
Quoted 24 lines · Guenter Roeck

Commit 334ef6ed06fa ("init/Kconfig: make COMPILE_TEST depend on !S390") disabled COMPILE_TEST for s390. At the same time, "make allmodconfig/allyesconfig" for s390 is still supported. However, it generates thousands of compiler messages such as the following, making it highly impractical to run.

Cyclomatic Complexity 1 scripts/mod/devicetable-offsets.c:main Cyclomatic Complexity 1 scripts/mod/devicetable-offsets.c:_GLOBAL__sub_I_00100_0_main

Since GCC_PLUGIN_CYC_COMPLEXITY is primarily used for testing, disable it when building s390 images.

Cc Arnd Bergmann <[email protected]>
Cc Heiko Carstens <[email protected]>
Fixes 334ef6ed06fa ("init/Kconfig: make COMPILE_TEST depend on !S390")
---
 scripts/gcc-plugins/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/gcc-plugins/Kconfig +0 -0
index ab9eb4cbe33a..5e9bb500f443 100644

scripts/gcc-plugins/Kconfig if GCC_PLUGINS · line 24

Quoted 5 lines
scripts/gcc-plugins/Kconfig +1 -1
@@ -21,7 +21,7 @@ if GCC_PLUGINS
 
 config GCC_PLUGIN_CYC_COMPLEXITY
     bool "Compute the cyclomatic complexity of a function" if EXPERT
-    depends on !COMPILE_TEST        # too noisy
+    depends on !COMPILE_TEST && !S390       # too noisy

I don't see a reason to disable this in general for s390. COMPILE_TEST was only disabled for s390 because a lot of irrelevant configs didn't compile and it would cause a lot of unnecessary work to fix that.

Quoted 5 lines

However the !COMPILE_TEST dependency here looks more like it was misused in lack of a possibility to detect if the config was generated with allyesconfig/allmodconfig. Maybe that could be added somehow to Kconfig?

That is what COMPILE_TEST used to be for. Not setting it for s390 doesn't just cause this config to be disabled. Lots of other compile tests for s390 are now disabled as well, and code which should be disabled is now enabled. Looking at it, I'd be a bit surprised if allmodconfig/ allyesconfig with COMPILE_TEST=y still builds for s390.

I agree that COMPILE_TEST it is being misused. However, I think what you'd be looking for is something like COMPILE_TEST_RANDCONFIG. FWIW, in my opinion, randconfig should not enable COMPILE_TEST to start with. But that is a different discussion.

Quoted 5 lines

Anyway, I can disable GCC_PLUGIN_CYC_COMPLEXITY manually in my own build tests, so this isn't that much of a problem for me, so feel free to drop this patch.

Guenter

Maybe, we can add something like CONFIG_SUPPRESS_NOISY_TESTS, which is set to y by all{yes,mod}config.

This is self-documenting, so we do not need the '# too noisy' comment.

config SUPPRESS_NOISY_TESTS
bool "suppress noisy test"

config GCC_PLUGIN_CYC_COMPLEXITY
bool "Compute the cyclomatic complexity of a function" if EXPERT depends on !SUPPRESS_NOISY_TESTS

Signature · 2 lines
Best Regards
Masahiro Yamada
#4 lore raw
Quoted 69 lines · Masahiro Yamada
Quoted 54 lines · Guenter Roeck
Quoted 35 lines · Heiko Carstens
Quoted 24 lines · Guenter Roeck

Commit 334ef6ed06fa ("init/Kconfig: make COMPILE_TEST depend on !S390") disabled COMPILE_TEST for s390. At the same time, "make allmodconfig/allyesconfig" for s390 is still supported. However, it generates thousands of compiler messages such as the following, making it highly impractical to run.

Cyclomatic Complexity 1 scripts/mod/devicetable-offsets.c:main Cyclomatic Complexity 1 scripts/mod/devicetable-offsets.c:_GLOBAL__sub_I_00100_0_main

Since GCC_PLUGIN_CYC_COMPLEXITY is primarily used for testing, disable it when building s390 images.

Cc Arnd Bergmann <[email protected]>
Cc Heiko Carstens <[email protected]>
Fixes 334ef6ed06fa ("init/Kconfig: make COMPILE_TEST depend on !S390")
---
 scripts/gcc-plugins/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/gcc-plugins/Kconfig +0 -0
index ab9eb4cbe33a..5e9bb500f443 100644

scripts/gcc-plugins/Kconfig if GCC_PLUGINS · line 24

Quoted 5 lines
scripts/gcc-plugins/Kconfig +1 -1
@@ -21,7 +21,7 @@ if GCC_PLUGINS
 
 config GCC_PLUGIN_CYC_COMPLEXITY
     bool "Compute the cyclomatic complexity of a function" if EXPERT
-    depends on !COMPILE_TEST        # too noisy
+    depends on !COMPILE_TEST && !S390       # too noisy

I don't see a reason to disable this in general for s390. COMPILE_TEST was only disabled for s390 because a lot of irrelevant configs didn't compile and it would cause a lot of unnecessary work to fix that.

Quoted 5 lines

However the !COMPILE_TEST dependency here looks more like it was misused in lack of a possibility to detect if the config was generated with allyesconfig/allmodconfig. Maybe that could be added somehow to Kconfig?

That is what COMPILE_TEST used to be for. Not setting it for s390 doesn't just cause this config to be disabled. Lots of other compile tests for s390 are now disabled as well, and code which should be disabled is now enabled. Looking at it, I'd be a bit surprised if allmodconfig/ allyesconfig with COMPILE_TEST=y still builds for s390.

I agree that COMPILE_TEST it is being misused. However, I think what you'd be looking for is something like COMPILE_TEST_RANDCONFIG. FWIW, in my opinion, randconfig should not enable COMPILE_TEST to start with. But that is a different discussion.

Quoted 5 lines

Anyway, I can disable GCC_PLUGIN_CYC_COMPLEXITY manually in my own build tests, so this isn't that much of a problem for me, so feel free to drop this patch.

Guenter

Maybe, we can add something like CONFIG_SUPPRESS_NOISY_TESTS, which is set to y by all{yes,mod}config.

This is self-documenting, so we do not need the '# too noisy' comment.

Quoted 8 lines

config SUPPRESS_NOISY_TESTS
bool "suppress noisy test"

config GCC_PLUGIN_CYC_COMPLEXITY
bool "Compute the cyclomatic complexity of a function" if EXPERT depends on !SUPPRESS_NOISY_TESTS

Good idea. Downside would be that it won't solve the real problem for s390 (which is lack of allmodconfig/allyesconfig compile test coverage because COMPILE_TEST isn't set anymore), but that is a different problem anyway, and my original patch doesn't solve that either.

On the other side, if that flag would be set explicitly by all{yes,mod}config, it would really beg for being misused. We might then as well add a new flag that is explicitly associated with all{yes,mod}config, but not with randconfig.

Thanks,
Guenter

#5 lore raw
Quoted 16 lines · Guenter Roeck
Quoted 7 lines

Maybe, we can add something like CONFIG_SUPPRESS_NOISY_TESTS, which is set to y by all{yes,mod}config.

This is self-documenting, so we do not need the '# too noisy' comment.

Quoted 8 lines

config SUPPRESS_NOISY_TESTS
bool "suppress noisy test"

config GCC_PLUGIN_CYC_COMPLEXITY
bool "Compute the cyclomatic complexity of a function" if EXPERT depends on !SUPPRESS_NOISY_TESTS

Quoted 5 lines

Good idea. Downside would be that it won't solve the real problem for s390 (which is lack of allmodconfig/allyesconfig compile test coverage because COMPILE_TEST isn't set anymore), but that is a different problem anyway, and my original patch doesn't solve that either.

I tried to explain why we don't want to set COMPILE_TEST for s390 anymore. It overrides architecture dependencies in Kconfig, and lots of drivers do not set dependencies for HAS_IOMEM, HAS_DMA, and friends correctly.
This generates constantly fallout which is irrelevant for s390 and also for other architectures. It generates just work with close to zero benefit. For drivers which matter for s390 we still see those errors.

Quoted 4 lines

On the other side, if that flag would be set explicitly by all{yes,mod}config, it would really beg for being misused. We might then as well add a new flag that is explicitly associated with all{yes,mod}config, but not with randconfig.

I think that makes most sense, probably also have a flag that is set for randconfig.

#6 lore raw
Quoted 32 lines · Heiko Carstens
Quoted 16 lines · Guenter Roeck
Quoted 7 lines

Maybe, we can add something like CONFIG_SUPPRESS_NOISY_TESTS, which is set to y by all{yes,mod}config.

This is self-documenting, so we do not need the '# too noisy' comment.

Quoted 8 lines

config SUPPRESS_NOISY_TESTS
bool "suppress noisy test"

config GCC_PLUGIN_CYC_COMPLEXITY
bool "Compute the cyclomatic complexity of a function" if EXPERT depends on !SUPPRESS_NOISY_TESTS

Quoted 5 lines

Good idea. Downside would be that it won't solve the real problem for s390 (which is lack of allmodconfig/allyesconfig compile test coverage because COMPILE_TEST isn't set anymore), but that is a different problem anyway, and my original patch doesn't solve that either.

I tried to explain why we don't want to set COMPILE_TEST for s390 anymore. It overrides architecture dependencies in Kconfig, and lots of drivers do not set dependencies for HAS_IOMEM, HAS_DMA, and friends correctly.
This generates constantly fallout which is irrelevant for s390 and also for other architectures. It generates just work with close to zero benefit. For drivers which matter for s390 we still see those errors.

Quoted 7 lines
Quoted 4 lines

On the other side, if that flag would be set explicitly by all{yes,mod}config, it would really beg for being misused. We might then as well add a new flag that is explicitly associated with all{yes,mod}config, but not with randconfig.

I think that makes most sense, probably also have a flag that is set for randconfig.

Not sure what value such an option would have, and how it would be used. I would argue that randconfig should not set COMPILE_TEST to start with, since its purpose should be to test random valid configurations and not to compile test arbitrary (and in that case random) code. But that is a different question, and just my personal opinion.

Overall, the question is what kind of additional option you would find useful for s390. You make it clear that you don't want COMPILE_TEST. At the same time, you still want all{mod,yes}config, but presumably excluding options currently restricted by !COMPILE_TEST (such as DEBUG_INFO, BPF_PRELOAD, UBSAN_TRAP, GCC_PLUGIN_CYC_COMPLEXITY, and a few others). SUPPRESS_NOISY_TESTS would not cover that, but neither would RANDCONFIG (or whatever it would be called).

Guenter

#7 lore raw
Quoted 23 lines · Guenter Roeck
Quoted 9 lines

I tried to explain why we don't want to set COMPILE_TEST for s390 anymore. It overrides architecture dependencies in Kconfig, and lots of drivers do not set dependencies for HAS_IOMEM, HAS_DMA, and friends correctly.
This generates constantly fallout which is irrelevant for s390 and also for other architectures. It generates just work with close to zero benefit. For drivers which matter for s390 we still see those errors.

Quoted 7 lines
Quoted 4 lines

On the other side, if that flag would be set explicitly by all{yes,mod}config, it would really beg for being misused. We might then as well add a new flag that is explicitly associated with all{yes,mod}config, but not with randconfig.

I think that makes most sense, probably also have a flag that is set for randconfig.

Not sure what value such an option would have, and how it would be used. I would argue that randconfig should not set COMPILE_TEST to start with, since its purpose should be to test random valid configurations and not to compile test arbitrary (and in that case random) code. But that is a different question, and just my personal opinion.

Quoted 7 lines

Overall, the question is what kind of additional option you would find useful for s390. You make it clear that you don't want COMPILE_TEST. At the same time, you still want all{mod,yes}config, but presumably excluding options currently restricted by !COMPILE_TEST (such as DEBUG_INFO, BPF_PRELOAD, UBSAN_TRAP, GCC_PLUGIN_CYC_COMPLEXITY, and a few others). SUPPRESS_NOISY_TESTS would not cover that, but neither would RANDCONFIG (or whatever it would be called).

Well, if we would have e.g. RANDCONFIG, then we could probably revert 334ef6ed06fa ("init/Kconfig: make COMPILE_TEST depend on !S390") and instead let COMPILE_TEST depend on !RANDCONFIG.
I think this _could_ solve all common problems we currently see.

And it would also do what you suggested.

#8 lore raw
Quoted 6 lines · Heiko Carstens

Well, if we would have e.g. RANDCONFIG, then we could probably revert 334ef6ed06fa ("init/Kconfig: make COMPILE_TEST depend on !S390") and instead let COMPILE_TEST depend on !RANDCONFIG.
I think this _could_ solve all common problems we currently see.

And it would also do what you suggested.

I've wanted similar (e.g. for some UBSAN options that would go weird under RANDCONFIG). :)

Signature · 1 line
Kees Cook
#9 lore raw
In reply to Heiko Carstens
Quoted 32 lines · Heiko Carstens
Quoted 23 lines · Guenter Roeck
Quoted 9 lines

I tried to explain why we don't want to set COMPILE_TEST for s390 anymore. It overrides architecture dependencies in Kconfig, and lots of drivers do not set dependencies for HAS_IOMEM, HAS_DMA, and friends correctly.
This generates constantly fallout which is irrelevant for s390 and also for other architectures. It generates just work with close to zero benefit. For drivers which matter for s390 we still see those errors.

Quoted 7 lines
Quoted 4 lines

On the other side, if that flag would be set explicitly by all{yes,mod}config, it would really beg for being misused. We might then as well add a new flag that is explicitly associated with all{yes,mod}config, but not with randconfig.

I think that makes most sense, probably also have a flag that is set for randconfig.

Not sure what value such an option would have, and how it would be used. I would argue that randconfig should not set COMPILE_TEST to start with, since its purpose should be to test random valid configurations and not to compile test arbitrary (and in that case random) code. But that is a different question, and just my personal opinion.

Quoted 7 lines

Overall, the question is what kind of additional option you would find useful for s390. You make it clear that you don't want COMPILE_TEST. At the same time, you still want all{mod,yes}config, but presumably excluding options currently restricted by !COMPILE_TEST (such as DEBUG_INFO, BPF_PRELOAD, UBSAN_TRAP, GCC_PLUGIN_CYC_COMPLEXITY, and a few others). SUPPRESS_NOISY_TESTS would not cover that, but neither would RANDCONFIG (or whatever it would be called).

Quoted 6 lines

Well, if we would have e.g. RANDCONFIG, then we could probably revert 334ef6ed06fa ("init/Kconfig: make COMPILE_TEST depend on !S390") and instead let COMPILE_TEST depend on !RANDCONFIG.
I think this _could_ solve all common problems we currently see.

And it would also do what you suggested.

Sounds good.

Question is how one would set such a flag. The code in scripts/kconfig/conf.c doesn't really set COMPILE_TEST in conjunction with randconfig; that is just as random as all other configuration flags. Would something like the patch below be acceptable ?

Thanks,
Guenter

---
From 301dc1746b259afce02c104ebbf3f0c37189ae4a Mon Sep 17 00:00:00 2001
From: Guenter Roeck <[email protected]>
Date: Tue, 23 Feb 2021 17:21:51 -0800
Subject: [PATCH] kconfig: Introduce RANDCONFIG

"make randconfig" is intended to be used to generate random valid configurations. It is supposed to verify if configuration dependencies are valid and compile. It is not supposed to be used as replacement for all{mod,yes}config.

However, that is not currently the case. "make randconfig" treats all configurations randomly. This means that "COMPILE_TEST" will be enabled randomly. This defeats the purpose of "make randconfig"

To solve the problem, introduce a RANDCONFIG configuration option and set it for all "randconfig" configurations. Disable COMPILE_TEST whenever RANDCONFIG is enabled.

---
 init/Kconfig               | 12 ++++++++++++
 scripts/kconfig/confdata.c | 15 ++++++++++++---
 scripts/kconfig/expr.h     |  1 +
 scripts/kconfig/lexer.l    |  1 +
 scripts/kconfig/lkc.h      |  1 +
 scripts/kconfig/menu.c     |  5 +++++
 scripts/kconfig/parser.y   |  6 ++++++
 7 files changed, 38 insertions(+), 3 deletions(-)
init/Kconfig +12 -0
index ba8bd5256980..a85099c5e383 100644
@@ -111,9 +111,21 @@ config INIT_ENV_ARG_LIMIT
 	  Maximum of each of the number of arguments and environment
 	  variables passed to init from the kernel command line.
 
+config RANDCONFIG
+	bool "Compile random configurations"
+	option randconfig_y
+	help
+	  This option indicates that the configuration is random and used to
+	  test if configuration dependencies are valid and complete.
+	  Resulting images are not expected to be bootable on real hardware.
+
+	  If you are a developer and want to build test random configurations,
+	  say Y here. If you are a user/distributor, say N.
+
 config COMPILE_TEST
 	bool "Compile also drivers which will not load"
 	depends on !UML && !S390
+	depends on !RANDCONFIG
 	default n
 	help
 	  Some drivers can be compiled on a different platform than they are
scripts/kconfig/confdata.c +12 -3
index 2568dbe16ed6..0b36cc2f702b 100644
@@ -1254,10 +1254,16 @@ bool conf_set_all_new_symbols(enum conf_def_mode mode)
 			has_changed = true;
 			switch (mode) {
 			case def_yes:
-				sym->def[S_DEF_USER].tri = yes;
+				if (sym->flags & SYMBOL_RANDCONFIG_Y)
+					sym->def[S_DEF_USER].tri = no;
+				else
+					sym->def[S_DEF_USER].tri = yes;
 				break;
 			case def_mod:
-				sym->def[S_DEF_USER].tri = mod;
+				if (sym->flags & SYMBOL_RANDCONFIG_Y)
+					sym->def[S_DEF_USER].tri = no;
+				else
+					sym->def[S_DEF_USER].tri = mod;
 				break;
 			case def_no:
 				if (sym->flags & SYMBOL_ALLNOCONFIG_Y)
@@ -1267,7 +1273,10 @@ bool conf_set_all_new_symbols(enum conf_def_mode mode)
 				break;
 			case def_random:
 				sym->def[S_DEF_USER].tri = no;
-				cnt = rand() % 100;
+				if (sym->flags & SYMBOL_RANDCONFIG_Y)
+					cnt = -1;
+				else
+					cnt = rand() % 100;
 				if (sym->type == S_TRISTATE) {
 					if (cnt < pty)
 						sym->def[S_DEF_USER].tri = yes;
scripts/kconfig/expr.h +1 -0
index 5c3443692f34..70f4acce2b7b 100644
@@ -158,6 +158,7 @@ struct symbol {
 
 /* Set symbol to y if allnoconfig; used for symbols that hide others */
 #define SYMBOL_ALLNOCONFIG_Y 0x200000
+#define SYMBOL_RANDCONFIG_Y  0x400000
 
 #define SYMBOL_MAXLENGTH	256
 #define SYMBOL_HASHSIZE		9973
scripts/kconfig/lexer.l +1 -0
index 9c22cb554673..fd9cd3622ea7 100644
@@ -92,6 +92,7 @@ n	[A-Za-z0-9_-]
 \\\n			/* escaped new line */
 \n			return T_EOL;
 "allnoconfig_y"		return T_ALLNOCONFIG_Y;
+"randconfig_y"		return T_RANDCONFIG_Y;
 "bool"			return T_BOOL;
 "choice"		return T_CHOICE;
 "comment"		return T_COMMENT;
scripts/kconfig/lkc.h +1 -0
index bee2413bda63..871a05f887f0 100644
@@ -110,6 +110,7 @@ void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
 void menu_add_option_modules(void);
 void menu_add_option_defconfig_list(void);
 void menu_add_option_allnoconfig_y(void);
+void menu_add_option_randconfig_y(void);
 void menu_finalize(struct menu *parent);
 void menu_set_type(int type);
 
scripts/kconfig/menu.c +5 -0
index a5fbd6ccc006..5ec3a26566b8 100644
@@ -233,6 +233,11 @@ void menu_add_option_allnoconfig_y(void)
 	current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y;
 }
 
+void menu_add_option_randconfig_y(void)
+{
+	current_entry->sym->flags |= SYMBOL_RANDCONFIG_Y;
+}
+
 static int menu_validate_number(struct symbol *sym, struct symbol *sym2)
 {
 	return sym2->type == S_INT || sym2->type == S_HEX ||
scripts/kconfig/parser.y +6 -0
index 190f1117f35a..335ce0554c84 100644
@@ -46,6 +46,7 @@ static struct menu *current_menu, *current_entry;
 %token <string> T_WORD
 %token <string> T_WORD_QUOTE
 %token T_ALLNOCONFIG_Y
+%token T_RANDCONFIG_Y
 %token T_BOOL
 %token T_CHOICE
 %token T_CLOSE_PAREN
@@ -233,6 +234,11 @@ config_option: T_OPTION T_ALLNOCONFIG_Y T_EOL
 	menu_add_option_allnoconfig_y();
 };
 
+config_option: T_OPTION T_RANDCONFIG_Y T_EOL
+{
+	menu_add_option_randconfig_y();
+};
+
 /* choice entry */
 
 choice: T_CHOICE word_opt T_EOL
Signature · 1 line
2.17.1
#10 lore raw
Quoted 39 lines · Guenter Roeck
Quoted 37 lines · Heiko Carstens
Quoted 23 lines · Guenter Roeck
Quoted 9 lines

I tried to explain why we don't want to set COMPILE_TEST for s390 anymore. It overrides architecture dependencies in Kconfig, and lots of drivers do not set dependencies for HAS_IOMEM, HAS_DMA, and friends correctly.
This generates constantly fallout which is irrelevant for s390 and also for other architectures. It generates just work with close to zero benefit. For drivers which matter for s390 we still see those errors.

Quoted 7 lines
Quoted 4 lines

On the other side, if that flag would be set explicitly by all{yes,mod}config, it would really beg for being misused. We might then as well add a new flag that is explicitly associated with all{yes,mod}config, but not with randconfig.

I think that makes most sense, probably also have a flag that is set for randconfig.

Not sure what value such an option would have, and how it would be used. I would argue that randconfig should not set COMPILE_TEST to start with, since its purpose should be to test random valid configurations and not to compile test arbitrary (and in that case random) code. But that is a different question, and just my personal opinion.

Quoted 7 lines

Overall, the question is what kind of additional option you would find useful for s390. You make it clear that you don't want COMPILE_TEST. At the same time, you still want all{mod,yes}config, but presumably excluding options currently restricted by !COMPILE_TEST (such as DEBUG_INFO, BPF_PRELOAD, UBSAN_TRAP, GCC_PLUGIN_CYC_COMPLEXITY, and a few others). SUPPRESS_NOISY_TESTS would not cover that, but neither would RANDCONFIG (or whatever it would be called).

Well, if we would have e.g. RANDCONFIG, then we could probably revert 334ef6ed06fa ("init/Kconfig: make COMPILE_TEST depend on !S390") and instead let COMPILE_TEST depend on !RANDCONFIG.
I think this _could_ solve all common problems we currently see.

Quoted 8 lines
Quoted 1 line

And it would also do what you suggested.

Sounds good.

Question is how one would set such a flag. The code in scripts/kconfig/conf.c doesn't really set COMPILE_TEST in conjunction with randconfig; that is just as random as all other configuration flags. Would something like the patch below be acceptable ?

NACK.

Such a stupid option is what I really do not want to merge. Even allnoconfig_y is also a horrible mistake, and I have a plan to kill it.

Only the sensible one is 'option modules'.
The others are really bad hacks.

Quoted 9 lines

Thanks,
Guenter

---
From 301dc1746b259afce02c104ebbf3f0c37189ae4a Mon Sep 17 00:00:00 2001
From: Guenter Roeck <[email protected]>
Date: Tue, 23 Feb 2021 17:21:51 -0800
Subject: [PATCH] kconfig: Introduce RANDCONFIG

Quoted 4 lines

"make randconfig" is intended to be used to generate random valid configurations. It is supposed to verify if configuration dependencies are valid and compile. It is not supposed to be used as replacement for all{mod,yes}config.

This is just your opinion.
Each sentence should start with "I think".

Quoted 3 lines

However, that is not currently the case. "make randconfig" treats all configurations randomly.

Yes, this is what randconfig should do.

Quoted 2 lines

This means that "COMPILE_TEST" will be enabled randomly. This defeats the purpose of "make randconfig"

If you want to set particular CONFIG option(s) to a fixed value, KCONFIG_ALLCONFIG is supported.

See Documentation/kbuild/kconfig.rst

Quoted 156 lines

To solve the problem, introduce a RANDCONFIG configuration option and set it for all "randconfig" configurations. Disable COMPILE_TEST whenever RANDCONFIG is enabled.

---
 init/Kconfig               | 12 ++++++++++++
 scripts/kconfig/confdata.c | 15 ++++++++++++---
 scripts/kconfig/expr.h     |  1 +
 scripts/kconfig/lexer.l    |  1 +
 scripts/kconfig/lkc.h      |  1 +
 scripts/kconfig/menu.c     |  5 +++++
 scripts/kconfig/parser.y   |  6 ++++++
 7 files changed, 38 insertions(+), 3 deletions(-)
init/Kconfig +12 -0
index ba8bd5256980..a85099c5e383 100644
@@ -111,9 +111,21 @@ config INIT_ENV_ARG_LIMIT
          Maximum of each of the number of arguments and environment
          variables passed to init from the kernel command line.
 
+config RANDCONFIG
+       bool "Compile random configurations"
+       option randconfig_y
+       help
+         This option indicates that the configuration is random and used to
+         test if configuration dependencies are valid and complete.
+         Resulting images are not expected to be bootable on real hardware.
+
+         If you are a developer and want to build test random configurations,
+         say Y here. If you are a user/distributor, say N.
+
 config COMPILE_TEST
        bool "Compile also drivers which will not load"
        depends on !UML && !S390
+       depends on !RANDCONFIG
        default n
        help
          Some drivers can be compiled on a different platform than they are
scripts/kconfig/confdata.c +12 -3
index 2568dbe16ed6..0b36cc2f702b 100644
@@ -1254,10 +1254,16 @@ bool conf_set_all_new_symbols(enum conf_def_mode mode)
                        has_changed = true;
                        switch (mode) {
                        case def_yes:
-                               sym->def[S_DEF_USER].tri = yes;
+                               if (sym->flags & SYMBOL_RANDCONFIG_Y)
+                                       sym->def[S_DEF_USER].tri = no;
+                               else
+                                       sym->def[S_DEF_USER].tri = yes;
                                break;
                        case def_mod:
-                               sym->def[S_DEF_USER].tri = mod;
+                               if (sym->flags & SYMBOL_RANDCONFIG_Y)
+                                       sym->def[S_DEF_USER].tri = no;
+                               else
+                                       sym->def[S_DEF_USER].tri = mod;
                                break;
                        case def_no:
                                if (sym->flags & SYMBOL_ALLNOCONFIG_Y)
@@ -1267,7 +1273,10 @@ bool conf_set_all_new_symbols(enum conf_def_mode mode)
                                break;
                        case def_random:
                                sym->def[S_DEF_USER].tri = no;
-                               cnt = rand() % 100;
+                               if (sym->flags & SYMBOL_RANDCONFIG_Y)
+                                       cnt = -1;
+                               else
+                                       cnt = rand() % 100;
                                if (sym->type == S_TRISTATE) {
                                        if (cnt < pty)
                                                sym->def[S_DEF_USER].tri = yes;
scripts/kconfig/expr.h +1 -0
index 5c3443692f34..70f4acce2b7b 100644
@@ -158,6 +158,7 @@ struct symbol {
 
 /* Set symbol to y if allnoconfig; used for symbols that hide others */
 #define SYMBOL_ALLNOCONFIG_Y 0x200000
+#define SYMBOL_RANDCONFIG_Y  0x400000
 
 #define SYMBOL_MAXLENGTH       256
 #define SYMBOL_HASHSIZE                9973
scripts/kconfig/lexer.l +1 -0
index 9c22cb554673..fd9cd3622ea7 100644
@@ -92,6 +92,7 @@ n     [A-Za-z0-9_-]
 \\\n                   /* escaped new line */
 \n                     return T_EOL;
 "allnoconfig_y"                return T_ALLNOCONFIG_Y;
+"randconfig_y"         return T_RANDCONFIG_Y;
 "bool"                 return T_BOOL;
 "choice"               return T_CHOICE;
 "comment"              return T_COMMENT;
scripts/kconfig/lkc.h +1 -0
index bee2413bda63..871a05f887f0 100644
@@ -110,6 +110,7 @@ void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
 void menu_add_option_modules(void);
 void menu_add_option_defconfig_list(void);
 void menu_add_option_allnoconfig_y(void);
+void menu_add_option_randconfig_y(void);
 void menu_finalize(struct menu *parent);
 void menu_set_type(int type);
 
scripts/kconfig/menu.c +5 -0
index a5fbd6ccc006..5ec3a26566b8 100644
@@ -233,6 +233,11 @@ void menu_add_option_allnoconfig_y(void)
        current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y;
 }
 
+void menu_add_option_randconfig_y(void)
+{
+       current_entry->sym->flags |= SYMBOL_RANDCONFIG_Y;
+}
+
 static int menu_validate_number(struct symbol *sym, struct symbol *sym2)
 {
        return sym2->type == S_INT || sym2->type == S_HEX ||
scripts/kconfig/parser.y +6 -1
index 190f1117f35a..335ce0554c84 100644
@@ -46,6 +46,7 @@ static struct menu *current_menu, *current_entry;
 %token <string> T_WORD
 %token <string> T_WORD_QUOTE
 %token T_ALLNOCONFIG_Y
+%token T_RANDCONFIG_Y
 %token T_BOOL
 %token T_CHOICE
 %token T_CLOSE_PAREN
@@ -233,6 +234,11 @@ config_option: T_OPTION T_ALLNOCONFIG_Y T_EOL
        menu_add_option_allnoconfig_y();
 };
 
+config_option: T_OPTION T_RANDCONFIG_Y T_EOL
+{
+       menu_add_option_randconfig_y();
+};
+
 /* choice entry */
 
 choice: T_CHOICE word_opt T_EOL
--

2.17.1

Signature · 2 lines
Best Regards
Masahiro Yamada