aboutsummaryrefslogtreecommitdiff
path: root/memory.c
diff options
context:
space:
mode:
authorAlexey Kardashevskiy <aik@ozlabs.ru>2017-09-21 18:50:54 +1000
committerPaolo Bonzini <pbonzini@redhat.com>2017-09-21 23:19:37 +0200
commit9a62e24f45bc97f8eaf198caf58906b47c50a8d5 (patch)
treeac7aae8c704105a4e8511154c93ddbca2de950d3 /memory.c
parente76bb18f7e430e0c50fb38d051feacf268bd78f4 (diff)
memory: Open code FlatView rendering
We are going to share FlatView's between AddressSpace's and per-AS memory listeners won't suit the purpose anymore so open code the dispatch tree rendering. Since there is a good chance that dispatch_listener was the only listener, this avoids address_space_update_topology_pass() if there is no registered listeners; this should improve starting time. This should cause no behavioural change. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Message-Id: <20170921085110.25598-3-aik@ozlabs.ru> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'memory.c')
-rw-r--r--memory.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/memory.c b/memory.c
index 51f54ab430..3241e449e7 100644
--- a/memory.c
+++ b/memory.c
@@ -884,14 +884,24 @@ static void address_space_update_topology_pass(AddressSpace *as,
}
}
-
static void address_space_update_topology(AddressSpace *as)
{
FlatView *old_view = address_space_get_flatview(as);
FlatView *new_view = generate_memory_topology(as->root);
+ int i;
- address_space_update_topology_pass(as, old_view, new_view, false);
- address_space_update_topology_pass(as, old_view, new_view, true);
+ mem_begin(as);
+ for (i = 0; i < new_view->nr; i++) {
+ MemoryRegionSection mrs =
+ section_from_flat_range(&new_view->ranges[i], as);
+ mem_add(as, &mrs);
+ }
+ mem_commit(as);
+
+ if (!QTAILQ_EMPTY(&as->listeners)) {
+ address_space_update_topology_pass(as, old_view, new_view, false);
+ address_space_update_topology_pass(as, old_view, new_view, true);
+ }
/* Writes are protected by the BQL. */
atomic_rcu_set(&as->current_map, new_view);
@@ -2626,7 +2636,7 @@ void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name)
QTAILQ_INIT(&as->listeners);
QTAILQ_INSERT_TAIL(&address_spaces, as, address_spaces_link);
as->name = g_strdup(name ? name : "anonymous");
- address_space_init_dispatch(as);
+ as->dispatch = NULL;
memory_region_update_pending |= root->enabled;
memory_region_transaction_commit();
}
@@ -2677,7 +2687,6 @@ void address_space_destroy(AddressSpace *as)
as->root = NULL;
memory_region_transaction_commit();
QTAILQ_REMOVE(&address_spaces, as, address_spaces_link);
- address_space_unregister(as);
/* At this point, as->dispatch and as->current_map are dummy
* entries that the guest should never use. Wait for the old