Skip to content

Commit d485cb9

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86-optimized-inlining
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86-optimized-inlining: generic: make optimized inlining arch-opt-in x86: add optimized inlining
2 parents 1292ebb + 765c68b commit d485cb9

File tree

5 files changed

+28
-3
lines changed

5 files changed

+28
-3
lines changed

arch/x86/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ config AUDIT_ARCH
142142
config ARCH_SUPPORTS_AOUT
143143
def_bool y
144144

145+
config ARCH_SUPPORTS_OPTIMIZED_INLINING
146+
def_bool y
147+
145148
# Use the generic interrupt handling code in kernel/irq/:
146149
config GENERIC_HARDIRQS
147150
bool

arch/x86/Kconfig.debug

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,3 +257,16 @@ config CPA_DEBUG
257257
Do change_page_attr() self-tests every 30 seconds.
258258

259259
endmenu
260+
261+
config OPTIMIZE_INLINING
262+
bool "Allow gcc to uninline functions marked 'inline'"
263+
default y
264+
help
265+
This option determines if the kernel forces gcc to inline the functions
266+
developers have marked 'inline'. Doing so takes away freedom from gcc to
267+
do what it thinks is best, which is desirable for the gcc 3.x series of
268+
compilers. The gcc 4.x series have a rewritten inlining algorithm and
269+
disabling this option will generate a smaller kernel there. Hopefully
270+
this algorithm is so good that allowing gcc4 to make the decision can
271+
become the default in the future, until then this option is there to
272+
test gcc for this.

arch/x86/configs/i386_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,7 @@ CONFIG_DEBUG_BUGVERBOSE=y
14211421
# CONFIG_DEBUG_VM is not set
14221422
# CONFIG_DEBUG_LIST is not set
14231423
# CONFIG_FRAME_POINTER is not set
1424+
CONFIG_OPTIMIZE_INLINING=y
14241425
# CONFIG_RCU_TORTURE_TEST is not set
14251426
# CONFIG_LKDTM is not set
14261427
# CONFIG_FAULT_INJECTION is not set

arch/x86/configs/x86_64_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,7 @@ CONFIG_DEBUG_BUGVERBOSE=y
13461346
# CONFIG_DEBUG_VM is not set
13471347
# CONFIG_DEBUG_LIST is not set
13481348
# CONFIG_FRAME_POINTER is not set
1349+
CONFIG_OPTIMIZE_INLINING=y
13491350
# CONFIG_RCU_TORTURE_TEST is not set
13501351
# CONFIG_LKDTM is not set
13511352
# CONFIG_FAULT_INJECTION is not set

include/linux/compiler-gcc.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,16 @@
2828
#define __must_be_array(a) \
2929
BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))
3030

31-
#define inline inline __attribute__((always_inline))
32-
#define __inline__ __inline__ __attribute__((always_inline))
33-
#define __inline __inline __attribute__((always_inline))
31+
/*
32+
* Force always-inline if the user requests it so via the .config:
33+
*/
34+
#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \
35+
!defined(CONFIG_OPTIMIZE_INLINING) && (__GNUC__ >= 4)
36+
# define inline inline __attribute__((always_inline))
37+
# define __inline__ __inline__ __attribute__((always_inline))
38+
# define __inline __inline __attribute__((always_inline))
39+
#endif
40+
3441
#define __deprecated __attribute__((deprecated))
3542
#define __packed __attribute__((packed))
3643
#define __weak __attribute__((weak))

0 commit comments

Comments
 (0)