From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755443AbbDKS55 (ORCPT ); Sat, 11 Apr 2015 14:57:57 -0400 Received: from www.linutronix.de ([62.245.132.108]:54625 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752650AbbDKS54 (ORCPT ); Sat, 11 Apr 2015 14:57:56 -0400 Date: Sat, 11 Apr 2015 20:57:52 +0200 (CEST) From: Thomas Gleixner To: Linus Torvalds cc: Ingo Molnar , Denys Vlasenko , Borislav Petkov , Tim Chen , Andy Lutomirski , Jason Low , Brian Gerst , Aswin Chandramouleeswaran , "Paul E. McKenney" , Davidlohr Bueso , Peter Zijlstra , "H. Peter Anvin" , LKML , Peter Zijlstra Subject: Re: [PATCH] x86: Turn off GCC branch probability heuristics In-Reply-To: Message-ID: References: <20150409175652.GI6464@linux.vnet.ibm.com> <20150409183926.GM6464@linux.vnet.ibm.com> <20150410090051.GA28549@gmail.com> <20150410091252.GA27630@gmail.com> <20150410092152.GA21332@gmail.com> <20150410111427.GA30477@gmail.com> <20150410112748.GB30477@gmail.com> <20150410120846.GA17101@gmail.com> <20150411092021.GA9478@gmail.com> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 11 Apr 2015, Linus Torvalds wrote: > On Apr 11, 2015 2:20 AM, "Ingo Molnar" wrote: > > > > 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! > > Ugh. That's much larger than I would have expected. Is it just because > gcc ends up turning > > if (a) > b > c > > into > > if (a) goto out-of-line > return: > c > .. > out-of-line: > c > goto return; > > a lot? Still, 5% sounds insanely big. > > How much of that 5% comes from code alignment? Or was this on *top* of > the 1-byte alignment testt? 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% So with the no-guess applied the align-1 does not matter anymore. Thanks, tglx