Experimental -O3 Optimizing The Linux Kernel For Better Performance Brought Up Again
Right now there exists the "CC_OPTIMIZE_FOR_PERFORMANCE_O3" Kconfig option to set the "-O3" optimization level when building the kernel for making use of that higher optimization level over the default -O2. The hope is that the GCC or Clang compiler will better optimize the kernel for better performance, but right now that option is only exposed for the ARC CPU architecture port.
While -O3 optimizing user-space application builds is commonly done for achieving better performance, with the complexity of the kernel and the very large code-base it's prone to possible errors or incorrect behavior with the low-level kernel code. Thus -O3'ing the kernel isn't widely carried out due to the possibility of likely subtle and possibly difficult to notice/detect problems.
But there is interest by enthusiasts in -O3 optimizing the kernel for greater performance and/or by developers in building with the higher optimization level to try to uncover bugs within the Linux kernel code and/or the compiler itself where optimizations go awry.
Miko Larsson sent out a set of patches this week that would allow CC_OPTIMIZE_FOR_PERFORMANCE_O3 to be flipped on for non-ARC architectures -- i.e. make it available for all Linux kernel builds. It also marks the option clearly as being an "EXPERIMENTAL" feature.
The patch series is out for review. It has been suggested though about possibly removing the option even though it's always been used on ARC. The suggestion is for those interested in "experimental features" could just build the kernel using make KCFLAGS=-O3 to achieve the same O3 optimized build. Generally the upstream Linux kernel developers are quite conservative in aggressive compiler features just intended for performance gains when it can mean subtle bugs / hard to detect issues. But we'll see if anything more comes from this most recent discussion over the -O3 compiler optimizations for Linux kernel builds.