Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762523AbZATWG3 (ORCPT ); Tue, 20 Jan 2009 17:06:29 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757601AbZATWF6 (ORCPT ); Tue, 20 Jan 2009 17:05:58 -0500 Received: from mx3.mail.elte.hu ([157.181.1.138]:38749 "EHLO mx3.mail.elte.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757306AbZATWF4 (ORCPT ); Tue, 20 Jan 2009 17:05:56 -0500 Date: Tue, 20 Jan 2009 23:05:16 +0100 From: Ingo Molnar To: Linus Torvalds Cc: David Woodhouse , Nick Piggin , Bernd Schmidt , Andi Kleen , Andrew Morton , Harvey Harrison , "H. Peter Anvin" , Chris Mason , Peter Zijlstra , Steven Rostedt , paulmck@linux.vnet.ibm.com, Gregory Haskins , Matthew Wilcox , Linux Kernel Mailing List , linux-fsdevel , linux-btrfs , Thomas Gleixner , Peter Morreale , Sven Dietrich , jh@suse.cz Subject: Re: gcc inlining heuristics was Re: [PATCH -v7][RFC]: mutex: implement adaptive spinning Message-ID: <20090120220516.GA10483@elte.hu> References: <496BBE27.2020206@t-online.de> <20090119001345.GA9880@elte.hu> <20090119062212.GC22584@wotan.suse.de> <20090120005124.GD16304@wotan.suse.de> <20090120123824.GD7790@elte.hu> <1232480940.22233.1435.camel@macbook.infradead.org> <20090120210515.GC19710@elte.hu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-ELTE-VirusStatus: clean X-ELTE-SpamScore: -1.5 X-ELTE-SpamLevel: X-ELTE-SpamCheck: no X-ELTE-SpamVersion: ELTE 2.0 X-ELTE-SpamCheck-Details: score=-1.5 required=5.9 tests=BAYES_00 autolearn=no SpamAssassin version=3.2.3 -1.5 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3563 Lines: 96 * Linus Torvalds wrote: > On Tue, 20 Jan 2009, Ingo Molnar wrote: > > > > (Different-type pointer uses are a common pattern: we have a lot of > > places where we have pointers to structures with different types so > > strict-aliasing optimization opportunities apply quite broadly > > already.) > > Yes and no. > > It's true that the kernel in general uses mostly pointers through > structures that can help the type-based thing. > > However, the most common and important cases are actually the very same > structures. In particular, things like . Same "struct > list", often embedded into another case of the same struct. > > And that's where "restrict" can actually help. It might be interesting > to see, for example, if it makes any difference to add a "restrict" > qualifier to the "new" pointer in __list_add(). That might give the > compiler the ability to schedule the stores to next->prev and prev->next > differently, and maybe it could matter? > > It probably is not noticeable. The big reason for wanting to do alias > analysis tends to not be thatt kind of code at all, but the cases where > you can do much bigger simplifications, or on in-order machines where > you really want to hoist things like FP loads early and FP stores late, > and alias analysis (and here type-based is more reasonable) shows that > the FP accesses cannot alias with the integer accesses around it. Hm, GCC uses __restrict__, right? The patch below makes no difference at all on an x86 defconfig: vmlinux: text data bss dec hex filename 7253544 1641812 1324296 10219652 9bf084 vmlinux.before 7253544 1641812 1324296 10219652 9bf084 vmlinux.after not a single instruction was changed: --- vmlinux.before.asm +++ vmlinux.after.asm @@ -1,5 +1,5 @@ -vmlinux.before: file format elf64-x86-64 +vmlinux.after: file format elf64-x86-64 I'm wondering whether there's any internal tie-up between alias analysis and the __restrict__ keyword - so if we turn off aliasing optimizations the __restrict__ keyword's optimizations are turned off as well. Nope, with aliasing optimizations turned back on there's still no change on the x86 defconfig: text data bss dec hex filename 7240893 1641796 1324296 10206985 9bbf09 vmlinux.before 7240893 1641796 1324296 10206985 9bbf09 vmlinux.after GCC 4.3.2. Maybe i missed something obvious? Ingo --- include/linux/list.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Index: linux/include/linux/list.h =================================================================== --- linux.orig/include/linux/list.h +++ linux/include/linux/list.h @@ -38,7 +38,7 @@ static inline void INIT_LIST_HEAD(struct * the prev/next entries already! */ #ifndef CONFIG_DEBUG_LIST -static inline void __list_add(struct list_head *new, +static inline void __list_add(struct list_head * __restrict__ new, struct list_head *prev, struct list_head *next) { @@ -48,7 +48,7 @@ static inline void __list_add(struct lis prev->next = new; } #else -extern void __list_add(struct list_head *new, +extern void __list_add(struct list_head * __restrict__ new, struct list_head *prev, struct list_head *next); #endif -- 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/