lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 11 Apr 2015 11:20:21 +0200
From:	Ingo Molnar <>
To:	"Paul E. McKenney" <>
Cc:	Linus Torvalds <>,
	Jason Low <>,
	Peter Zijlstra <>,
	Davidlohr Bueso <>,
	Tim Chen <>,
	Aswin Chandramouleeswaran <>,
	LKML <>,
	Borislav Petkov <>,
	Andy Lutomirski <>,
	Denys Vlasenko <>,
	Brian Gerst <>,
	"H. Peter Anvin" <>,
	Thomas Gleixner <>,
	Peter Zijlstra <>
Subject: [PATCH] x86: Turn off GCC branch probability heuristics

* Ingo Molnar <> 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.




From: Ingo Molnar <>
Date: Sat, 11 Apr 2015 11:16:30 +0200
Subject: [PATCH] x86: Turn off GCC branch probability heuristics

Not-Signed-off-by: Ingo Molnar <>
 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
More majordomo info at
Please read the FAQ at

Powered by blists - more mailing lists