From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Usese-0006Tm-3X for qemu-devel@nongnu.org; Fri, 28 Jun 2013 16:02:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Usesc-0001qV-Co for qemu-devel@nongnu.org; Fri, 28 Jun 2013 16:02:52 -0400 Received: from mail-gh0-f169.google.com ([209.85.160.169]:59942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Usesc-0001qL-8D for qemu-devel@nongnu.org; Fri, 28 Jun 2013 16:02:50 -0400 Received: by mail-gh0-f169.google.com with SMTP id r1so990116ghr.0 for ; Fri, 28 Jun 2013 13:02:49 -0700 (PDT) From: Anthony Liguori In-Reply-To: <1372444009-11544-3-git-send-email-pbonzini@redhat.com> References: <1372444009-11544-1-git-send-email-pbonzini@redhat.com> <1372444009-11544-3-git-send-email-pbonzini@redhat.com> Date: Fri, 28 Jun 2013 15:02:47 -0500 Message-ID: <87bo6q9f6g.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH 02/30] memory: use a new FlatView pointer on every topology update List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Paolo Bonzini writes: > This is the first step towards converting as->current_map to > RCU-style updates, where the FlatView updates run concurrently > with uses of an old FlatView. > > Signed-off-by: Paolo Bonzini Reviewed-by: Anthony Liguori Regards, Anthony Liguori > --- > memory.c | 34 ++++++++++++++++++---------------- > 1 file changed, 18 insertions(+), 16 deletions(-) > > diff --git a/memory.c b/memory.c > index 1f44cd1..319894e 100644 > --- a/memory.c > +++ b/memory.c > @@ -276,6 +276,7 @@ static void flatview_destroy(FlatView *view) > memory_region_unref(view->ranges[i].mr); > } > g_free(view->ranges); > + g_free(view); > } > > static bool can_merge(FlatRange *r1, FlatRange *r2) > @@ -512,17 +513,18 @@ static void render_memory_region(FlatView *view, > } > > /* Render a memory topology into a list of disjoint absolute ranges. */ > -static FlatView generate_memory_topology(MemoryRegion *mr) > +static FlatView *generate_memory_topology(MemoryRegion *mr) > { > - FlatView view; > + FlatView *view; > > - flatview_init(&view); > + view = g_new(FlatView, 1); > + flatview_init(view); > > if (mr) { > - render_memory_region(&view, mr, int128_zero(), > + render_memory_region(view, mr, int128_zero(), > addrrange_make(int128_zero(), int128_2_64()), false); > } > - flatview_simplify(&view); > + flatview_simplify(view); > > return view; > } > @@ -610,8 +612,8 @@ static void address_space_update_ioeventfds(AddressSpace *as) > } > > static void address_space_update_topology_pass(AddressSpace *as, > - FlatView old_view, > - FlatView new_view, > + const FlatView *old_view, > + const FlatView *new_view, > bool adding) > { > unsigned iold, inew; > @@ -621,14 +623,14 @@ static void address_space_update_topology_pass(AddressSpace *as, > * Kill ranges in the old map, and instantiate ranges in the new map. > */ > iold = inew = 0; > - while (iold < old_view.nr || inew < new_view.nr) { > - if (iold < old_view.nr) { > - frold = &old_view.ranges[iold]; > + while (iold < old_view->nr || inew < new_view->nr) { > + if (iold < old_view->nr) { > + frold = &old_view->ranges[iold]; > } else { > frold = NULL; > } > - if (inew < new_view.nr) { > - frnew = &new_view.ranges[inew]; > + if (inew < new_view->nr) { > + frnew = &new_view->ranges[inew]; > } else { > frnew = NULL; > } > @@ -674,14 +676,14 @@ static void address_space_update_topology_pass(AddressSpace *as, > > static void address_space_update_topology(AddressSpace *as) > { > - FlatView old_view = *as->current_map; > - FlatView new_view = generate_memory_topology(as->root); > + FlatView *old_view = as->current_map; > + FlatView *new_view = generate_memory_topology(as->root); > > address_space_update_topology_pass(as, old_view, new_view, false); > address_space_update_topology_pass(as, old_view, new_view, true); > > - *as->current_map = new_view; > - flatview_destroy(&old_view); > + as->current_map = new_view; > + flatview_destroy(old_view); > address_space_update_ioeventfds(as); > } > > -- > 1.8.1.4