{"id":816831,"url":"http://patchwork.ozlabs.org/api/patches/816831/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170921120751.3027-3-pbonzini@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170921120751.3027-3-pbonzini@redhat.com>","list_archive_url":null,"date":"2017-09-21T12:07:50","name":"[2/3] memory: seek FlatView sharing candidates among children subregions","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"8941a1691b5aea861056bc5ba8dc6aea2115fe7c","submitter":{"id":2701,"url":"http://patchwork.ozlabs.org/api/people/2701/?format=json","name":"Paolo Bonzini","email":"pbonzini@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170921120751.3027-3-pbonzini@redhat.com/mbox/","series":[{"id":4365,"url":"http://patchwork.ozlabs.org/api/series/4365/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=4365","date":"2017-09-21T12:07:49","name":"FlatView memory savings","version":1,"mbox":"http://patchwork.ozlabs.org/series/4365/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/816831/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/816831/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx05.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx05.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=pbonzini@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xyb7r1zWJz9t43\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 22:11:52 +1000 (AEST)","from localhost ([::1]:53395 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dv0Kc-0005Cz-9L\n\tfor incoming@patchwork.ozlabs.org; Thu, 21 Sep 2017 08:11:50 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:39266)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <pbonzini@redhat.com>) id 1dv0Gs-0002GT-FK\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 08:08:04 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <pbonzini@redhat.com>) id 1dv0Gq-00026C-QQ\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 08:07:58 -0400","from mx1.redhat.com ([209.132.183.28]:53126)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <pbonzini@redhat.com>) id 1dv0Gq-00024j-Ke\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 08:07:56 -0400","from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id B0A112CE907;\n\tThu, 21 Sep 2017 12:07:55 +0000 (UTC)","from donizetti.redhat.com (ovpn-117-52.ams2.redhat.com\n\t[10.36.117.52])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id E967C5EDF8;\n\tThu, 21 Sep 2017 12:07:54 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com B0A112CE907","From":"Paolo Bonzini <pbonzini@redhat.com>","To":"qemu-devel@nongnu.org","Date":"Thu, 21 Sep 2017 14:07:50 +0200","Message-Id":"<20170921120751.3027-3-pbonzini@redhat.com>","In-Reply-To":"<20170921120751.3027-1-pbonzini@redhat.com>","References":"<20170921120751.3027-1-pbonzini@redhat.com>","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.15","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.29]);\n\tThu, 21 Sep 2017 12:07:55 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"[Qemu-devel] [PATCH 2/3] memory: seek FlatView sharing candidates\n\tamong children subregions","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"aik@ozlabs.ru","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"A container can be used instead of an alias to allow switching between\nmultiple subregions.  In this case we cannot directly share the\nsubregions (since they only belong to a single parent), but if the\nsubregions are aliases we can in turn walk those.\n\nWhile this does not reduce much the number of FlatViews that are created,\nit makes it possible to share the PCI bus master FlatViews and their\nAddressSpaceDispatch structures.  For 112 virtio-net-pci devices, boot time\nis reduced from 25 to 10 seconds and memory consumption from 1.4 to 1 G.\n\nSigned-off-by: Paolo Bonzini <pbonzini@redhat.com>\n---\n memory.c | 41 +++++++++++++++++++++++++++++++++++------\n 1 file changed, 35 insertions(+), 6 deletions(-)","diff":"diff --git a/memory.c b/memory.c\nindex 4952cc5d84..3207ae55e2 100644\n--- a/memory.c\n+++ b/memory.c\n@@ -733,12 +733,41 @@ static void render_memory_region(FlatView *view,\n \n static MemoryRegion *memory_region_get_flatview_root(MemoryRegion *mr)\n {\n-    while (mr->alias && !mr->alias_offset &&\n-           int128_ge(mr->size, mr->alias->size)) {\n-        /* The alias is included in its entirety.  Use it as\n-         * the \"real\" root, so that we can share more FlatViews.\n-         */\n-        mr = mr->alias;\n+    while (mr->enabled) {\n+        if (mr->alias && !mr->alias_offset &&\n+            int128_ge(mr->size, mr->alias->size)) {\n+            /* The alias is included in its entirety.  Use it as\n+             * the \"real\" root, so that we can share more FlatViews.\n+             */\n+            mr = mr->alias;\n+            continue;\n+        }\n+\n+        if (!mr->terminates) {\n+            unsigned int found = 0;\n+            MemoryRegion *child, *next = NULL;\n+            QTAILQ_FOREACH(child, &mr->subregions, subregions_link) {\n+                if (child->enabled) {\n+                    if (++found > 1) {\n+                        next = NULL;\n+                        break;\n+                    }\n+                    if (!child->addr && int128_ge(mr->size, child->size)) {\n+                        /* A child is included in its entirety.  If it's the only\n+                         * enabled one, use it in the hope of finding an alias down the\n+                         * way. This will also let us share FlatViews.\n+                         */\n+                        next = child;\n+                    }\n+                }\n+            }\n+            if (next) {\n+                mr = next;\n+                continue;\n+            }\n+        }\n+\n+        break;\n     }\n \n     return mr;\n","prefixes":["2/3"]}