OSDN Git Service

compiler: allow all arches to enable CONFIG_OPTIMIZE_INLINING
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Tue, 14 May 2019 22:42:25 +0000 (15:42 -0700)
committer0ranko0P <ranko0p@outlook.com>
Thu, 9 Jan 2020 06:53:45 +0000 (14:53 +0800)
Commit 60a3cdd06394 ("x86: add optimized inlining") introduced
CONFIG_OPTIMIZE_INLINING, but it has been available only for x86.

The idea is obviously arch-agnostic.  This commit moves the config entry
from arch/x86/Kconfig.debug to lib/Kconfig.debug so that all
architectures can benefit from it.

This can make a huge difference in kernel image size especially when
CONFIG_OPTIMIZE_FOR_SIZE is enabled.

For example, I got 3.5% smaller arm64 kernel for v5.1-rc1.

  dec       file
  18983424  arch/arm64/boot/Image.before
  18321920  arch/arm64/boot/Image.after

This also slightly improves the "Kernel hacking" Kconfig menu as
e61aca5158a8 ("Merge branch 'kconfig-diet' from Dave Hansen') suggested;
this config option would be a good fit in the "compiler option" menu.

Link: http://lkml.kernel.org/r/20190423034959.13525-12-yamada.masahiro@socionext.com
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Borislav Petkov <bp@suse.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Boris Brezillon <bbrezillon@kernel.org>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Christophe Leroy <christophe.leroy@c-s.fr>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Marek Vasut <marek.vasut@gmail.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Malaterre <malat@debian.org>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[kdrag0n: Backported to k4.14]
Signed-off-by: Danny Lin <danny@kdrag0n.dev>
arch/x86/Kconfig
arch/x86/Kconfig.debug
include/linux/compiler-gcc.h
lib/Kconfig.debug

index 3d5d6f5..c98435a 100644 (file)
@@ -272,9 +272,6 @@ config ZONE_DMA32
 config AUDIT_ARCH
        def_bool y if X86_64
 
-config ARCH_SUPPORTS_OPTIMIZED_INLINING
-       def_bool y
-
 config ARCH_SUPPORTS_DEBUG_PAGEALLOC
        def_bool y
 
index 3cb8e17..0025bdb 100644 (file)
@@ -304,20 +304,6 @@ config CPA_DEBUG
        ---help---
          Do change_page_attr() self-tests every 30 seconds.
 
-config OPTIMIZE_INLINING
-       bool "Allow gcc to uninline functions marked 'inline'"
-       ---help---
-         This option determines if the kernel forces gcc to inline the functions
-         developers have marked 'inline'. Doing so takes away freedom from gcc to
-         do what it thinks is best, which is desirable for the gcc 3.x series of
-         compilers. The gcc 4.x series have a rewritten inlining algorithm and
-         enabling this option will generate a smaller kernel there. Hopefully
-         this algorithm is so good that allowing gcc 4.x and above to make the
-         decision will become the default in the future. Until then this option
-         is there to test gcc for this.
-
-         If unsure, say N.
-
 config DEBUG_ENTRY
        bool "Debug low-level entry code"
        depends on DEBUG_KERNEL
index af8b4a8..d56a8e1 100644 (file)
@@ -89,8 +89,7 @@
  * of extern inline functions at link time.
  * A lot of inline functions can cause havoc with function tracing.
  */
-#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) ||               \
-    !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4)
+#if !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4)
 #define inline \
        inline __attribute__((always_inline, unused)) notrace __gnu_inline
 #else
index 43e3a0d..d960913 100644 (file)
@@ -289,6 +289,20 @@ config HEADERS_CHECK
          exported to $(INSTALL_HDR_PATH) (usually 'usr/include' in
          your build tree), to make sure they're suitable.
 
+config OPTIMIZE_INLINING
+       bool "Allow compiler to uninline functions marked 'inline'"
+       help
+         This option determines if the kernel forces gcc to inline the functions
+         developers have marked 'inline'. Doing so takes away freedom from gcc to
+         do what it thinks is best, which is desirable for the gcc 3.x series of
+         compilers. The gcc 4.x series have a rewritten inlining algorithm and
+         enabling this option will generate a smaller kernel there. Hopefully
+         this algorithm is so good that allowing gcc 4.x and above to make the
+         decision will become the default in the future. Until then this option
+         is there to test gcc for this.
+
+         If unsure, say N.
+
 config DEBUG_SECTION_MISMATCH
        bool "Enable full Section mismatch analysis"
        help