From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFd6a-0006Xf-UG for qemu-devel@nongnu.org; Mon, 26 Jan 2015 01:25:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YFd6V-0006JO-SB for qemu-devel@nongnu.org; Mon, 26 Jan 2015 01:25:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38013) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFd6V-0006JK-LF for qemu-devel@nongnu.org; Mon, 26 Jan 2015 01:24:55 -0500 Date: Mon, 26 Jan 2015 14:24:48 +0800 From: Fam Zheng Message-ID: <20150126062448.GG2354@ad.nay.redhat.com> References: <1421938053-10318-1-git-send-email-pbonzini@redhat.com> <1421938053-10318-8-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1421938053-10318-8-git-send-email-pbonzini@redhat.com> Subject: Re: [Qemu-devel] [PATCH 07/15] memory: avoid ref/unref in memory_region_find List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: borntraeger@de.ibm.com, qemu-devel@nongnu.org, stefanha@redhat.com On Thu, 01/22 15:47, Paolo Bonzini wrote: > Do the entire lookup under RCU, which avoids atomic operations. address_space_get_flatview() already is RCU protected, I don't see why this patch is necessary. Could you explain? And there is one question below: > > Signed-off-by: Paolo Bonzini > --- > memory.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/memory.c b/memory.c > index a844ced..577e87c 100644 > --- a/memory.c > +++ b/memory.c > @@ -1828,7 +1828,8 @@ MemoryRegionSection memory_region_find(MemoryRegion *mr, > } > range = addrrange_make(int128_make64(addr), int128_make64(size)); > > - view = address_space_get_flatview(as); > + rcu_read_lock(); > + view = atomic_rcu_read(&as->current_map); > fr = flatview_lookup(view, range); > if (!fr) { > flatview_unref(view); Following lines are: return ret; } Which requires a rcu_read_unlock. Fam > @@ -1850,7 +1851,7 @@ MemoryRegionSection memory_region_find(MemoryRegion *mr, > ret.readonly = fr->readonly; > memory_region_ref(ret.mr); > > - flatview_unref(view); > + rcu_read_unlock(); > return ret; > } > > -- > 1.8.3.1 > >