]> rtime.felk.cvut.cz Git - lisovros/linux_canprio.git/commitdiff
x86: add optimized inlining
authorIngo Molnar <mingo@elte.hu>
Mon, 3 Mar 2008 11:38:52 +0000 (12:38 +0100)
committerIngo Molnar <mingo@elte.hu>
Sat, 26 Apr 2008 15:44:55 +0000 (17:44 +0200)
add CONFIG_OPTIMIZE_INLINING=y.

allow gcc to optimize the kernel image's size by uninlining
functions that have been marked 'inline'. Previously gcc was
forced by Linux to always-inline these functions via a gcc
attribute:

 #define inline inline __attribute__((always_inline))

Especially when the user has already selected
CONFIG_OPTIMIZE_FOR_SIZE=y this can make a huge difference in
kernel image size (using a standard Fedora .config):

   text    data     bss     dec           hex filename
   5613924  562708 3854336 10030968    990f78 vmlinux.before
   5486689  562708 3854336  9903733    971e75 vmlinux.after

that's a 2.3% text size reduction (!).

Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/Kconfig.debug
arch/x86/configs/i386_defconfig
arch/x86/configs/x86_64_defconfig
include/linux/compiler-gcc.h

index 239fd9fba0a5fd8737aff15585494ae1d0176611..5b1979a45a1ea07f6ffc8d6b563fc1ddcb64dae3 100644 (file)
@@ -257,3 +257,16 @@ config CPA_DEBUG
          Do change_page_attr() self-tests every 30 seconds.
 
 endmenu
+
+config OPTIMIZE_INLINING
+       bool "Allow gcc to uninline functions marked 'inline'"
+       default y
+       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
+         disabling this option will generate a smaller kernel there. Hopefully
+         this algorithm is so good that allowing gcc4 to make the decision can
+         become the default in the future, until then this option is there to
+         test gcc for this.
index 3df340b54e57e93ab09dc6430184f38a2e4b49f3..ad7ddaaff588aaa619010fabe29af2ee2559d54d 100644 (file)
@@ -1421,6 +1421,7 @@ CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_VM is not set
 # CONFIG_DEBUG_LIST is not set
 # CONFIG_FRAME_POINTER is not set
+CONFIG_OPTIMIZE_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
 # CONFIG_LKDTM is not set
 # CONFIG_FAULT_INJECTION is not set
index eef98cb00c629f118ae3982c4f654290de6c2102..2d6f5b2809d2f4644e82ccfd323acbe587693bf5 100644 (file)
@@ -1346,6 +1346,7 @@ CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_VM is not set
 # CONFIG_DEBUG_LIST is not set
 # CONFIG_FRAME_POINTER is not set
+CONFIG_OPTIMIZE_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
 # CONFIG_LKDTM is not set
 # CONFIG_FAULT_INJECTION is not set
index fe23792f05c1077149718fd783458e8d4d12c5db..340bc5d9277210a911bbd1d88599332244b27761 100644 (file)
 #define __must_be_array(a) \
   BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))
 
-#define inline         inline          __attribute__((always_inline))
-#define __inline__     __inline__      __attribute__((always_inline))
-#define __inline       __inline        __attribute__((always_inline))
+/*
+ * Force always-inline if the user requests it so via the .config:
+ */
+#if !defined(CONFIG_OPTIMIZE_INLINING) && (__GNUC__ >= 4)
+# define inline                inline          __attribute__((always_inline))
+# define __inline__    __inline__      __attribute__((always_inline))
+# define __inline      __inline        __attribute__((always_inline))
+#endif
+
 #define __deprecated                   __attribute__((deprecated))
 #define __packed                       __attribute__((packed))
 #define __weak                         __attribute__((weak))