|
|
9bac43 |
From 34644299c4e930a16b7e0a7725f69b7b83ca600e Mon Sep 17 00:00:00 2001
|
|
|
9bac43 |
From: David Gibson <dgibson@redhat.com>
|
|
|
9bac43 |
Date: Thu, 16 Nov 2017 03:07:31 +0100
|
|
|
9bac43 |
Subject: [PATCH 27/30] memory: seek FlatView sharing candidates among children
|
|
|
9bac43 |
subregions
|
|
|
9bac43 |
|
|
|
9bac43 |
RH-Author: David Gibson <dgibson@redhat.com>
|
|
|
9bac43 |
Message-id: <20171116030732.8560-22-dgibson@redhat.com>
|
|
|
9bac43 |
Patchwork-id: 77708
|
|
|
9bac43 |
O-Subject: [PATCH 21/22] memory: seek FlatView sharing candidates among children subregions
|
|
|
9bac43 |
Bugzilla: 1481593
|
|
|
9bac43 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
A container can be used instead of an alias to allow switching between
|
|
|
9bac43 |
multiple subregions. In this case we cannot directly share the
|
|
|
9bac43 |
subregions (since they only belong to a single parent), but if the
|
|
|
9bac43 |
subregions are aliases we can in turn walk those.
|
|
|
9bac43 |
|
|
|
9bac43 |
This is not enough to remove all source of quadratic FlatView creation,
|
|
|
9bac43 |
but it enables sharing of the PCI bus master FlatViews (and their
|
|
|
9bac43 |
AddressSpaceDispatch structures) across all PCI devices. For 112
|
|
|
9bac43 |
virtio-net-pci devices, boot time is reduced from 25 to 10 seconds and
|
|
|
9bac43 |
memory consumption from 1.4 to 1 G.
|
|
|
9bac43 |
|
|
|
9bac43 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9bac43 |
(cherry picked from commit e673ba9af9bf8fd8e0f44025ac738b8285b3ed27)
|
|
|
9bac43 |
|
|
|
9bac43 |
Signed-off-by: David Gibson <dgibson@redhat.com>
|
|
|
9bac43 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9bac43 |
---
|
|
|
9bac43 |
memory.c | 40 ++++++++++++++++++++++++++++++++++------
|
|
|
9bac43 |
1 file changed, 34 insertions(+), 6 deletions(-)
|
|
|
9bac43 |
|
|
|
9bac43 |
diff --git a/memory.c b/memory.c
|
|
|
9bac43 |
index 8733efc..38eabe7 100644
|
|
|
9bac43 |
--- a/memory.c
|
|
|
9bac43 |
+++ b/memory.c
|
|
|
9bac43 |
@@ -733,12 +733,40 @@ static void render_memory_region(FlatView *view,
|
|
|
9bac43 |
|
|
|
9bac43 |
static MemoryRegion *memory_region_get_flatview_root(MemoryRegion *mr)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
- while (mr->alias && !mr->alias_offset &&
|
|
|
9bac43 |
- int128_ge(mr->size, mr->alias->size)) {
|
|
|
9bac43 |
- /* The alias is included in its entirety. Use it as
|
|
|
9bac43 |
- * the "real" root, so that we can share more FlatViews.
|
|
|
9bac43 |
- */
|
|
|
9bac43 |
- mr = mr->alias;
|
|
|
9bac43 |
+ while (mr->enabled) {
|
|
|
9bac43 |
+ if (mr->alias) {
|
|
|
9bac43 |
+ if (!mr->alias_offset && int128_ge(mr->size, mr->alias->size)) {
|
|
|
9bac43 |
+ /* The alias is included in its entirety. Use it as
|
|
|
9bac43 |
+ * the "real" root, so that we can share more FlatViews.
|
|
|
9bac43 |
+ */
|
|
|
9bac43 |
+ mr = mr->alias;
|
|
|
9bac43 |
+ continue;
|
|
|
9bac43 |
+ }
|
|
|
9bac43 |
+ } else if (!mr->terminates) {
|
|
|
9bac43 |
+ unsigned int found = 0;
|
|
|
9bac43 |
+ MemoryRegion *child, *next = NULL;
|
|
|
9bac43 |
+ QTAILQ_FOREACH(child, &mr->subregions, subregions_link) {
|
|
|
9bac43 |
+ if (child->enabled) {
|
|
|
9bac43 |
+ if (++found > 1) {
|
|
|
9bac43 |
+ next = NULL;
|
|
|
9bac43 |
+ break;
|
|
|
9bac43 |
+ }
|
|
|
9bac43 |
+ if (!child->addr && int128_ge(mr->size, child->size)) {
|
|
|
9bac43 |
+ /* A child is included in its entirety. If it's the only
|
|
|
9bac43 |
+ * enabled one, use it in the hope of finding an alias down the
|
|
|
9bac43 |
+ * way. This will also let us share FlatViews.
|
|
|
9bac43 |
+ */
|
|
|
9bac43 |
+ next = child;
|
|
|
9bac43 |
+ }
|
|
|
9bac43 |
+ }
|
|
|
9bac43 |
+ }
|
|
|
9bac43 |
+ if (next) {
|
|
|
9bac43 |
+ mr = next;
|
|
|
9bac43 |
+ continue;
|
|
|
9bac43 |
+ }
|
|
|
9bac43 |
+ }
|
|
|
9bac43 |
+
|
|
|
9bac43 |
+ break;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
return mr;
|
|
|
9bac43 |
--
|
|
|
9bac43 |
1.8.3.1
|
|
|
9bac43 |
|