Message ID | 1467104499-27517-14-git-send-email-pl@kamp.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 28/06/2016 11:01, Peter Lieven wrote: > 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 <pl@kamp.de> The size of the node from the previous as->dispatch could be used as a hint for the new one perhaps, avoiding the reallocation? Paolo
Am 28.06.2016 um 12:43 schrieb Paolo Bonzini: > > On 28/06/2016 11:01, Peter Lieven wrote: >> 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 <pl@kamp.de> > The size of the node from the previous as->dispatch could be used as a > hint for the new one perhaps, avoiding the reallocation? I will figure that out. But still all the PhyPageMaps are allocated before they are freed. Or are you fine with using mmap here? Peter
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)
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 <pl@kamp.de> --- exec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)