Optimized inlining for ARM
Subsystems (2)
cover Optimized inlining for ARM
I know that Ingo deliberately introduced this option as x86 specific, but I'd like to introduce this for ARM as well. To avoid useless copy paste, I've made the option generic so any arch can support it.
In an effort to make a tiny crash kernel this option can shave a few kb off the crash kernel size. It also helps a regular kernel have a smaller icache footprint which should be benficial. This option isn't on by default so there is no harm in adding it besides giving the user a potentially dangerous option to enable. If it's really experimental we can add an "if EXPERIMENTAL" in the second patch. In the end, I'd like to get a wider range of testing with this feature enabled on ARM so I'm posting it here in hopes that people can respond back with Tested-by tags (or Naks if it crashes their system).
Stephen Boyd (2):
Make OPTIMIZE_INLINING a generic option
arm: add optimized inlining
arch/arm/Kconfig | 1 + arch/x86/Kconfig | 4 +--- arch/x86/Kconfig.debug | 14 -------------- init/Kconfig | 18 ++++++++++++++++++ 4 files changed, 20 insertions(+), 17 deletions(-)
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH 1/2 Make OPTIMIZE_INLINING a generic option
This option is useful on more architectures than just x86. When this option was introduced Ingo deliberately made it x86 specific since he was uncertain of the amount of testing other architectures had (see http://lkml.org/lkml/2008/3/4/285).
This option has been tested on ARM v7 with no ill effects observed. Therefore make it generic so ARM can choose it in the next patch.
--- arch/x86/Kconfig | 4 +--- arch/x86/Kconfig.debug | 14 -------------- init/Kconfig | 18 ++++++++++++++++++ 3 files changed, 19 insertions(+), 17 deletions(-)
arch/x86/Kconfig +1 -3
@@ -65,6 +65,7 @@ config X86 select HAVE_SPARSE_IRQ select GENERIC_IRQ_PROBE select GENERIC_PENDING_IRQ if SMP + select ARCH_SUPPORTS_OPTIMIZED_INLINING config INSTRUCTION_DECODER def_bool (KPROBES || PERF_EVENTS)
@@ -193,9 +194,6 @@ config AUDIT_ARCH bool default X86_64 -config ARCH_SUPPORTS_OPTIMIZED_INLINING - def_bool y - config ARCH_SUPPORTS_DEBUG_PAGEALLOC def_bool y
arch/x86/Kconfig.debug +0 -14
@@ -265,20 +265,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_STRICT_USER_COPY_CHECKS bool "Strict copy size checks" depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
init/Kconfig +18 -0
@@ -811,6 +811,24 @@ config CC_OPTIMIZE_FOR_SIZE If unsure, say Y. +config ARCH_SUPPORTS_OPTIMIZED_INLINING + bool + +config OPTIMIZE_INLINING + bool "Allow gcc to uninline functions marked 'inline'" + depends on ARCH_SUPPORTS_OPTIMIZED_INLINING + ---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 SYSCTL bool
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH 2/2 arm: add optimized inlining
In reply to Stephen BoydThis patch is inspired by 60a3cdd (x86: add optimized inlining, 2008-03-03). GCC is currently being forced to inline whatever functions are marked as inline (due to the #define of inline to the gcc attribute always_inline). The 4.x series of GCC has a rewritten inlining algorithm which should be good enough for the kernel's purposes. Enabling this option will allow GCC to decide when to inline a function marked as inline. Since it's opt-in and doesn't affect functions marked as always_inline there shouldn't be much harm in allowing people to enable this. If there is, we should find the affected functions and mark them as always_inline.
text data bss dec hex filename 5987182 246104 926696 7159982 6d40ae vmlinux.orig 5794190 246104 926744 6967038 6a4efe vmlinux.new
It reduces the text section of my kernel by 3.3%, which is pretty nice.
--- arch/arm/Kconfig | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/Kconfig +1 -0
@@ -23,6 +23,7 @@ config ARM select PERF_USE_VMALLOC select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_HW_BREAKPOINT if (PERF_EVENTS && (CPU_V6 || CPU_V7)) + select ARCH_SUPPORTS_OPTIMIZED_INLINING help The ARM series is a line of low-power-consumption RISC chip designs licensed by ARM Ltd and targeted at embedded applications and
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.