Received: from eggs.gnu.org ([2001:4830:134:3::10]:34731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHouG-0006lN-Mn for qemu-devel@nongnu.org; Tue, 28 Jun 2016 05:02:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHou9-0003Lw-Te for qemu-devel@nongnu.org; Tue, 28 Jun 2016 05:02:08 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:50862 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHou9-0003Lk-KV for qemu-devel@nongnu.org; Tue, 28 Jun 2016 05:02:01 -0400 From: Peter Lieven Date: Tue, 28 Jun 2016 11:01:37 +0200 Message-Id: <1467104499-27517-14-git-send-email-pl@kamp.de> In-Reply-To: <1467104499-27517-1-git-send-email-pl@kamp.de> References: <1467104499-27517-1-git-send-email-pl@kamp.de> Subject: [Qemu-devel] [PATCH 13/15] exec: use mmap for PhysPageMap->nodes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, mreitz@redhat.com, pbonzini@redhat.com, mst@redhat.com, dgilbert@redhat.com, peter.maydell@linaro.org, kraxel@redhat.com, Peter Lieven 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 --- 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