Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755866AbbDJMSP (ORCPT ); Fri, 10 Apr 2015 08:18:15 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:36052 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755439AbbDJMSO (ORCPT ); Fri, 10 Apr 2015 08:18:14 -0400 Date: Fri, 10 Apr 2015 14:18:08 +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: Pack function addresses tightly as well Message-ID: <20150410121808.GA19918@gmail.com> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150410120846.GA17101@gmail.com> 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: 2393 Lines: 65 * Ingo Molnar wrote: > I realize that x86 CPU manufacturers recommend 16-byte jump target > alignments (it's in the Intel optimization manual), but the cost of > that is very significant: > > text data bss dec filename > 12566391 1617840 1089536 15273767 vmlinux.align.16-byte > 12224951 1617840 1089536 14932327 vmlinux.align.1-byte > > By using 1 byte jump target alignment (i.e. no alignment at all) we > get an almost 3% reduction in kernel size (!) - and a probably > similar reduction in I$ footprint. Likewise we could pack functions tightly as well via the patch below: text data bss dec filename 12566391 1617840 1089536 15273767 vmlinux.align.16-byte 12224951 1617840 1089536 14932327 vmlinux.align.1-byte 11976567 1617840 1089536 14683943 vmlinux.align.1-byte.funcs-1-byte Which brings another 2% reduction in the kernel's code size. It would be interesting to see some benchmarks with these two patches applied. Only lightly tested. Thanks, Ingo ============================> >From 773dbbfbf37df3520dd98e91972fbfdef5fe91ad Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Fri, 10 Apr 2015 14:14:29 +0200 Subject: [PATCH] x86: Pack function addresses tightly as well Not-Signed-off-by: Ingo Molnar --- arch/x86/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 0366d6b44a14..573d0c459f99 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -77,9 +77,12 @@ else KBUILD_AFLAGS += -m64 KBUILD_CFLAGS += -m64 - # Align jump targets to 1 byte, not the default 16 bytes: + # 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 + # Don't autogenerate traditional x87 instructions KBUILD_CFLAGS += $(call cc-option,-mno-80387) KBUILD_CFLAGS += $(call cc-option,-mno-fp-ret-in-387) -- 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/