From patchwork Thu Jul 4 15:13:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 256948 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2315B2C008F for ; Fri, 5 Jul 2013 01:40:33 +1000 (EST) Received: from localhost ([::1]:52154 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uule2-0003tw-Tb for incoming@patchwork.ozlabs.org; Thu, 04 Jul 2013 11:40:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45609) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UulH0-0003L1-QS for qemu-devel@nongnu.org; Thu, 04 Jul 2013 11:16:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UulGx-000669-EH for qemu-devel@nongnu.org; Thu, 04 Jul 2013 11:16:42 -0400 Received: from mail-wi0-x22a.google.com ([2a00:1450:400c:c05::22a]:33558) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UulGx-00065i-7O for qemu-devel@nongnu.org; Thu, 04 Jul 2013 11:16:39 -0400 Received: by mail-wi0-f170.google.com with SMTP id ey16so7444659wid.3 for ; Thu, 04 Jul 2013 08:16:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=xX+PFsZljI6ydc2gUJ5kK+bZh9st0a1WCohNJkGjHew=; b=Mk4FCXDx8Fn1Jb0a0AZ9J6CF4uqp5r6AOieULfodP2/E+12qmN+NZk2PePkz/ibTYj emZGmKnAxcZDbZybQ762NNGm6p9paZtrT9LT4NhAlie5VOg6caSGOdPO/7tILTUtsdbv rMuzVP/f9SSvfC/tClivckteoN6pQl+l36sdoDCqfTxHCPe4pFkE3SSta+ykqiinXsE5 lefs+tbyTaX5ysOGHe6ZFp8BU9B0RjQ5E1jNwL+OXJu5UdQuNnjLnnVm/v/MNXKv8yPG 8TWo6GKk5eVe3Z6FKCFldP7bi2/wmgjdo/n0j2hGAxRc5bXp+SIvLf9KUj5Vi/REj7ea 6dkg== X-Received: by 10.180.99.67 with SMTP id eo3mr3612317wib.35.1372950998644; Thu, 04 Jul 2013 08:16:38 -0700 (PDT) Received: from playground.station (net-37-117-148-210.cust.dsl.vodafone.it. [37.117.148.210]) by mx.google.com with ESMTPSA id d8sm4212546wiz.0.2013.07.04.08.16.36 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 04 Jul 2013 08:16:37 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 4 Jul 2013 17:13:58 +0200 Message-Id: <1372950842-32422-63-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1372950842-32422-1-git-send-email-pbonzini@redhat.com> References: <1372950842-32422-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22a Subject: [Qemu-devel] [PATCH 62/66] exec: move listener from AddressSpaceDispatch to AddressSpace X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This will help having two copies of AddressSpaceDispatch during the recreation of the radix tree (one being built, and one that is complete and will be protected by RCU). We do not want to have to unregister and re-register the listener. Reviewed-by: Jan Kiszka 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 598ac3a..2eb279c 100644 --- a/exec.c +++ b/exec.c @@ -93,7 +93,6 @@ struct AddressSpaceDispatch { * The bottom level has pointers to MemoryRegionSections. */ PhysPageEntry phys_map; - MemoryListener listener; AddressSpace *as; }; @@ -841,7 +840,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); @@ -1703,7 +1703,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; } @@ -1772,22 +1773,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; - 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 8355bdb..248c89b 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -209,6 +209,8 @@ struct AddressSpace { int ioeventfd_nb; struct MemoryRegionIoeventfd *ioeventfds; struct AddressSpaceDispatch *dispatch; + MemoryListener dispatch_listener; + QTAILQ_ENTRY(AddressSpace) address_spaces_link; };