[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 24/32] memory: Share special empty FlatView
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 24/32] memory: Share special empty FlatView |
Date: |
Fri, 22 Sep 2017 01:16:32 +0200 |
From: Alexey Kardashevskiy <address@hidden>
This shares an cached empty FlatView among address spaces. The empty
FV is used every time when a root MR renders into a FV without memory
sections which happens when MR or its children are not enabled or
zero-sized. The empty_view is not NULL to keep the rest of memory
API intact; it also has a dispatch tree for the same reason.
On POWER8 with 255 CPUs, 255 virtio-net, 40 PCI bridges guest this halves
the amount of FlatView's in use (557 -> 260) and dispatch tables
(~800000 -> ~370000). In an unrelated experiment with 112 non-virtio
devices on x86 ("-M pc"), only 4 FlatViews are alive, and about ~2000
are created at startup.
Signed-off-by: Alexey Kardashevskiy <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
memory.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/memory.c b/memory.c
index 15b1bd7..5e6351a 100644
--- a/memory.c
+++ b/memory.c
@@ -317,6 +317,7 @@ static void flatview_unref(FlatView *view)
{
if (atomic_fetch_dec(&view->ref) == 1) {
trace_flatview_destroy_rcu(view, view->root);
+ assert(view->root);
call_rcu(view, flatview_destroy, rcu);
}
}
@@ -761,16 +762,19 @@ static MemoryRegion
*memory_region_get_flatview_root(MemoryRegion *mr)
}
}
}
+ if (found == 0) {
+ return NULL;
+ }
if (next) {
mr = next;
continue;
}
}
- break;
+ return mr;
}
- return mr;
+ return NULL;
}
/* Render a memory topology into a list of disjoint absolute ranges. */
@@ -966,12 +970,22 @@ static void
address_space_update_topology_pass(AddressSpace *as,
static void flatviews_init(void)
{
+ static FlatView *empty_view;
+
if (flat_views) {
return;
}
flat_views = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL,
(GDestroyNotify) flatview_unref);
+ if (!empty_view) {
+ empty_view = generate_memory_topology(NULL);
+ /* We keep it alive forever in the global variable. */
+ flatview_ref(empty_view);
+ } else {
+ g_hash_table_replace(flat_views, NULL, empty_view);
+ flatview_ref(empty_view);
+ }
}
static void flatviews_reset(void)
--
1.8.3.1
- [Qemu-devel] [PULL 15/32] memory: Alloc dispatch tree where topology is generared, (continued)
- [Qemu-devel] [PULL 15/32] memory: Alloc dispatch tree where topology is generared, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 11/32] memory: Switch memory from using AddressSpace to FlatView, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 16/32] memory: Move address_space_update_ioeventfds, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 17/32] memory: Share FlatView's and dispatch trees between address spaces, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 18/32] memory: Do not allocate FlatView in address_space_init, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 21/32] memory: Create FlatView directly, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 23/32] memory: seek FlatView sharing candidates among children subregions, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 20/32] memory: Get rid of address_space_init_shareable, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 22/32] memory: trace FlatView creation and destruction, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 19/32] memory: Rework "info mtree" to print flat views and dispatch trees, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 24/32] memory: Share special empty FlatView,
Paolo Bonzini <=
- [Qemu-devel] [PULL 25/32] scsi, file-posix: add support for persistent reservation management, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 29/32] chardev: new qemu_chr_be_update_read_handlers(), Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 28/32] scsi: add persistent reservation manager using qemu-pr-helper, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 30/32] chardev: add Chardev.gcontext field, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 27/32] scsi: add multipath support to qemu-pr-helper, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 26/32] scsi: build qemu-pr-helper, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 31/32] chardev: use per-dev context for io_add_watch_poll, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 32/32] chardev: remove context in chr_update_read_handler, Paolo Bonzini, 2017/09/21