Skip to content

Commit 9012d01

Browse files
masahir0ytorvalds
authored andcommitted
compiler: allow all arches to enable CONFIG_OPTIMIZE_INLINING
Commit 60a3cdd ("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 e61aca5 ("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/[email protected] Signed-off-by: Masahiro Yamada <[email protected]> Acked-by: Borislav Petkov <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Boris Brezillon <[email protected]> Cc: Brian Norris <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: David Woodhouse <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Marek Vasut <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Malaterre <[email protected]> Cc: Miquel Raynal <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: Richard Weinberger <[email protected]> Cc: Russell King <[email protected]> Cc: Stefan Agner <[email protected]> Cc: Thomas Gleixner <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent efc344c commit 9012d01

File tree

4 files changed

+15
-19
lines changed

4 files changed

+15
-19
lines changed

arch/x86/Kconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,6 @@ config ZONE_DMA32
305305
config AUDIT_ARCH
306306
def_bool y if X86_64
307307

308-
config ARCH_SUPPORTS_OPTIMIZED_INLINING
309-
def_bool y
310-
311308
config ARCH_SUPPORTS_DEBUG_PAGEALLOC
312309
def_bool y
313310

arch/x86/Kconfig.debug

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -266,20 +266,6 @@ config CPA_DEBUG
266266
---help---
267267
Do change_page_attr() self-tests every 30 seconds.
268268

269-
config OPTIMIZE_INLINING
270-
bool "Allow gcc to uninline functions marked 'inline'"
271-
---help---
272-
This option determines if the kernel forces gcc to inline the functions
273-
developers have marked 'inline'. Doing so takes away freedom from gcc to
274-
do what it thinks is best, which is desirable for the gcc 3.x series of
275-
compilers. The gcc 4.x series have a rewritten inlining algorithm and
276-
enabling this option will generate a smaller kernel there. Hopefully
277-
this algorithm is so good that allowing gcc 4.x and above to make the
278-
decision will become the default in the future. Until then this option
279-
is there to test gcc for this.
280-
281-
If unsure, say N.
282-
283269
config DEBUG_ENTRY
284270
bool "Debug low-level entry code"
285271
depends on DEBUG_KERNEL

include/linux/compiler_types.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ struct ftrace_likely_data {
140140
* Do not use __always_inline here, since currently it expands to inline again
141141
* (which would break users of __always_inline).
142142
*/
143-
#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \
144-
!defined(CONFIG_OPTIMIZE_INLINING)
143+
#if !defined(CONFIG_OPTIMIZE_INLINING)
145144
#define inline inline __attribute__((__always_inline__)) __gnu_inline \
146145
__maybe_unused notrace
147146
#else

lib/Kconfig.debug

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,20 @@ config HEADERS_CHECK
318318
exported to $(INSTALL_HDR_PATH) (usually 'usr/include' in
319319
your build tree), to make sure they're suitable.
320320

321+
config OPTIMIZE_INLINING
322+
bool "Allow compiler to uninline functions marked 'inline'"
323+
help
324+
This option determines if the kernel forces gcc to inline the functions
325+
developers have marked 'inline'. Doing so takes away freedom from gcc to
326+
do what it thinks is best, which is desirable for the gcc 3.x series of
327+
compilers. The gcc 4.x series have a rewritten inlining algorithm and
328+
enabling this option will generate a smaller kernel there. Hopefully
329+
this algorithm is so good that allowing gcc 4.x and above to make the
330+
decision will become the default in the future. Until then this option
331+
is there to test gcc for this.
332+
333+
If unsure, say N.
334+
321335
config DEBUG_SECTION_MISMATCH
322336
bool "Enable full Section mismatch analysis"
323337
help

0 commit comments

Comments
 (0)