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 <pbonz...@redhat.com> > --- > 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 > >