[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150411092021.GA9478@gmail.com>
Date: Sat, 11 Apr 2015 11:20:21 +0200
From: Ingo Molnar <mingo@...nel.org>
To: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Jason Low <jason.low2@...com>,
Peter Zijlstra <peterz@...radead.org>,
Davidlohr Bueso <dave@...olabs.net>,
Tim Chen <tim.c.chen@...ux.intel.com>,
Aswin Chandramouleeswaran <aswin@...com>,
LKML <linux-kernel@...r.kernel.org>,
Borislav Petkov <bp@...en8.de>,
Andy Lutomirski <luto@...capital.net>,
Denys Vlasenko <dvlasenk@...hat.com>,
Brian Gerst <brgerst@...il.com>,
"H. Peter Anvin" <hpa@...or.com>,
Thomas Gleixner <tglx@...utronix.de>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: [PATCH] x86: Turn off GCC branch probability heuristics
* Ingo Molnar <mingo@...nel.org> wrote:
> Btw., totally off topic, the following NOP caught my attention:
>
> > 5a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
>
> That's a dead NOP that boats the function a bit, added for the 16 byte
> alignment of one of the jump targets.
Another thing caught my attention (and I'm hijacking the RCU thread
again): GCC's notion of how to place branches seems somewhat random,
and rather bloaty.
So I tried the experiment below on an x86 defconfig, turning off GCC's
branch heuristics, and it's rather surprising:
text data bss dec filename
12566447 1617840 1089536 15273823 vmlinux.fguess-branch-probability
11923593 1617840 1089536 14630969 vmlinux.fno-guess-branch-probability
That's an 5.4% code size improvement!
So maybe we should try this, as it results in much more predictable
(and more compact!) code by default - and allows us to shape loops and
branches in a natural fashion: by their placement, and also via
likely()/unlikely() hints when absolutely necessary.
Thoughts?
Thanks,
Ingo
=================>
From: Ingo Molnar <mingo@...nel.org>
Date: Sat, 11 Apr 2015 11:16:30 +0200
Subject: [PATCH] x86: Turn off GCC branch probability heuristics
Not-Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
arch/x86/Makefile | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 5ba2d9ce82dc..7c12b3f56915 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -81,6 +81,9 @@ else
KBUILD_CFLAGS += $(call cc-option,-mno-80387)
KBUILD_CFLAGS += $(call cc-option,-mno-fp-ret-in-387)
+ # Don't guess branch probabilities, follow the code and unlikely()/likely() hints:
+ KBUILD_CFLAGS += -fno-guess-branch-probability
+
# Use -mpreferred-stack-boundary=3 if supported.
KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=3)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists