Re: [PATCH] x86: Turn off GCC branch probability heuristics

From: Linus Torvalds
Date: Sat Apr 11 2015 - 15:36:08 EST

On Sat, Apr 11, 2015 at 11:57 AM, Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
> I thinks its just the no-guess one:
> text data dec patch reduction
> 7563475 1781048 10302987
> 7192973 1780024 9931461 no-guess -4.8%
> 7354819 1781048 958464 align-1 -2.7%
> 7192973 1780024 9931461 no-guess + align-1 -4.8%

Yeah, a 5% code expansion is a big deal. Sadly, it looks like
'no-guess' also disables our explicit likely/unlikely handling.

Damn. If it actually honored likely/unlikely, then we should just do
it - and manually fix up any places where we really care.

But the fact that it apparently entirely disables not just the
guesses, but our *explicit* likely/unlikely, means that we can't fix
up the mistakes.

And in many of the hot codepaths that likely/unlikely really does
matter. Some of our hottest paths have known "this basically never
happens" situations that we do *not* want to break up our L1 I$ over.
There's a number of functions that have been optimized to really
generate good code, and "-fno-guess-branch-probability" disables those
manual optimizations.

So we'd have no way to fix it for the cases that matter.


It might be worth bringing this up with some gcc people. I added Jakub
to the cc. Any other gcc people suggestions?

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at