linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86: Use -m-omit-leaf-frame-pointer to shrink text size
@ 2011-12-16  8:19 Ingo Molnar
  2011-12-16  8:48 ` Andrew Morton
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Ingo Molnar @ 2011-12-16  8:19 UTC (permalink / raw)
  To: linux-kernel
  Cc: H. Peter Anvin, Thomas Gleixner, Peter Zijlstra,
	Frédéric Weisbecker, Linus Torvalds, Andrew Morton,
	Jan Beulich, Arjan van de Ven, Alexander van Heukelum


This patch turns on -momit-leaf-frame-pointer on x86 builds and 
thus shrinks .text noticeably. On a defconfig-ish kernel:

   text	   data	    bss	    dec	    hex	filename
   9843902	1935808	3649536	15429246	 eb6e7e	vmlinux.before
   9813764	1935792	3649536	15399092	 eaf8b4	vmlinux.after

That's 0.3% off text size.

The actual win is larger than this percentage suggests: many 
small, hot helper functions such as find_next_bit(), 
do_raw_spin_lock() or most of the list_*() functions are leaf 
functions and are now shorter by 2 instructions.

Probably a good chunk of the framepointers related runtime 
overhead on common workloads is eliminated via this patch, as 
small leaf functions execute more often than larger parent 
functions.

The call-chains are still intact for quality backtraces and for 
call-chain profiling (perf record -g), as the backtrace walker 
can deduct the full backtrace from the RIP of a leaf function 
and the parent chain.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/Makefile |    8 ++++++++
 1 file changed, 8 insertions(+)

Index: linux/arch/x86/Makefile
===================================================================
--- linux.orig/arch/x86/Makefile
+++ linux/arch/x86/Makefile
@@ -72,6 +72,14 @@ else
         KBUILD_CFLAGS += -maccumulate-outgoing-args
 endif
 
+#
+# This shrinks many small functions, we don't actually
+# need their frame pointer, in backtraces the RIP will
+# identify the function and the stack frame walker will
+# find the parent function:
+#
+KBUILD_CFLAGS += $(call cc-option,-momit-leaf-frame-pointer)
+
 ifdef CONFIG_CC_STACKPROTECTOR
 	cc_has_sp := $(srctree)/scripts/gcc-x86_$(BITS)-has-stack-protector.sh
         ifeq ($(shell $(CONFIG_SHELL) $(cc_has_sp) $(CC) $(KBUILD_CPPFLAGS) $(biarch)),y)

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-12-16 16:27 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-16  8:19 [PATCH] x86: Use -m-omit-leaf-frame-pointer to shrink text size Ingo Molnar
2011-12-16  8:48 ` Andrew Morton
2011-12-16  8:54   ` Ingo Molnar
2011-12-16  8:53 ` Ingo Molnar
2011-12-16  9:23   ` Jeremy Fitzhardinge
2011-12-16 10:20     ` Peter Zijlstra
2011-12-16 16:27       ` Richard Henderson
2011-12-16 11:46     ` Jan Beulich
2011-12-16 12:00       ` Ingo Molnar
2011-12-16 15:32         ` H. Peter Anvin
2011-12-16 14:01 ` Frederic Weisbecker
2011-12-16 14:06 ` Frederic Weisbecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).