Skip to contentSkip to conversation

Kconfig: -O3 enablement

PATCH In review Miko Larsson 4 participants 11 messages Jun 21, 2022 – Jun 23, 2022 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Kconfig: -O3 enablement

Hi,

This very small series allows -O3 to be used for all architectures. The first patch marks -O3 as experimental, with the reasoning being that it might expose unwanted regressions to users, and the second patch actually allows -O3 by removing the "depend on ARC" string.

The reasoning behind this series is to open up -O3 so that bugs related to it (both compiler-related and kernel-related) can be discovered by eyeballs wanting to improve the "-O3 experience," as that might be beneficial to both compilers and the kernel. This has been attempted before [1], but unfortunately nothing ever came of it.

[1] https://lore.kernel.org/lkml/[email protected]/

Cc Nathan Chancellor <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Nick Desaulniers <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Sebastian Andrzej Siewior <[email protected]>
Cc Sean Christopherson <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Chris Down <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc John Ogness <[email protected]>
Cc Elliot Berman <[email protected]>
Cc Oleksandr Natalenko <[email protected]>

Miko Larsson (2):
Kconfig: Mark -O3 as experimental
Kconfig: Allow -O3 for all architectures

 init/Kconfig | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.36.1
#1 lore raw

PATCH 1/2 Kconfig: Mark -O3 as experimental

Mark -O3 as experimental, as it might cause unwanted regressions for users.

---
 init/Kconfig | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
init/Kconfig +4 -1
index c7900e897..9c292acb2 100644
@@ -1402,12 +1402,15 @@ config CC_OPTIMIZE_FOR_PERFORMANCE
 	  helpful compile-time warnings.
 
 config CC_OPTIMIZE_FOR_PERFORMANCE_O3
-	bool "Optimize more for performance (-O3)"
+	bool "Optimize more for performance (-O3) (EXPERIMENTAL)"
 	depends on ARC
 	help
 	  Choosing this option will pass "-O3" to your compiler to optimize
 	  the kernel yet more for performance.
 
+	  This option is EXPERIMENTAL; you may encounter compiler bugs and/or
+	  kernel bugs with this option enabled.
+
 config CC_OPTIMIZE_FOR_SIZE
 	bool "Optimize for size (-Os)"
 	help
Signature · 1 line
2.36.1
#2 lore raw

PATCH 2/2 Kconfig: Allow -O3 for all architectures

In reply to Miko Larsson

This commit allows all architectures to use the experimental -O3 optimization option. Previously, only ARC was allowed to use this option.

---
 init/Kconfig | 1 -
 1 file changed, 1 deletion(-)
init/Kconfig +0 -1
index 9c292acb2..b88613cb5 100644
@@ -1403,7 +1403,6 @@ config CC_OPTIMIZE_FOR_PERFORMANCE
 
 config CC_OPTIMIZE_FOR_PERFORMANCE_O3
 	bool "Optimize more for performance (-O3) (EXPERIMENTAL)"
-	depends on ARC
 	help
 	  Choosing this option will pass "-O3" to your compiler to optimize
 	  the kernel yet more for performance.
Signature · 1 line
2.36.1
#3 lore raw
In reply to Miko Larsson
Quoted 7 lines · Miko Larsson

Hi,

This very small series allows -O3 to be used for all architectures. The first patch marks -O3 as experimental, with the reasoning being that it might expose unwanted regressions to users, and the second patch actually allows -O3 by removing the "depend on ARC" string.

I think we should just remove -O3 support from KCONFIG.

If someone wants to mess around with "experimental features," there's nothing stopping you from doing:

$ make KCFLAGS=-O3
Quoted 35 lines

The reasoning behind this series is to open up -O3 so that bugs related to it (both compiler-related and kernel-related) can be discovered by eyeballs wanting to improve the "-O3 experience," as that might be beneficial to both compilers and the kernel. This has been attempted before [1], but unfortunately nothing ever came of it.

[1] https://lore.kernel.org/lkml/[email protected]/

Cc Nathan Chancellor <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Nick Desaulniers <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Sebastian Andrzej Siewior <[email protected]>
Cc Sean Christopherson <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Chris Down <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc John Ogness <[email protected]>
Cc Elliot Berman <[email protected]>
Cc Oleksandr Natalenko <[email protected]>

Miko Larsson (2):
Kconfig: Mark -O3 as experimental
Kconfig: Allow -O3 for all architectures

 init/Kconfig | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--
2.36.1

Signature · 2 lines
Thanks,
~Nick Desaulniers
#4 lore raw
Quoted 10 lines · Nick Desaulniers
Quoted 7 lines · Miko Larsson

Hi,

This very small series allows -O3 to be used for all architectures. The first patch marks -O3 as experimental, with the reasoning being that it might expose unwanted regressions to users, and the second patch actually allows -O3 by removing the "depend on ARC" string.

Quoted 7 lines

I think we should just remove -O3 support from KCONFIG.

If someone wants to mess around with "experimental features," there's nothing stopping you from doing:

$ make KCFLAGS=-O3

ARC uses -O3 since day1.

"Generic build system uses -O2, we want -O3" in commit cfdbc2e16e65c1ec1c23057640607cee98d1a1bd

If they want -O3, it is up to the ARC maintainer.

If you want to say "use this option carefully",
EXPERT might be another option.

    depends on ARC || EXPERT
Quoted 40 lines
Quoted 29 lines

The reasoning behind this series is to open up -O3 so that bugs related to it (both compiler-related and kernel-related) can be discovered by eyeballs wanting to improve the "-O3 experience," as that might be beneficial to both compilers and the kernel. This has been attempted before [1], but unfortunately nothing ever came of it.

[1] https://lore.kernel.org/lkml/[email protected]/

Cc Nathan Chancellor <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Nick Desaulniers <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Sebastian Andrzej Siewior <[email protected]>
Cc Sean Christopherson <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Chris Down <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc John Ogness <[email protected]>
Cc Elliot Berman <[email protected]>
Cc Oleksandr Natalenko <[email protected]>

Miko Larsson (2):
Kconfig: Mark -O3 as experimental
Kconfig: Allow -O3 for all architectures

Quoted 6 lines
 init/Kconfig | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--
2.36.1

--
Thanks,
~Nick Desaulniers

Signature · 2 lines
Best Regards
Masahiro Yamada
#5 lore raw
Quoted 5 lines · On Wednesday, 22 June 2022 03:57:34 CEST Masahiro Yamada wrote:

If you want to say "use this option carefully",
EXPERT might be another option.

    depends on ARC || EXPERT

Yeah, this would be a fair compromise, though I think it would be better to use "visible if" instead of "depends on". I can get a v2 of the series together if this is desired.

--
~miko

#6 lore raw
Quoted 11 lines · Miko Larsson
Quoted 5 lines · On Wednesday, 22 June 2022 03:57:34 CEST Masahiro Yamada wrote:

If you want to say "use this option carefully",
EXPERT might be another option.

    depends on ARC || EXPERT

Yeah, this would be a fair compromise, though I think it would be better to use "visible if" instead of "depends on". I can get a v2 of the series together if this is desired.

Why is "visible if" better than "depends on"?

Quoted 4 lines

--
~miko

--
Best Regards
Masahiro Yamada

#7 lore raw
Quoted 5 lines · On Thursday, 23 June 2022 17:44:57 CEST Masahiro Yamada wrote:
Quoted 4 lines · Miko Larsson
Quoted 3 lines · On Wednesday, 22 June 2022 03:57:34 CEST Masahiro Yamada wrote:

If you want to say "use this option carefully",
EXPERT might be another option.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line
    depends on ARC || EXPERT

Yeah, this would be a fair compromise, though I think it would be better to use "visible if" instead of "depends on". I can get a v2 of the series together if this is desired.

Why is "visible if" better than "depends on"?

Technically it most likely doesn't matter, but logically it makes more sense, since we'd make CC_OPTIMIZE_FOR_PERFORMANCE_O3 be visible if we're on ARC or if we have EXPERT enabled, instead of depending on them. But yeah, it probably doesn't matter.

--
~miko

#8 lore raw
Quoted 13 lines · Miko Larsson
Quoted 11 lines · On Thursday, 23 June 2022 17:44:57 CEST Masahiro Yamada wrote:
Quoted 9 lines · Miko Larsson
Quoted 4 lines · On Wednesday, 22 June 2022 03:57:34 CEST Masahiro Yamada wrote:

If you want to say "use this option carefully",
EXPERT might be another option.

    depends on ARC || EXPERT

Yeah, this would be a fair compromise, though I think it would be better to use "visible if" instead of "depends on". I can get a v2 of the series together if this is desired.

Quoted 7 lines
Quoted 2 lines

Why is "visible if" better than "depends on"?

Technically it most likely doesn't matter, but logically it makes more sense, since we'd make CC_OPTIMIZE_FOR_PERFORMANCE_O3 be visible if we're on ARC or if we have EXPERT enabled, instead of depending on them. But yeah, it probably doesn't matter.

Did you write and test the code?

"visible if" is only supported for "menu".
This is clearly documented at line 207
of Documentation/kbuild/kconfig-language.rst

Using "visible if" for config entry will just
result in the syntax error.

Quoted 5 lines

--
~miko

--
Best Regards
Masahiro Yamada

#9 lore raw
Quoted 3 lines · On Thursday, 23 June 2022 19:15:14 CEST Masahiro Yamada wrote:
Quoted 2 lines · Miko Larsson
Quoted 1 line · On Thursday, 23 June 2022 17:44:57 CEST Masahiro Yamada wrote:

On Fri, Jun 24, 2022 at 12:42 AM Miko Larsson <[email protected]>

Quoted 10 lines · wrote:
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines · On Wednesday, 22 June 2022 03:57:34 CEST Masahiro Yamada wrote:
Quoted 4 lines

If you want to say "use this option carefully",
EXPERT might be another option.

    depends on ARC || EXPERT

Yeah, this would be a fair compromise, though I think it would be better to use "visible if" instead of "depends on". I can get a v2 of the series together if this is desired.

Quoted 9 lines
Quoted 6 lines
Quoted 1 line

Why is "visible if" better than "depends on"?

Technically it most likely doesn't matter, but logically it makes more sense, since we'd make CC_OPTIMIZE_FOR_PERFORMANCE_O3 be visible if we're on ARC or if we have EXPERT enabled, instead of depending on them. But yeah, it probably doesn't matter.

Did you write and test the code?

Admittedly, I didn't, since I had falsely assumed that "visible if" was just an "alternative" to "depends on".

Quoted 8 lines

"visible if" is only supported for "menu".
This is clearly documented at line 207
of Documentation/kbuild/kconfig-language.rst

Using "visible if" for config entry will just
result in the syntax error.

Oops, yeah, I wasn't aware of this. Sorry.

--
~miko

#10 lore raw
In reply to Masahiro Yamada
Quoted 4 lines · Masahiro Yamada
Quoted 3 lines · Nick Desaulniers
Quoted 1 line · Miko Larsson
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

Hi,

This very small series allows -O3 to be used for all architectures. The first patch marks -O3 as experimental, with the reasoning being that it might expose unwanted regressions to users, and the second patch actually allows -O3 by removing the "depend on ARC" string.

I think we should just remove -O3 support from KCONFIG.

I agree that would be best

Quoted 6 lines
Quoted 5 lines

If someone wants to mess around with "experimental features," there's nothing stopping you from doing:

$ make KCFLAGS=-O3
Quoted 6 lines

ARC uses -O3 since day1.

"Generic build system uses -O2, we want -O3" in commit cfdbc2e16e65c1ec1c23057640607cee98d1a1bd

If they want -O3, it is up to the ARC maintainer.

I suppose whatever the reason for using -O3 at the time has likely changed by now.

Quoted 4 lines

If you want to say "use this option carefully",
EXPERT might be another option.

    depends on ARC || EXPERT

This probably also needs a dependency on !COMPILE_TEST so we don't report compile-time problems that are specific to -O3. Maybe a good first step would be to turn this into

      depends on ARCH && EXPERT && !COMPILE_TEST

which should help both with compile-testing on ARC, and it would prevent it from being visible on other architectures.

Arnd