From: Alan Cox Subject: Re: memory barrier question Date: Sat, 18 Sep 2010 02:12:19 +0100 Message-ID: <20100918021219.1ff6f98f@lxorguk.ukuu.org.uk> References: <3777.1284638136@redhat.com> <6383.1284647456@redhat.com> <20100916150356.GD2462@linux.vnet.ibm.com> <20100916163708.GG2462@linux.vnet.ibm.com> <1284656978.26423.11.camel@mulgrave.site> <1284760148.30449.107.camel@pasglop> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: Received: from earthlight.etchedpixels.co.uk ([81.2.110.250]:36742 "EHLO www.etchedpixels.co.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753785Ab0IRAu6 (ORCPT ); Fri, 17 Sep 2010 20:50:58 -0400 In-Reply-To: <1284760148.30449.107.camel@pasglop> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Benjamin Herrenschmidt Cc: Miklos Szeredi , James Bottomley , paulmck@linux.vnet.ibm.com, dhowells@redhat.com, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org > > LOAD inode = next.dentry->inode > > if (inode != NULL) > > LOAD inode->f_op > > > > What is there the compiler can optimize? > > Those two loads depend on each other, I don't think any implementation > can re-order them. In fact, such data dependency is typically what is > used to avoid having barriers in some cases. The second load cannot be > issued until the value from the first one is returned. Actually I've met several compilers which will optimise them but not gcc and not in a Linux environment. Some compilers know how to optimise the == NULL case for pointer dereferences providing their programming environment has a couple of low pages mapped read only and reading 0. Alan