Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758008AbXHQWaw (ORCPT ); Fri, 17 Aug 2007 18:30:52 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753659AbXHQWal (ORCPT ); Fri, 17 Aug 2007 18:30:41 -0400 Received: from gate.crashing.org ([63.228.1.57]:53034 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752951AbXHQWaj (ORCPT ); Fri, 17 Aug 2007 18:30:39 -0400 In-Reply-To: References: <46C32618.2080108@redhat.com> <20070815234021.GA28775@gondor.apana.org.au> <3694fb2e4ed1e4d9bf873c0d050c911e@kernel.crashing.org> <46C3B50E.7010702@yahoo.com.au> <194369f4c96ea0e24decf8f9197d5bad@kernel.crashing.org> <46C505B2.6030704@yahoo.com.au> <18117.4848.695269.72976@cargo.ozlabs.ibm.com> Mime-Version: 1.0 (Apple Message framework v623) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <036b785bc30ad3faa872171d8630542f@kernel.crashing.org> Content-Transfer-Encoding: 7bit Cc: Paul Mackerras , heiko.carstens@de.ibm.com, horms@verge.net.au, linux-kernel@vger.kernel.org, rpjday@mindspring.com, ak@suse.de, netdev@vger.kernel.org, cfriesen@nortel.com, akpm@linux-foundation.org, Nick Piggin , linux-arch@vger.kernel.org, jesper.juhl@gmail.com, satyam@infradead.org, zlynx@acm.org, clameter@sgi.com, schwidefsky@de.ibm.com, Chris Snook , Herbert Xu , davem@davemloft.net, wensong@linux-vs.org, wjiang@resilience.com From: Segher Boessenkool Subject: Re: [PATCH 0/24] make atomic_read() behave consistently across all architectures Date: Sat, 18 Aug 2007 00:29:30 +0200 To: Linus Torvalds X-Mailer: Apple Mail (2.623) Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1331 Lines: 40 > In a reasonable world, gcc should just make that be (on x86) > > addl $1,i(%rip) > > on x86-64, which is indeed what it does without the volatile. But with > the > volatile, the compiler gets really nervous, and doesn't dare do it in > one > instruction, and thus generates crap like > > movl i(%rip), %eax > addl $1, %eax > movl %eax, i(%rip) > > instead. For no good reason, except that "volatile" just doesn't have > any > good/clear semantics for the compiler, so most compilers will just > make it > be "I will not touch this access in any way, shape, or form". Including > even trivially correct instruction optimization/combination. It's just a (target-specific, perhaps) missed-optimisation kind of bug in GCC. Care to file a bug report? > but is > (again) something that gcc doesn't dare do, since "i" is volatile. Just nobody taught it it can do this; perhaps no one wanted to add optimisations like that, maybe with a reasoning like "people who hit the go-slow-in-unspecified-ways button should get what they deserve" ;-) Segher - 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/