Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752100AbbEQGEt (ORCPT ); Sun, 17 May 2015 02:04:49 -0400 Received: from terminus.zytor.com ([198.137.202.10]:53842 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751208AbbEQGEl (ORCPT ); Sun, 17 May 2015 02:04:41 -0400 Date: Sat, 16 May 2015 23:03:31 -0700 From: tip-bot for Ingo Molnar Message-ID: Cc: a.p.zijlstra@chello.nl, aswin@hp.com, dvlasenk@redhat.com, hpa@zytor.com, tglx@linutronix.de, luto@amacapital.net, bp@alien8.de, linux-kernel@vger.kernel.org, paulmck@linux.vnet.ibm.com, mingo@kernel.org, jason.low2@hp.com, torvalds@linux-foundation.org, tim.c.chen@linux.intel.com, brgerst@gmail.com, peterz@infradead.org, dave@stgolabs.net Reply-To: mingo@kernel.org, dave@stgolabs.net, peterz@infradead.org, torvalds@linux-foundation.org, jason.low2@hp.com, brgerst@gmail.com, tim.c.chen@linux.intel.com, paulmck@linux.vnet.ibm.com, tglx@linutronix.de, hpa@zytor.com, dvlasenk@redhat.com, linux-kernel@vger.kernel.org, bp@alien8.de, luto@amacapital.net, a.p.zijlstra@chello.nl, aswin@hp.com In-Reply-To: <20150410123017.GB19918@gmail.com> References: <20150410123017.GB19918@gmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/apic] x86: Pack loops tightly as well Git-Commit-ID: 52648e83c9a6b9f7fc3dd272d4d10175e93aa62a X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3772 Lines: 106 Commit-ID: 52648e83c9a6b9f7fc3dd272d4d10175e93aa62a Gitweb: http://git.kernel.org/tip/52648e83c9a6b9f7fc3dd272d4d10175e93aa62a Author: Ingo Molnar AuthorDate: Sun, 17 May 2015 07:56:54 +0200 Committer: Ingo Molnar CommitDate: Sun, 17 May 2015 07:56:54 +0200 x86: Pack loops tightly as well Packing loops tightly (-falign-loops=1) is beneficial to code size: 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 11903735 1617840 1089536 14611111 vmlinux.align.1-byte.funcs-1-byte.loops-1-byte Which reduces the size of the kernel by another 0.6%, so the the total combined size reduction of the alignment-packing patches is ~5.5%. The x86 decoder bandwidth and caching arguments laid out in: be6cb02779ca ("x86: Align jump targets to 1-byte boundaries") apply to loop alignment as well. Furtermore, modern CPU uarchs have a loop cache/buffer that is a L0 cache before even any uop cache, covering a few dozen most recently executed instructions. This loop cache generally does not have the 16-byte alignment restrictions of the uop cache. Now loop alignment can still be beneficial if: - a loop is cache-hot and its surroundings are not. - if the loop is so cache hot that the instruction flow becomes x86 decoder bandwidth limited But loop alignment is harmful if: - a loop is cache-cold - a loop's surroundings are cache-hot as well - two cache-hot loops are close to each other - if the loop fits into the loop cache - if the code flow is not decoder bandwidth limited and I'd argue that the latter five scenarios are much more common in the kernel, as our hottest loops are typically: - pointer chasing: this should fit into the loop cache in most cases and is typically data cache and address generation limited - generic memory ops (memset, memcpy, etc.): these generally fit into the loop cache as well, and are likewise data cache limited. So this patch packs loop addresses tightly as well. Acked-by: Denys Vlasenko Cc: Andy Lutomirski Cc: Aswin Chandramouleeswaran Cc: Borislav Petkov Cc: Brian Gerst Cc: Davidlohr Bueso Cc: H. Peter Anvin Cc: Jason Low Cc: Linus Torvalds Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Tim Chen Link: http://lkml.kernel.org/r/20150410123017.GB19918@gmail.com 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 ca17e5f..57996ee 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -80,6 +80,9 @@ else # Align jump targets to 1 byte, not the default 16 bytes: KBUILD_CFLAGS += -falign-jumps=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) -- 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/