From nobody Mon Nov 3 20:17:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505984680368427.4920102814143; Thu, 21 Sep 2017 02:04:40 -0700 (PDT) Received: from localhost ([::1]:52477 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duxPS-0007Nm-5k for importer@patchew.org; Thu, 21 Sep 2017 05:04:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48587) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duxCw-0005Ca-IZ for qemu-devel@nongnu.org; Thu, 21 Sep 2017 04:51:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duxCu-0001OP-FT for qemu-devel@nongnu.org; Thu, 21 Sep 2017 04:51:42 -0400 Received: from ozlabs.ru ([107.173.13.209]:54112) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duxCu-0001CA-9u for qemu-devel@nongnu.org; Thu, 21 Sep 2017 04:51:40 -0400 Received: from vpl1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 302CE3A60058; Thu, 21 Sep 2017 04:52:56 -0400 (EDT) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Thu, 21 Sep 2017 18:51:09 +1000 Message-Id: <20170921085110.25598-18-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921085110.25598-1-aik@ozlabs.ru> References: <20170921085110.25598-1-aik@ozlabs.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 107.173.13.209 Subject: [Qemu-devel] [PATCH qemu v5 17/18] memory: Create FlatView directly X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This avoids usual memory_region_transaction_commit() which rebuilds all FVs. On POWER8 with 255 CPUs, 255 virtio-net, 40 PCI bridges guest this brings down the boot time from 25s to 20s and reduces the amount of temporary FVs allocated during machine constructon (~800000 -> ~640000) and amount of temporary dispatch trees (~370000 -> ~300000), the total memory footprint goes down (18G -> 17G). Signed-off-by: Alexey Kardashevskiy --- Changes: v5: * %s/flatview_update_topology_single/address_space_update_topology/g * fixup after moving g_hash_table_replace() to generate_memory_topology() --- memory.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/memory.c b/memory.c index 57e47e990f..5c21563745 100644 --- a/memory.c +++ b/memory.c @@ -1027,6 +1027,17 @@ static void address_space_set_flatview(AddressSpace = *as) } } =20 +static void address_space_update_topology(AddressSpace *as) +{ + MemoryRegion *physmr =3D memory_region_get_flatview_root(as->root); + + flatviews_init(); + if (!g_hash_table_lookup(flat_views, physmr)) { + generate_memory_topology(physmr); + } + address_space_set_flatview(as); +} + void memory_region_transaction_begin(void) { qemu_flush_coalesced_mmio_buffer(); @@ -2738,7 +2749,6 @@ void memory_region_invalidate_mmio_ptr(MemoryRegion *= mr, hwaddr offset, void address_space_init(AddressSpace *as, MemoryRegion *root, const char *= name) { memory_region_ref(root); - memory_region_transaction_begin(); as->root =3D root; as->current_map =3D NULL; as->ioeventfd_nb =3D 0; @@ -2746,8 +2756,7 @@ void address_space_init(AddressSpace *as, MemoryRegio= n *root, const char *name) QTAILQ_INIT(&as->listeners); QTAILQ_INSERT_TAIL(&address_spaces, as, address_spaces_link); as->name =3D g_strdup(name ? name : "anonymous"); - memory_region_update_pending |=3D root->enabled; - memory_region_transaction_commit(); + address_space_update_topology(as); } =20 static void do_address_space_destroy(AddressSpace *as) --=20 2.11.0