Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938207AbXHPDex (ORCPT ); Wed, 15 Aug 2007 23:34:53 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932624AbXHPDel (ORCPT ); Wed, 15 Aug 2007 23:34:41 -0400 Received: from rhun.apana.org.au ([64.62.148.172]:3268 "EHLO arnor.apana.org.au" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932509AbXHPDek (ORCPT ); Wed, 15 Aug 2007 23:34:40 -0400 Date: Thu, 16 Aug 2007 11:33:43 +0800 From: Herbert Xu To: Paul Mackerras Cc: Christoph Lameter , Satyam Sharma , "Paul E. McKenney" , Stefan Richter , Chris Snook , Linux Kernel Mailing List , linux-arch@vger.kernel.org, Linus Torvalds , netdev@vger.kernel.org, Andrew Morton , ak@suse.de, heiko.carstens@de.ibm.com, davem@davemloft.net, schwidefsky@de.ibm.com, wensong@linux-vs.org, horms@verge.net.au, wjiang@resilience.com, cfriesen@nortel.com, zlynx@acm.org, rpjday@mindspring.com, jesper.juhl@gmail.com, segher@kernel.crashing.org Subject: Re: [PATCH 0/24] make atomic_read() behave consistently across all architectures Message-ID: <20070816033343.GA31844@gondor.apana.org.au> References: <20070816003948.GY9645@linux.vnet.ibm.com> <20070816005348.GA9645@linux.vnet.ibm.com> <20070816011414.GC9645@linux.vnet.ibm.com> <20070816020851.GA30809@gondor.apana.org.au> <18115.49946.522011.832468@cargo.ozlabs.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <18115.49946.522011.832468@cargo.ozlabs.ibm.com> User-Agent: Mutt/1.5.9i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1390 Lines: 38 On Thu, Aug 16, 2007 at 01:23:06PM +1000, Paul Mackerras wrote: > > In particular, atomic_read seems to lend itself to buggy uses. People > seem to do things like: > > atomic_add(&v, something); > if (atomic_read(&v) > something_else) ... If you're referring to the code in sk_stream_mem_schedule then it's working as intended. The atomicity guarantees that the atomic_add/atomic_sub won't be seen in parts by other readers. We certainly do not need to see other atomic_add/atomic_sub operations immediately. If you're referring to another code snippet please cite. > I'd go so far as to say that anywhere where you want a non-"volatile" > atomic_read, either your code is buggy, or else an int would work just > as well. An int won't work here because += and -= do not have the atomicity guarantees that atomic_add/atomic_sub do. In particular, this may cause an atomic_read on another CPU to give a bogus reading. Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt - 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/