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 1506037066880237.96722762627758; Thu, 21 Sep 2017 16:37:46 -0700 (PDT) Received: from localhost ([::1]:55950 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvB2P-0005fc-Pt for importer@patchew.org; Thu, 21 Sep 2017 19:37:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAiX-0004uP-2J for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:17:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAiW-0004TZ-3K for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:17:13 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:35743) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dvAiV-0004SU-Sb for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:17:12 -0400 Received: by mail-wm0-x244.google.com with SMTP id e64so6456852wmi.2 for ; Thu, 21 Sep 2017 16:17:11 -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.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 16:17:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=NOnw5MaoK+euvPHQsq6zeKgOCjDOGpSGqZnRUahr4Ls=; b=MUeauWds5csG9qP7286haW0ABqelsaeso2ZftfrV+xl3PO0xxi+jJzl6wiOrJed937 Al2oWZQuUzYem8Hd8OxXNj/bYDYEm/ilmmfuUFe8z5gScbn57qBXab41X920jTiKTti0 bPuXnsif7Uje0cx6B6cSfAKRoau5vjSwWUgw2VDuaRyw00C6Fz0byXohezHW8iSmruvA LpoSU0BPX8FKUkWNLQIbzUJwlV1DncQQHOsxneuvXkJGTr/6taA054GVCJB/bW7XGVQF yM0/BKNpratOgumELy/Jr5xvG2udpAHF3gUYCHDAq6UzV/7uE6Ch2jvcm8sqZ3soQabO w1/A== 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:subject:date:message-id :in-reply-to:references; bh=NOnw5MaoK+euvPHQsq6zeKgOCjDOGpSGqZnRUahr4Ls=; b=od3/u3dKx+HuT9/afv5FQS1nCAHAWTurpYMxUk4IAM3vdREIixAAenqN2lhc++8MdX P7WytLP2yQgLy6mQfeQJkbiZYAQih4STlPmVl3qV+En6NMSRTF5XTeDiqt5/MRc9Hw4B fTypjXU0PCu0eBPQRfgPNNCohtbnG6fnhXJMIujq6TIraOpj8zTg156byTykwZ0MOn6w 7NfmejowOvsIqpi8sYo50NUV5GTbDGyJvlIeETjiZdXpKGKKFytgn3SRbWmfBjZ/9gko KUl8VRMPLQr+6aYiL8pwUPDtPhlGeECkNJ6lSNjticJoW6CIATpm5LfoVWlExE+0aZQn UKJA== X-Gm-Message-State: AHPjjUikkFsnQvZsLgl+bpOX4rrNCvaQsvji9GsFY+NPcB9xoIp6TSjg Dfywc+hdhUrLcDDOJVIQYzRomXMl X-Google-Smtp-Source: AOwi7QAl+6NiIRKWBbZxEto9mLAexaEy+JY1lFChpNQ8897hsOdAEgo50UsgrkpWlUKxFwDJpQgKBw== X-Received: by 10.28.220.85 with SMTP id t82mr2265619wmg.95.1506035830609; Thu, 21 Sep 2017 16:17:10 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:16:31 +0200 Message-Id: <1506035800-30509-24-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:c09::244 Subject: [Qemu-devel] [PULL 23/32] memory: seek FlatView sharing candidates among children subregions 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: , 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" A container can be used instead of an alias to allow switching between multiple subregions. In this case we cannot directly share the subregions (since they only belong to a single parent), but if the subregions are aliases we can in turn walk those. This is not enough to remove all source of quadratic FlatView creation, but it enables sharing of the PCI bus master FlatViews (and their AddressSpaceDispatch structures) across all PCI devices. For 112 virtio-net-pci devices, boot time is reduced from 25 to 10 seconds and memory consumption from 1.4 to 1 G. Signed-off-by: Paolo Bonzini --- memory.c | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/memory.c b/memory.c index 68cdf8b..15b1bd7 100644 --- a/memory.c +++ b/memory.c @@ -734,12 +734,40 @@ static void render_memory_region(FlatView *view, =20 static MemoryRegion *memory_region_get_flatview_root(MemoryRegion *mr) { - while (mr->alias && !mr->alias_offset && - int128_ge(mr->size, mr->alias->size)) { - /* The alias is included in its entirety. Use it as - * the "real" root, so that we can share more FlatViews. - */ - mr =3D mr->alias; + while (mr->enabled) { + if (mr->alias) { + if (!mr->alias_offset && int128_ge(mr->size, mr->alias->size))= { + /* The alias is included in its entirety. Use it as + * the "real" root, so that we can share more FlatViews. + */ + mr =3D mr->alias; + continue; + } + } else if (!mr->terminates) { + unsigned int found =3D 0; + MemoryRegion *child, *next =3D NULL; + QTAILQ_FOREACH(child, &mr->subregions, subregions_link) { + if (child->enabled) { + if (++found > 1) { + next =3D NULL; + break; + } + if (!child->addr && int128_ge(mr->size, child->size)) { + /* A child is included in its entirety. If it's t= he only + * enabled one, use it in the hope of finding an a= lias down the + * way. This will also let us share FlatViews. + */ + next =3D child; + } + } + } + if (next) { + mr =3D next; + continue; + } + } + + break; } =20 return mr; --=20 1.8.3.1