Re: [patch 00/2] improve .text size on gcc 4.0 and newer compilers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Ingo Molnar <[email protected]> wrote:

> (there's a third thing that i was also playing with, -ffunction-sections 
> and -fdata-sections, but those dont seem to be reliable on the binutils 
> side yet.)
> 
> here are the isolated unit-at-a-time numbers as well:
> 
>    text    data     bss     dec     hex filename
>   3286166  869852  387260 4543278  45532e vmlinux-orig
>   3259928  833176  387748 4480852  445f54 vmlinux-units         -0.8%
>   3194123  955168  387260 4536551  4538e7 vmlinux-inline        -2.9%
>   3119495  884960  387748 4392203  43050b vmlinux-inline+units  -5.3%
> 
> so both inlining and unit-at-a-time is a win independently [although 
> inlining alone does bloat .data], but applied together they bring an 
> additional 1.6% of .text savings. All builds done with:
> 
>    gcc version 4.0.2 20051109 (Red Hat 4.0.2-6)
> 
> how about giving the inlining stuff some more exposure in -mm (if it's 
> fine with Andrew), to check for any regressions? I'd suggest the same 
> for the unit-at-a-time thing too, in any case.

another thing: i wanted to decrease the size of -Os 
(CONFIG_CC_OPTIMIZE_FOR_SIZE) kernels, which e.g. Fedora uses too (to 
keep the icache footprint down).

I think gcc should arguably not be forced to inline things when doing 
-Os, and it's also expected to mess up much less than when optimizing 
for speed. So maybe forced inlining should be dependent on 
!CONFIG_CC_OPTIMIZE_FOR_SIZE?

I.e. like the patch below?

	Ingo

----------------->
Subject: allow gcc4 to control inlining

allow gcc4 compilers to decide what to inline and what not - instead
of the kernel forcing gcc to inline all the time.

Signed-off-by: Ingo Molnar <[email protected]>
Signed-off-by: Arjan van de Ven <[email protected]>
----

 include/linux/compiler-gcc4.h |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

Index: linux-gcc.q/include/linux/compiler-gcc4.h
===================================================================
--- linux-gcc.q.orig/include/linux/compiler-gcc4.h
+++ linux-gcc.q/include/linux/compiler-gcc4.h
@@ -3,14 +3,19 @@
 /* These definitions are for GCC v4.x.  */
 #include <linux/compiler-gcc.h>
 
-#define inline			inline		__attribute__((always_inline))
-#define __inline__		__inline__	__attribute__((always_inline))
-#define __inline		__inline	__attribute__((always_inline))
+
+#ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE
+# define inline			inline		__attribute__((always_inline))
+# define __inline__		__inline__	__attribute__((always_inline))
+# define __inline		__inline	__attribute__((always_inline))
+#endif
+
 #define __deprecated		__attribute__((deprecated))
 #define __attribute_used__	__attribute__((__used__))
 #define __attribute_pure__	__attribute__((pure))
 #define __attribute_const__	__attribute__((__const__))
-#define  noinline		__attribute__((noinline))
+#define noinline		__attribute__((noinline))
+#define __always_inline		inline __attribute__((always_inline))
 #define __must_check 		__attribute__((warn_unused_result))
 #define __compiler_offsetof(a,b) __builtin_offsetof(a,b)
 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux