[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v5 04/86] memory: merge adjacent segments of a single
From: |
Avi Kivity |
Subject: |
[Qemu-devel] [RFC v5 04/86] memory: merge adjacent segments of a single memory region |
Date: |
Wed, 20 Jul 2011 19:49:14 +0300 |
Simple implementations of memory routers, for example the Cirrus VGA memory
banks
or the 440FX PAM registers can generate adjacent memory regions which are
contiguous.
Detect these and merge them; this saves kvm memory slots and shortens lookup
times.
Signed-off-by: Avi Kivity <address@hidden>
---
memory.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/memory.c b/memory.c
index a569666..339bea3 100644
--- a/memory.c
+++ b/memory.c
@@ -122,6 +122,27 @@ static void flatview_destroy(FlatView *view)
qemu_free(view->ranges);
}
+/* Attempt to simplify a view by merging ajacent ranges */
+static void flatview_simplify(FlatView *view)
+{
+ unsigned i;
+ FlatRange *r1, *r2;
+
+ for (i = 0; i + 1 < view->nr; ++i) {
+ r1 = &view->ranges[i];
+ r2 = &view->ranges[i+1];
+ if (addrrange_end(r1->addr) == r2->addr.start
+ && r1->mr == r2->mr
+ && r1->offset_in_region + r1->addr.size == r2->offset_in_region
+ && r1->dirty_log_mask == r2->dirty_log_mask) {
+ r1->addr.size += r2->addr.size;
+ memmove(r2, r2 + 1, (view->nr - (i + 2)) * sizeof(*r2));
+ --view->nr;
+ --i;
+ }
+ }
+}
+
/* Render a memory region into the global view. Ranges in @view obscure
* ranges in @mr.
*/
@@ -209,6 +230,7 @@ static FlatView generate_memory_topology(MemoryRegion *mr)
flatview_init(&view);
render_memory_region(&view, mr, 0, addrrange_make(0, UINT64_MAX));
+ flatview_simplify(&view);
return view;
}
--
1.7.5.3
- [Qemu-devel] [RFC v5 00/86] Memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 01/86] xen: fix xen-mapcache build on non-Xen capable targets, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 04/86] memory: merge adjacent segments of a single memory region,
Avi Kivity <=
- [Qemu-devel] [RFC v5 13/86] memory: separate building the final memory map into two steps, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 74/86] ppc405_uc: convert to memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 16/86] pc: grab system_memory, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 69/86] gt64xxx.c: convert to memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 34/86] pci: allow I/O BARs to be registered with pci_register_bar_region(), Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 18/86] pc: move global memory map out of pc_init1() and into its callers, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 83/86] isa: add isa_address_space(), Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 26/86] cirrus: simplify mmio BAR access functions, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 25/86] vga: convert vga and its derivatives to the memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 12/86] memory: add ioeventfd support, Avi Kivity, 2011/07/20