From patchwork Thu Jul 4 15:14:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 256949 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 DDF9A2C0091 for ; Fri, 5 Jul 2013 01:41:35 +1000 (EST) Received: from localhost ([::1]:55072 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uulf3-0005WT-V4 for incoming@patchwork.ozlabs.org; Thu, 04 Jul 2013 11:41:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UulH3-0003QH-Q3 for qemu-devel@nongnu.org; Thu, 04 Jul 2013 11:16:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UulH1-00067Z-Qh for qemu-devel@nongnu.org; Thu, 04 Jul 2013 11:16:45 -0400 Received: from mail-we0-x22f.google.com ([2a00:1450:400c:c03::22f]:41444) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UulH1-00067B-JD for qemu-devel@nongnu.org; Thu, 04 Jul 2013 11:16:43 -0400 Received: by mail-we0-f175.google.com with SMTP id t59so1216632wes.20 for ; Thu, 04 Jul 2013 08:16:43 -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=2YdEhO489XPe19HON5ocvIjtKuvUIjyFhSOmqpXhNmw=; b=eJ5CSFeQohD2OqnkOanevIxdhZ//NEZYRd3DS2b2s++Wa3KjU1xRKZMaZ7iE6Owzef +i9uSgLV9oq2UBmB7t3vUIHaBgOYo/AxRaQvIahQuLKSOGlllgv5Xlnp5Mw7+c33z8iP ntUXgEAFI+MeTJ9fQhyA6DxWSBVcqvnZKAlkT/RNKEk2FOtjl4e0jpd0AkGAq8b1K0rn b+MqDCdE9IHQ+2MKEPVeg4aXqfm4v29uJj/LgRunBw/uRhBCstNG0KnBUa4RwaJOljnc oXefIsTIqbGGxkA2kJQkZnYI8DXnRc2JaADQ0M1hN+BwUKBQVDqKEWCz/l6qTqr9Yccj BPuA== X-Received: by 10.194.109.104 with SMTP id hr8mr3843085wjb.32.1372951002977; Thu, 04 Jul 2013 08:16:42 -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.40 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 04 Jul 2013 08:16:42 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 4 Jul 2013 17:14:00 +0200 Message-Id: <1372950842-32422-65-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:c03::22f Subject: [Qemu-devel] [PATCH 64/66] exec: put memory map in AddressSpaceDispatch 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 After this patch, AddressSpaceDispatch holds a constistent tuple of (phys_map, nodes, sections). This will be important when updates of the topology will run concurrently with reads. cur_map is not used anymore except for freeing it at the end of the topology update. Signed-off-by: Paolo Bonzini --- exec.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/exec.c b/exec.c index bd05c40..6d3492e 100644 --- a/exec.c +++ b/exec.c @@ -88,11 +88,15 @@ struct PhysPageEntry { uint16_t ptr : 15; }; +typedef PhysPageEntry Node[L2_SIZE]; + struct AddressSpaceDispatch { /* This is a multi-level map on the physical address space. * The bottom level has pointers to MemoryRegionSections. */ PhysPageEntry phys_map; + Node *nodes; + MemoryRegionSection *sections; AddressSpace *as; }; @@ -109,8 +113,6 @@ typedef struct subpage_t { #define PHYS_SECTION_ROM 2 #define PHYS_SECTION_WATCH 3 -typedef PhysPageEntry Node[L2_SIZE]; - typedef struct PhysPageMap { unsigned sections_nb; unsigned sections_nb_alloc; @@ -232,14 +234,15 @@ static MemoryRegionSection *address_space_lookup_region(AddressSpace *as, hwaddr addr, bool resolve_subpage) { + AddressSpaceDispatch *d = as->dispatch; MemoryRegionSection *section; subpage_t *subpage; - section = phys_page_find(as->dispatch->phys_map, addr >> TARGET_PAGE_BITS, - cur_map.nodes, cur_map.sections); + section = phys_page_find(d->phys_map, addr >> TARGET_PAGE_BITS, + d->nodes, d->sections); if (resolve_subpage && section->mr->subpage) { subpage = container_of(section->mr, subpage_t, iomem); - section = &cur_map.sections[subpage->sub_section[SUBPAGE_IDX(addr)]]; + section = &d->sections[subpage->sub_section[SUBPAGE_IDX(addr)]]; } return section; } @@ -730,7 +733,7 @@ hwaddr memory_region_section_get_iotlb(CPUArchState *env, iotlb |= PHYS_SECTION_ROM; } } else { - iotlb = section - cur_map.sections; + iotlb = section - address_space_memory.dispatch->sections; iotlb += xlat; } @@ -1687,7 +1690,7 @@ static uint16_t dummy_section(MemoryRegion *mr) MemoryRegion *iotlb_to_region(hwaddr index) { - return cur_map.sections[index & ~TARGET_PAGE_MASK].mr; + return address_space_memory.dispatch->sections[index & ~TARGET_PAGE_MASK].mr; } static void io_mem_init(void) @@ -1714,11 +1717,14 @@ static void mem_begin(MemoryListener *listener) static void mem_commit(MemoryListener *listener) { AddressSpace *as = container_of(listener, AddressSpace, dispatch_listener); - AddressSpaceDispatch *d = as->dispatch; + AddressSpaceDispatch *cur = as->dispatch; + AddressSpaceDispatch *next = as->next_dispatch; - /* cur_map will soon be switched to next_map, too. */ - as->dispatch = as->next_dispatch; - g_free(d); + next->nodes = next_map.nodes; + next->sections = next_map.sections; + + as->dispatch = next; + g_free(cur); } static void core_begin(MemoryListener *listener)