From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uu1lh-0000cv-4V for qemu-devel@nongnu.org; Tue, 02 Jul 2013 10:41:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uu1le-0007zW-Hm for qemu-devel@nongnu.org; Tue, 02 Jul 2013 10:41:21 -0400 Received: from david.siemens.de ([192.35.17.14]:33328) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uu1le-0007zN-8K for qemu-devel@nongnu.org; Tue, 02 Jul 2013 10:41:18 -0400 Message-ID: <51D2E68A.8090503@siemens.com> Date: Tue, 02 Jul 2013 16:41:14 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <1372444009-11544-1-git-send-email-pbonzini@redhat.com> <1372444009-11544-24-git-send-email-pbonzini@redhat.com> In-Reply-To: <1372444009-11544-24-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 23/30] exec: move listener from AddressSpaceDispatch to AddressSpace List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org On 2013-06-28 20:26, Paolo Bonzini wrote: > This will help having two copies of AddressSpaceDispatch during the > recreation of the radix tree (one being built, and one that is complete > and accessed under RCU). We do not want to have to unregister and > re-register the listener. > > Signed-off-by: Paolo Bonzini > --- > exec.c | 17 +++++++++-------- > include/exec/memory.h | 2 ++ > 2 files changed, 11 insertions(+), 8 deletions(-) > > diff --git a/exec.c b/exec.c > index f138e56..dffdf23 100644 > --- a/exec.c > +++ b/exec.c > @@ -99,7 +99,6 @@ struct AddressSpaceDispatch { > * The bottom level has pointers to MemoryRegionSections. > */ > PhysPageEntry phys_map; > - MemoryListener listener; > AddressSpace *as; > }; > > @@ -855,7 +854,8 @@ static void register_multipage(AddressSpaceDispatch *d, > > static void mem_add(MemoryListener *listener, MemoryRegionSection *section) > { > - AddressSpaceDispatch *d = container_of(listener, AddressSpaceDispatch, listener); > + AddressSpace *as = container_of(listener, AddressSpace, dispatch_listener); > + AddressSpaceDispatch *d = as->dispatch; > MemoryRegionSection now = *section, remain = *section; > Int128 page_size = int128_make64(TARGET_PAGE_SIZE); > > @@ -1717,7 +1717,8 @@ static void io_mem_init(void) > > static void mem_begin(MemoryListener *listener) > { > - AddressSpaceDispatch *d = container_of(listener, AddressSpaceDispatch, listener); > + AddressSpace *as = container_of(listener, AddressSpace, dispatch_listener); > + AddressSpaceDispatch *d = as->dispatch; > > d->phys_map.ptr = PHYS_MAP_NODE_NIL; > } > @@ -1786,22 +1787,22 @@ void address_space_init_dispatch(AddressSpace *as) > AddressSpaceDispatch *d = g_new(AddressSpaceDispatch, 1); > > d->phys_map = (PhysPageEntry) { .ptr = PHYS_MAP_NODE_NIL, .is_leaf = 0 }; > - d->listener = (MemoryListener) { > + d->as = as; > + as->dispatch = d; > + as->dispatch_listener = (MemoryListener) { > .begin = mem_begin, > .region_add = mem_add, > .region_nop = mem_add, > .priority = 0, > }; > - d->as = as; > - as->dispatch = d; > - memory_listener_register(&d->listener, as); > + memory_listener_register(&as->dispatch_listener, as); > } > > void address_space_destroy_dispatch(AddressSpace *as) > { > AddressSpaceDispatch *d = as->dispatch; You could save this line, but only if you need to touch the patch for some other reason. > > - memory_listener_unregister(&d->listener); > + memory_listener_unregister(&as->dispatch_listener); > g_free(d); > as->dispatch = NULL; > } > diff --git a/include/exec/memory.h b/include/exec/memory.h > index 913ac45..1cd1f50 100644 > --- a/include/exec/memory.h > +++ b/include/exec/memory.h > @@ -212,6 +212,8 @@ struct AddressSpace { > int ioeventfd_nb; > struct MemoryRegionIoeventfd *ioeventfds; > struct AddressSpaceDispatch *dispatch; > + MemoryListener dispatch_listener; > + > QTAILQ_ENTRY(AddressSpace) address_spaces_link; > }; > > Reviewed-by: Jan Kiszka Jan -- Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux