From nobody Wed Feb 11 06:50:07 2026 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; dkim=fail; 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 150603683515455.830923019409056; Thu, 21 Sep 2017 16:33:55 -0700 (PDT) Received: from localhost ([::1]:55932 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAyd-0002Lh-9F for importer@patchew.org; Thu, 21 Sep 2017 19:33:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAiS-0004pZ-MF for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:17:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAiQ-0004LF-Dw for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:17:08 -0400 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:34312) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dvAiQ-0004KI-7O for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:17:06 -0400 Received: by mail-wr0-x241.google.com with SMTP id k20so3843971wre.1 for ; Thu, 21 Sep 2017 16:17:06 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-246-117.clienti.tiscali.it. [78.12.246.117]) by smtp.gmail.com with ESMTPSA id u186sm2596278wmd.19.2017.09.21.16.17.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 16:17:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=PwFVLUBKmvWq/O7gtImVjNXoIP/0PHgaf/95Dg7lUtA=; b=K8fuuMg8Gls/lvs8FNFVAH2FB86A8ry7QHHsGIfzOxoab1+hR10/CQLO6x6G3ErTFz 4h9Q1XqOUiDk2ibTCIHg3kIsfMgWLJ/s/mJULBAjJSW2iqv6jLTE7oh5ocgw5K9Zxyel Oem0ldosOmicksNOe2Ndl0njKKlJnmjvluJ+R1Ez7i46apfXrEbQmsXNThH9ygEH0dPX POIdERg4Mcl/GjRw9ix47MkDm6Kn6g6DTzVz/YCVWecblBwfs8vmWKp2ByaudqgDDx3Y 2sDgLR1buAwxt067BXoewJWjTZWg49iZ0E/+vDErbGG0CCfgNxsQlkicXfiiw3FyJ1MK wjLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=PwFVLUBKmvWq/O7gtImVjNXoIP/0PHgaf/95Dg7lUtA=; b=BlKdG1cBInz9PAcLbeccxlbzcnULD8m3iC12kDgN6Xp3wQPONG0sG+KfvwmLY9kZ2O I4X9+peQMc86h22gwhDfrAm4a8vzeQ1Y9I+oFV3+RCo9RFCTnBC30InqIL/Lf51peysA cbdZTq+qiPPo9jprTP7RPfskRClTaGOMFczWD1dRbGa5Sr1uUDiy8dnQTlE5CR30Bxc1 ps+wy4vVnCNI0LBsb6ZsBfvU//jQFEotOYWGQJV40L88ecJx1kYKG9K1kb6C2p0xgT1/ qugvSPsIgjHirdK4am9KyKXTpSOKFhUdNYPl2utyjThJNSCqqW/7j4iSPVL8eDkRM2Wk BOdw== X-Gm-Message-State: AHPjjUgJh+efuQVjvyVPnhGI+gnZjEKWnhBwz20OjtX54TA5Vym59ntV nJEU6GtnDYPd1YOsk4dPKrgk4HCa X-Google-Smtp-Source: AOwi7QCJX/hbvIB6VleOViuDx+/v9m/4TbGLdd0rkJ6Wc/qado/Zd8hOmW+nnlCM9x4WdFbG6aYX4w== X-Received: by 10.223.175.230 with SMTP id y38mr2976156wrd.213.1506035825020; Thu, 21 Sep 2017 16:17:05 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:16:26 +0200 Message-Id: <1506035800-30509-19-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1506035800-30509-1-git-send-email-pbonzini@redhat.com> References: <1506035800-30509-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 18/32] memory: Do not allocate FlatView in address_space_init 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alexey Kardashevskiy This creates a new AS object without any FlatView as memory_region_transaction_commit() may want to reuse the empty FV. Signed-off-by: Alexey Kardashevskiy Message-Id: <20170921085110.25598-14-aik@ozlabs.ru> Signed-off-by: Paolo Bonzini --- memory.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/memory.c b/memory.c index 8ee3c81..3f6dd40 100644 --- a/memory.c +++ b/memory.c @@ -967,22 +967,37 @@ static void flatviews_reset(void) =20 static void address_space_set_flatview(AddressSpace *as) { - FlatView *old_view =3D address_space_get_flatview(as); + FlatView *old_view =3D address_space_to_flatview(as); MemoryRegion *physmr =3D memory_region_get_flatview_root(as->root); FlatView *new_view =3D g_hash_table_lookup(flat_views, physmr); =20 assert(new_view); =20 + if (old_view =3D=3D new_view) { + return; + } + + if (old_view) { + flatview_ref(old_view); + } + flatview_ref(new_view); =20 if (!QTAILQ_EMPTY(&as->listeners)) { - address_space_update_topology_pass(as, old_view, new_view, false); - address_space_update_topology_pass(as, old_view, new_view, true); + FlatView tmpview =3D { .nr =3D 0 }, *old_view2 =3D old_view; + + if (!old_view2) { + old_view2 =3D &tmpview; + } + address_space_update_topology_pass(as, old_view2, new_view, false); + address_space_update_topology_pass(as, old_view2, new_view, true); } =20 /* Writes are protected by the BQL. */ atomic_rcu_set(&as->current_map, new_view); - flatview_unref(old_view); + if (old_view) { + flatview_unref(old_view); + } =20 /* Note that all the old MemoryRegions are still alive up to this * point. This relieves most MemoryListeners from the need to @@ -990,7 +1005,9 @@ static void address_space_set_flatview(AddressSpace *a= s) * outside the iothread mutex, in which case precise reference * counting is necessary. */ - flatview_unref(old_view); + if (old_view) { + flatview_unref(old_view); + } } =20 void memory_region_transaction_begin(void) @@ -2708,7 +2725,7 @@ void address_space_init(AddressSpace *as, MemoryRegio= n *root, const char *name) as->ref_count =3D 1; as->root =3D root; as->malloced =3D false; - as->current_map =3D flatview_new(root); + as->current_map =3D NULL; as->ioeventfd_nb =3D 0; as->ioeventfds =3D NULL; QTAILQ_INIT(&as->listeners); --=20 1.8.3.1