From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755330Ab0IPObN (ORCPT ); Thu, 16 Sep 2010 10:31:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18961 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752387Ab0IPObL (ORCPT ); Thu, 16 Sep 2010 10:31:11 -0400 Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: References: <3777.1284638136@redhat.com> To: Miklos Szeredi Cc: dhowells@redhat.com, paulmck@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Subject: Re: memory barrier question Date: Thu, 16 Sep 2010 15:30:56 +0100 Message-ID: <6383.1284647456@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Miklos Szeredi wrote: > Is the rmb() really needed? > > Take this code from fs/namei.c for example: > > inode = next.dentry->d_inode; > if (!inode) > goto out_dput; > > if (inode->i_op->follow_link) { > > It happily dereferences dentry->d_inode without a barrier after > checking it for non-null, while that d_inode might have just been > initialized on another CPU with a freshly created inode. There's > absolutely no synchornization with that on this side. Perhaps it's not necessary; once set, how likely is i_op to be changed once I_NEW is cleared? > Isn't the fact that we check the pointer for being non-null (together > with locking/barrier on the other side) enough to ensure that it's > safe to dereference it? It's possible that since there's a dependency between the variables on the reading CPU that the barrier is not required. I think I have to refer that question to Paul. David