Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754629AbbDNJQh (ORCPT ); Tue, 14 Apr 2015 05:16:37 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:35658 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753207AbbDNJQY (ORCPT ); Tue, 14 Apr 2015 05:16:24 -0400 Date: Tue, 14 Apr 2015 11:16:16 +0200 From: Ingo Molnar To: Markus Trippelsdorf Cc: Linus Torvalds , "H. Peter Anvin" , Denys Vlasenko , "Paul E. McKenney" , Jason Low , Peter Zijlstra , Davidlohr Bueso , Tim Chen , Aswin Chandramouleeswaran , LKML , Borislav Petkov , Andy Lutomirski , Brian Gerst , Thomas Gleixner , Peter Zijlstra Subject: Re: [PATCH] x86: Align jump targets to 1 byte boundaries Message-ID: <20150414091615.GA10345@gmail.com> References: <5527C700.3030405@redhat.com> <5527CD92.1080901@zytor.com> <20150411144135.GB31416@x4> <20150412101422.GA2862@gmail.com> <20150413162308.GB398@x4> <20150413172624.GC398@x4> <20150413190914.GA398@x4> <20150414053821.GA28321@gmail.com> <20150414082346.GB398@x4> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150414082346.GB398@x4> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4202 Lines: 115 * Markus Trippelsdorf wrote: > On 2015.04.14 at 07:38 +0200, Ingo Molnar wrote: > > > > Just to make sure, could you please also apply the 3 alignment patches > > attached below? There's a lot of noise from extra alignment. > > Here's an updated table: > > text data bss dec filename > 8746230 970072 802816 10519118 ./vmlinux gcc-5 (lto) > 9202488 978512 811008 10992008 ./vmlinux gcc-5 > 8036915 970296 802816 9810027 ./vmlinux gcc-5 (lto -fno-guess-branch-probability) > 8593615 978512 811008 10383135 ./vmlinux gcc-5 (-fno-guess-branch-probability) > 8202614 970072 802816 9975502 ./vmlinux gcc-5 (lto + Ingo's patch) > 8801016 978512 811008 10590536 ./vmlinux gcc-5 (Ingo's patch) > 8733943 952088 798720 10484751 ./vmlinux gcc-5 (lto + -malign-data=abi) > 9186105 958320 806912 10951337 ./vmlinux gcc-5 (-malign-data=abi) > 8190327 952088 798720 9941135 ./vmlinux gcc-5 (lto + Ingo's patch + -malign-data=abi) > 8784633 958320 806912 10549865 ./vmlinux gcc-5 (Ingo's patch + -malign-data=abi) > > For the "lto + Ingo's patch + -malign-data=abi" combination there is a > 10% text size reduction. Lets rename "Ingo's patch" to "code_align=1". The interesting one would be to compare: code_align=1 + -fno-guess-branch-probability vs. lto + code_align=1 + -fno-guess-branch-probability Or rather, you could try "Ingo's combo patch" further below, with and without LTO. I'd expect LTO to still be in the 5% reduction range. > -malign-data is a new option for gcc-5 that controls how the > compiler aligns variables. "abi" aligns variables according to psABI > and give the tightest packing. I'm not so sure about that one, our data access patterns are usually a lot more well thought out than our code alignment (which is really mostly compiler controlled). It also gives limited savings: 9202488 vmlinux gcc-5 9186105 vmlinux gcc-5 (-malign-data=abi) Which is 0.1%. I've got a handful of options in that size range: + # Reduces vmlinux size by 0.25%: + KBUILD_CFLAGS += -fno-caller-saves + + # Reduces vmlinux size by 1.10%: + KBUILD_CFLAGS += -fno-inline-small-functions + + # Reduces vmlinux size by about 0.95%: + KBUILD_CFLAGS += -fno-tree-ch but obviously they are more obscure and thus riskier. Find below an updated "Ingo's combo patch". It gives more than 10% savings here on x86 defconfig using gcc 4.9, without LTO. Thanks, Ingo ----------------> arch/x86/Makefile | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 5ba2d9ce82dc..999e94685d12 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -77,10 +77,34 @@ else KBUILD_AFLAGS += -m64 KBUILD_CFLAGS += -m64 + # Pack jump targets tightly, don't align them to the default 16 bytes: + KBUILD_CFLAGS += -falign-jumps=1 + + # Pack functions tightly as well: + KBUILD_CFLAGS += -falign-functions=1 + + # Pack loops tightly as well: + KBUILD_CFLAGS += -falign-loops=1 + # Don't autogenerate traditional x87 instructions 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, + # which reduces vmlinux size by about 5.4%: + # + KBUILD_CFLAGS += -fno-guess-branch-probability + + # Reduces vmlinux size by 0.25%: + KBUILD_CFLAGS += -fno-caller-saves + + # Reduces vmlinux size by 1.10%: + KBUILD_CFLAGS += -fno-inline-small-functions + + # Reduces vmlinux size by about 0.95%: + KBUILD_CFLAGS += -fno-tree-ch + # 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/