diff mbox series

[qemu,v5,18/18] memory: Avoid temporary FlatView allocation in a single child case

Message ID 20170921085110.25598-19-aik@ozlabs.ru
State New
Headers show
Series memory: Store physical root MR in FlatView | expand

Commit Message

Alexey Kardashevskiy Sept. 21, 2017, 8:51 a.m. UTC
The root MR may be enabled but the only child may be not (this is
the case for the PCI bus master address space) so check this and avoid
allocating temporary FV if that nested MR is not enabled.

This does not make any difference though.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 memory.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/memory.c b/memory.c
index 5c21563745..bf71f19fec 100644
--- a/memory.c
+++ b/memory.c
@@ -748,9 +748,14 @@  static FlatView *generate_memory_topology(MemoryRegion *mr)
     int i;
     FlatView *view;
     bool use_empty = false;
+    MemoryRegion *child = QTAILQ_FIRST(&mr->subregions);
 
     if (!mr->enabled) {
         use_empty = true;
+    } else if (child && !child->enabled &&
+               !QTAILQ_NEXT(child, subregions_link) &&
+               !child->addr && int128_eq(child->size, mr->size)) {
+        use_empty = true;
     } else {
         view = flatview_new(mr);
         if (mr) {