qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 13/15] exec: use mmap for PhysPageMap->nodes


From: Peter Lieven
Subject: [Qemu-devel] [PATCH 13/15] exec: use mmap for PhysPageMap->nodes
Date: Tue, 28 Jun 2016 11:01:37 +0200

this was causing serious framentation in conjunction with the
subpages since RCU was introduced. The node space was allocated
at approx 32kB then reallocted to approx 75kB and this a few hundred
times at startup. And thanks to RCU the freeing was delayed.

Signed-off-by: Peter Lieven <address@hidden>
---
 exec.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/exec.c b/exec.c
index 1b7be2a..b4bcf47 100644
--- a/exec.c
+++ b/exec.c
@@ -189,9 +189,11 @@ struct CPUAddressSpace {
 static void phys_map_node_reserve(PhysPageMap *map, unsigned nodes)
 {
     if (map->nodes_nb + nodes > map->nodes_nb_alloc) {
+        size_t old_size = map->nodes_nb_alloc * sizeof(Node);
         map->nodes_nb_alloc = MAX(map->nodes_nb_alloc * 2, 16);
         map->nodes_nb_alloc = MAX(map->nodes_nb_alloc, map->nodes_nb + nodes);
-        map->nodes = g_renew(Node, map->nodes, map->nodes_nb_alloc);
+        map->nodes = qemu_anon_ram_remap(map->nodes, old_size,
+                                         sizeof(Node) * map->nodes_nb_alloc);
     }
 }
 
@@ -1162,7 +1164,7 @@ static void phys_sections_free(PhysPageMap *map)
         phys_section_destroy(section->mr);
     }
     g_free(map->sections);
-    g_free(map->nodes);
+    qemu_anon_ram_munmap(map->nodes, map->nodes_nb_alloc * sizeof(Node));
 }
 
 static void register_subpage(AddressSpaceDispatch *d, MemoryRegionSection 
*section)
-- 
1.9.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]