Received: from eggs.gnu.org ([2001:4830:134:3::10]:53782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfPkE-0002qk-Hh for qemu-devel@nongnu.org; Thu, 01 Sep 2016 07:01:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bfPkA-00052Q-FP for qemu-devel@nongnu.org; Thu, 01 Sep 2016 07:01:17 -0400 Sender: Paolo Bonzini References: <20160831222909.26983-1-bobby.prani@gmail.com> From: Paolo Bonzini Message-ID: <73565fc1-8d02-bae1-42b0-c03ed7c73a09@redhat.com> Date: Thu, 1 Sep 2016 13:01:02 +0200 MIME-Version: 1.0 In-Reply-To: <20160831222909.26983-1-bobby.prani@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] aio: Remove spurious smp_read_barrier_depends() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pranith Kumar , Stefan Hajnoczi , Fam Zheng , "open list:Block I/O path" , "open list:All patches CC here" On 01/09/2016 00:29, Pranith Kumar wrote: > smp_read_barrier_depends() should be used only if you are reading > dependent pointers which are shared. bh is shared since it is equal to ctx->first_bh or ctx->first_bh->...->next. While the compiler will always order the load of bh->next after the load of ctx->first_bh and any previous load of bh->next, this may not be the case for the processor. Only the DEC Alpha has this behavior, but it _can_ happen. Paolo Here 'bh' is a local variable and > dereferencing it will always be ordered after loading 'bh', i.e., > bh->next will always be ordered after fetching bh. > > This patch removes the barrier and adds a comment why storing > 'bh->next' is necessary. > > Signed-off-by: Pranith Kumar > --- > async.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/async.c b/async.c > index 3bca9b0..6b691aa 100644 > --- a/async.c > +++ b/async.c > @@ -77,8 +77,7 @@ int aio_bh_poll(AioContext *ctx) > > ret = 0; > for (bh = ctx->first_bh; bh; bh = next) { > - /* Make sure that fetching bh happens before accessing its members */ > - smp_read_barrier_depends(); > + /* store bh->next since bh can be freed in aio_bh_call() */ > next = bh->next; > /* The atomic_xchg is paired with the one in qemu_bh_schedule. The > * implicit memory barrier ensures that the callback sees all writes >