History

compiler: allow all arches to enable CONFIG_OPTIMIZE_INLINING

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.

Masahiro Yamada committed 7 years ago

Commit 9012d011 parent efc344c4 files · +15 −19Browse files

Unified · Split

4 files
  1. arch/x86/Kconfig +0 −3
  2. arch/x86/Kconfig.debug +0 −14
  3. include/linux/compiler_types.h +1 −2
  4. lib/Kconfig.debug +14 −0
arch/x86/Kconfig+0−3
@@ -305,9 +305,6 @@ config ZONE_DMA32 · 304 unmodified lines
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+0−14
@@ -266,20 +266,6 @@ config CPA_DEBUG · 265 unmodified lines
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+1−2
@@ -140,8 +140,7 @@ struct ftrace_likely_data { · 139 unmodified lines
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+14−0
@@ -318,6 +318,20 @@ config HEADERS_CHECK · 317 unmodified lines
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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t