Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935244AbXHPCJZ (ORCPT ); Wed, 15 Aug 2007 22:09:25 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754307AbXHPCJE (ORCPT ); Wed, 15 Aug 2007 22:09:04 -0400 Received: from gate.crashing.org ([63.228.1.57]:51652 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750976AbXHPCJC (ORCPT ); Wed, 15 Aug 2007 22:09:02 -0400 In-Reply-To: <18115.44462.622801.683446@cargo.ozlabs.ibm.com> References: <20070809131423.GA9927@shell.boston.redhat.com> <46C2D6F3.3070707@s5r6.in-berlin.de> <18115.35524.56393.347841@cargo.ozlabs.ibm.com> <20070816003948.GY9645@linux.vnet.ibm.com> <18115.44462.622801.683446@cargo.ozlabs.ibm.com> Mime-Version: 1.0 (Apple Message framework v623) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit Cc: Christoph Lameter , heiko.carstens@de.ibm.com, horms@verge.net.au, Stefan Richter , Satyam Sharma , Linux Kernel Mailing List , "Paul E. McKenney" , netdev@vger.kernel.org, ak@suse.de, cfriesen@nortel.com, rpjday@mindspring.com, jesper.juhl@gmail.com, linux-arch@vger.kernel.org, Andrew Morton , zlynx@acm.org, schwidefsky@de.ibm.com, Chris Snook , Herbert Xu , davem@davemloft.net, Linus Torvalds , wensong@linux-vs.org, wjiang@resilience.com From: Segher Boessenkool Subject: Re: [PATCH 0/24] make atomic_read() behave consistently across all architectures Date: Thu, 16 Aug 2007 04:07:01 +0200 To: Paul Mackerras X-Mailer: Apple Mail (2.623) Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1297 Lines: 30 >> A volatile default would disable optimizations for atomic_read. >> atomic_read without volatile would allow for full optimization by the >> compiler. Seems that this is what one wants in many cases. > > Name one such case. > > An atomic_read should do a load from memory. If the programmer puts > an atomic_read() in the code then the compiler should emit a load for > it, not re-use a value returned by a previous atomic_read. I do not > believe it would ever be useful for the compiler to collapse two > atomic_read statements into a single load. An atomic_read() implemented as a "normal" C variable read would allow that read to be combined with another "normal" read from that variable. This could perhaps be marginally useful, although I'd bet you cannot see it unless counting cycles on a simulator or counting bits in the binary size. With an asm() implementation, the compiler can not do this; with a "volatile" implementation (either volatile variable or volatile-cast), this invokes undefined behaviour (in both C and GCC). 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/