[{"id":1772813,"web_url":"http://patchwork.ozlabs.org/comment/1772813/","msgid":"<1d5f2bb4-c330-98b9-bf1a-6024a9f9093d@ozlabs.ru>","list_archive_url":null,"date":"2017-09-21T13:39:25","subject":"Re: [Qemu-devel] [PATCH 2/3] memory: seek FlatView sharing\n\tcandidates among children subregions","submitter":{"id":7621,"url":"http://patchwork.ozlabs.org/api/people/7621/","name":"Alexey Kardashevskiy","email":"aik@ozlabs.ru"},"content":"On 21/09/17 22:07, Paolo Bonzini wrote:\n> A container can be used instead of an alias to allow switching between\n> multiple subregions.  In this case we cannot directly share the\n> subregions (since they only belong to a single parent), but if the\n> subregions are aliases we can in turn walk those.\n> \n> While this does not reduce much the number of FlatViews that are created,\n> it makes it possible to share the PCI bus master FlatViews and their\n> AddressSpaceDispatch structures.  For 112 virtio-net-pci devices, boot time\n> is reduced from 25 to 10 seconds and memory consumption from 1.4 to 1 G.\n> \n> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>\n> ---\n>  memory.c | 41 +++++++++++++++++++++++++++++++++++------\n>  1 file changed, 35 insertions(+), 6 deletions(-)\n> \n> diff --git a/memory.c b/memory.c\n> index 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\nCan an MR have terminates==true and children by the same time? If so, what for?\n\n\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\n\nAh, I tried this one but in v4's 18/18 (that hinting thing), did not work\nout but for a different reason.\n\n\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>","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>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ozlabs-ru.20150623.gappssmtp.com\n\theader.i=@ozlabs-ru.20150623.gappssmtp.com\n\theader.b=\"ReiG8YSH\"; dkim-atps=neutral"],"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 3xydGQ0Z9zz9ryr\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 23:47:42 +1000 (AEST)","from localhost ([::1]:53818 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 1dv1pM-0006NA-8S\n\tfor incoming@patchwork.ozlabs.org; Thu, 21 Sep 2017 09:47:40 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:33721)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <aik@ozlabs.ru>) id 1dv1hW-0008S0-E1\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 09:39:40 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <aik@ozlabs.ru>) id 1dv1hT-00075w-9t\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 09:39:34 -0400","from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:33132)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <aik@ozlabs.ru>) id 1dv1hT-00075R-0l\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 09:39:31 -0400","by mail-pg0-x242.google.com with SMTP id i130so3459630pgc.0\n\tfor <qemu-devel@nongnu.org>; Thu, 21 Sep 2017 06:39:30 -0700 (PDT)","from [192.168.10.22] (124-171-134-202.dyn.iinet.net.au.\n\t[124.171.134.202]) by smtp.googlemail.com with ESMTPSA id\n\ts81sm3797254pfg.162.2017.09.21.06.39.27\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tThu, 21 Sep 2017 06:39:29 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ozlabs-ru.20150623.gappssmtp.com; s=20150623;\n\th=subject:to:references:from:message-id:date:user-agent:mime-version\n\t:in-reply-to:content-language:content-transfer-encoding;\n\tbh=PFRH6mL0NLT50vm5b5n7Ge3zCPHEPkzst4Mdbu/aLD4=;\n\tb=ReiG8YSH6UFIHIchThgmAiL7/OukzpGOjcAZpeBQUS/DFjqHh2TktPe35RMCrodnzC\n\ttkdCW/gPRm+xjfF3lU3nJSZBMNbeV6qzBYu8j13DjgLa0BCGdfXNR4HSh+MaTqiUcnvT\n\t05jeGOctmry2FZIORZGy2ZDQ9+Z/6/cTNYWBQWlo+pY3Z6WMmotlaH9LtWnnu6677hrW\n\tmEnaS+eW2titXruQoZ+hcYb7ERlUfbRGjYv/0UsIc8utXkQtcfQbgPssvaMXxF2Yeh0b\n\tG1jDw0Pe1s9dmIZIWDmDTNNAk42sxab8T2JJlmkX0vSjzs3w/FIXthDGjz5M6yVSULDH\n\tHpKQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:subject:to:references:from:message-id:date\n\t:user-agent:mime-version:in-reply-to:content-language\n\t:content-transfer-encoding;\n\tbh=PFRH6mL0NLT50vm5b5n7Ge3zCPHEPkzst4Mdbu/aLD4=;\n\tb=bwqIPzOjNTORh+ypJHOL03dV57UYknHKxjFshayXu6HAwd5r0/iFM5w/gzjffW5tJh\n\t0ToE6t+EEeofv7Il2Qi3vRY7X5MQx2gYm8qS/cTYiozSyTvP11vHyEpA7at9tzxiph1a\n\tMqO6G2x9GGzP3f52wtBZchwocgYTZfXJIZeQleJQJwVx5BdHaE2QChoI6eaTeHF2Kl0h\n\trk1kznaDDdRudCInt1CMbqdtqu8zUdxG7IBqDFWmvggOBk4NMFGZ9ILU+wu4A63mqG6c\n\tEmm/U3RtLqjSEXBd9iS3BBvBYLbaraVZnAGPlUqJNsTO7QueMibigCBblQC7njgikp1s\n\t1Zhg==","X-Gm-Message-State":"AHPjjUgP6RBUXz99G+7N5l6OuDjBAldtpnwiDX7AiNzCTtWGpsdPf/WB\n\tMvJcbAMWQTYEkSn/Cb5aHdQg1EWj","X-Google-Smtp-Source":"AOwi7QCWfEhHkzqn1IIFRZHc3rT08LnlBDt1rP7NHzeIGR54hMtUJnvT5fDcAwQTWd65nKS2E2dYXg==","X-Received":"by 10.99.1.10 with SMTP id 10mr5686174pgb.377.1506001169626;\n\tThu, 21 Sep 2017 06:39:29 -0700 (PDT)","To":"Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org","References":"<20170921120751.3027-1-pbonzini@redhat.com>\n\t<20170921120751.3027-3-pbonzini@redhat.com>","From":"Alexey Kardashevskiy <aik@ozlabs.ru>","Message-ID":"<1d5f2bb4-c330-98b9-bf1a-6024a9f9093d@ozlabs.ru>","Date":"Thu, 21 Sep 2017 23:39:25 +1000","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.2.1","MIME-Version":"1.0","In-Reply-To":"<20170921120751.3027-3-pbonzini@redhat.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-AU","Content-Transfer-Encoding":"7bit","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"2607:f8b0:400e:c05::242","Subject":"Re: [Qemu-devel] [PATCH 2/3] memory: seek FlatView sharing\n\tcandidates among 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>","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>"}},{"id":1772819,"web_url":"http://patchwork.ozlabs.org/comment/1772819/","msgid":"<d29597cd-773d-3268-4d27-a2f68c895d14@redhat.com>","list_archive_url":null,"date":"2017-09-21T13:57:15","subject":"Re: [Qemu-devel] [PATCH 2/3] memory: seek FlatView sharing\n\tcandidates among children subregions","submitter":{"id":2701,"url":"http://patchwork.ozlabs.org/api/people/2701/","name":"Paolo Bonzini","email":"pbonzini@redhat.com"},"content":"On 21/09/2017 15:39, Alexey Kardashevskiy wrote:\n> On 21/09/17 22:07, Paolo Bonzini wrote:\n>> A container can be used instead of an alias to allow switching between\n>> multiple subregions.  In this case we cannot directly share the\n>> subregions (since they only belong to a single parent), but if the\n>> subregions are aliases we can in turn walk those.\n>>\n>> While this does not reduce much the number of FlatViews that are created,\n>> it makes it possible to share the PCI bus master FlatViews and their\n>> AddressSpaceDispatch structures.  For 112 virtio-net-pci devices, boot time\n>> is reduced from 25 to 10 seconds and memory consumption from 1.4 to 1 G.\n>>\n>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>\n>> ---\n>>  memory.c | 41 +++++++++++++++++++++++++++++++++++------\n>>  1 file changed, 35 insertions(+), 6 deletions(-)\n>>\n>> diff --git a/memory.c b/memory.c\n>> index 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> \n> Can an MR have terminates==true and children by the same time? If so, what for?\n\nYes, children override the parent.  But more important, !mr->terminates\nmeans that patch 3 doesn't think that MR produces an empty FlatView.\n\n> \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> \n> \n> Ah, I tried this one but in v4's 18/18 (that hinting thing), did not work\n> out but for a different reason.\n\nYeah, I did take some inspiration from your code, but we were thinking\nof different scenarios (I wanted to cover the child->enabled == true).\n\nPaolo\n\n> \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>>\n> \n>","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-mx03.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx03.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 3xydVH6kZBz9t3v\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 23:57:59 +1000 (AEST)","from localhost ([::1]:53878 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 1dv1zJ-0003Vy-VZ\n\tfor incoming@patchwork.ozlabs.org; Thu, 21 Sep 2017 09:57:58 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:39210)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <pbonzini@redhat.com>) id 1dv1ym-0003UB-UK\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 09:57:26 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <pbonzini@redhat.com>) id 1dv1yi-0002bt-1c\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 09:57:24 -0400","from mx1.redhat.com ([209.132.183.28]:54372)\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 1dv1yh-0002bZ-QR\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 09:57:19 -0400","from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13])\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 AA6EC7DCC2;\n\tThu, 21 Sep 2017 13:57:18 +0000 (UTC)","from [10.36.117.52] (ovpn-117-52.ams2.redhat.com [10.36.117.52])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id E8BA8614D9;\n\tThu, 21 Sep 2017 13:57:16 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com AA6EC7DCC2","To":"Alexey Kardashevskiy <aik@ozlabs.ru>, qemu-devel@nongnu.org","References":"<20170921120751.3027-1-pbonzini@redhat.com>\n\t<20170921120751.3027-3-pbonzini@redhat.com>\n\t<1d5f2bb4-c330-98b9-bf1a-6024a9f9093d@ozlabs.ru>","From":"Paolo Bonzini <pbonzini@redhat.com>","Message-ID":"<d29597cd-773d-3268-4d27-a2f68c895d14@redhat.com>","Date":"Thu, 21 Sep 2017 15:57:15 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<1d5f2bb4-c330-98b9-bf1a-6024a9f9093d@ozlabs.ru>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.13","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.27]);\n\tThu, 21 Sep 2017 13:57:18 +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":"Re: [Qemu-devel] [PATCH 2/3] memory: seek FlatView sharing\n\tcandidates among 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>","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>"}},{"id":1773257,"web_url":"http://patchwork.ozlabs.org/comment/1773257/","msgid":"<a7cbb7ee-a3a7-7775-f146-4fca9960327a@ozlabs.ru>","list_archive_url":null,"date":"2017-09-22T04:45:50","subject":"Re: [Qemu-devel] [PATCH 2/3] memory: seek FlatView sharing\n\tcandidates among children subregions","submitter":{"id":7621,"url":"http://patchwork.ozlabs.org/api/people/7621/","name":"Alexey Kardashevskiy","email":"aik@ozlabs.ru"},"content":"On 21/09/17 23:57, Paolo Bonzini wrote:\n> On 21/09/2017 15:39, Alexey Kardashevskiy wrote:\n>> On 21/09/17 22:07, Paolo Bonzini wrote:\n>>> A container can be used instead of an alias to allow switching between\n>>> multiple subregions.  In this case we cannot directly share the\n>>> subregions (since they only belong to a single parent), but if the\n>>> subregions are aliases we can in turn walk those.\n>>>\n>>> While this does not reduce much the number of FlatViews that are created,\n>>> it makes it possible to share the PCI bus master FlatViews and their\n>>> AddressSpaceDispatch structures.  For 112 virtio-net-pci devices, boot time\n>>> is reduced from 25 to 10 seconds and memory consumption from 1.4 to 1 G.\n>>>\n>>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>\n>>> ---\n>>>  memory.c | 41 +++++++++++++++++++++++++++++++++++------\n>>>  1 file changed, 35 insertions(+), 6 deletions(-)\n>>>\n>>> diff --git a/memory.c b/memory.c\n>>> index 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>>\n>> Can an MR have terminates==true and children by the same time? If so, what for?\n> \n> Yes, children override the parent. > But more important, !mr->terminates\n> means that patch 3 doesn't think that MR produces an empty FlatView.\n\n\nI see, after some debugging only MRs with @terminates==true appear in the\ndispatch tree which makes sense. But I am still struggling to understand\nwhat @terminates really means here in plain english.","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>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ozlabs-ru.20150623.gappssmtp.com\n\theader.i=@ozlabs-ru.20150623.gappssmtp.com\n\theader.b=\"iKoCaHtU\"; dkim-atps=neutral"],"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 3xz1Cb2P2dz9sNr\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 22 Sep 2017 14:46:30 +1000 (AEST)","from localhost ([::1]:56662 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 1dvFrA-0006Ta-8Z\n\tfor incoming@patchwork.ozlabs.org; Fri, 22 Sep 2017 00:46:28 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:37931)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <aik@ozlabs.ru>) id 1dvFqj-0006T9-Mn\n\tfor qemu-devel@nongnu.org; Fri, 22 Sep 2017 00:46:02 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <aik@ozlabs.ru>) id 1dvFqg-0003hj-K3\n\tfor qemu-devel@nongnu.org; Fri, 22 Sep 2017 00:46:01 -0400","from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:38399)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <aik@ozlabs.ru>) id 1dvFqg-0003dT-AX\n\tfor qemu-devel@nongnu.org; Fri, 22 Sep 2017 00:45:58 -0400","by mail-pg0-x242.google.com with SMTP id m30so9946pgn.5\n\tfor <qemu-devel@nongnu.org>; Thu, 21 Sep 2017 21:45:56 -0700 (PDT)","from [10.61.2.175] ([122.99.82.10])\n\tby smtp.googlemail.com with ESMTPSA id\n\tb8sm5014962pfl.62.2017.09.21.21.45.53\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tThu, 21 Sep 2017 21:45:54 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ozlabs-ru.20150623.gappssmtp.com; s=20150623;\n\th=subject:to:references:from:message-id:date:user-agent:mime-version\n\t:in-reply-to:content-language:content-transfer-encoding;\n\tbh=KKH1wJ41crHfYPVROPsF/yAeWEMC/I8aL8Al1/jwBG4=;\n\tb=iKoCaHtU13aZUP7u9eR64H0VueWleG0xcf2OzVJcHTADZ8OH1A+hvMM9WtTUXnLT24\n\tPFq1qu8P3uBHZBkVstm3Vky2OolOGiUFdYAmBP2uHbiPzlCV1+LjtgqFlKcg1srLB0BO\n\t4g9Trve/QPbdU0XNyYcPDz71dRxSi+joJdOw3DnRgjBHLRAmUZHMIiTpyx8WhH/QKDOG\n\twgfnDX9UOjDMNAmm9wmcIwJc/yhFb+huyu21eBX3wKfmU4iDQFg0lZ9ca7+8WC1fcJ9z\n\tljD12YZUNYTwMBwtE9BlgJgEiR/9Yo4yEMdRhad0YPXvHWfwtSKanGx3qht+VbgD7mzY\n\tPV6w==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:subject:to:references:from:message-id:date\n\t:user-agent:mime-version:in-reply-to:content-language\n\t:content-transfer-encoding;\n\tbh=KKH1wJ41crHfYPVROPsF/yAeWEMC/I8aL8Al1/jwBG4=;\n\tb=kOW0q2uDgPH08KQNhV/TwmDBEJ/6D99W//Xx6JMMlCKNMIqLfCXAX3q/oUxbS8hnPs\n\tZvF+lHkXSH6qPR4vDySac58NgHOivmX1v1MC8pp3nzf6lBKCNDZp14TfOw1K0Mrj+r7X\n\t0ANwMcN42m1KG49heSoGEquumvPNtfCuDIGYEswG8YQyKFEsyhh67vkCJJbjwLQDNKFI\n\tE8MBEm1XA0ROvjuC1o/WTVGKYEiv/35S3SIdpZYH0L/crXqcpYiHvR1CR2ofPzA693YE\n\tptqnusrcV1ffqi1IrTcSytyFMnWnkOGm3ezyXS3zVLXMlDX5kMLSjGceaJGZcf+J0hbJ\n\tTgSA==","X-Gm-Message-State":"AHPjjUgvv36bPjmMcexP/CocwOI9kd5hBDG555Q4tdDtguA8o7OA8r8T\n\tIOzCmF2XfyEuMfyyK80O+obu81OA","X-Google-Smtp-Source":"AOwi7QDVWETK/ToQzx6LL59x03EPCmoPDpT8xRkCBFrxL4W53lOhyWrvK4aIl1HPwYZQs2lK2st/EA==","X-Received":"by 10.98.147.137 with SMTP id r9mr7870583pfk.161.1506055554795; \n\tThu, 21 Sep 2017 21:45:54 -0700 (PDT)","To":"Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org","References":"<20170921120751.3027-1-pbonzini@redhat.com>\n\t<20170921120751.3027-3-pbonzini@redhat.com>\n\t<1d5f2bb4-c330-98b9-bf1a-6024a9f9093d@ozlabs.ru>\n\t<d29597cd-773d-3268-4d27-a2f68c895d14@redhat.com>","From":"Alexey Kardashevskiy <aik@ozlabs.ru>","Message-ID":"<a7cbb7ee-a3a7-7775-f146-4fca9960327a@ozlabs.ru>","Date":"Fri, 22 Sep 2017 14:45:50 +1000","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.2.1","MIME-Version":"1.0","In-Reply-To":"<d29597cd-773d-3268-4d27-a2f68c895d14@redhat.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-AU","Content-Transfer-Encoding":"7bit","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"2607:f8b0:400e:c05::242","Subject":"Re: [Qemu-devel] [PATCH 2/3] memory: seek FlatView sharing\n\tcandidates among 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>","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>"}},{"id":1773320,"web_url":"http://patchwork.ozlabs.org/comment/1773320/","msgid":"<cea99470-0eab-53d3-30dc-213ef14cd9aa@redhat.com>","list_archive_url":null,"date":"2017-09-22T07:28:25","subject":"Re: [Qemu-devel] [PATCH 2/3] memory: seek FlatView sharing\n\tcandidates among children subregions","submitter":{"id":2701,"url":"http://patchwork.ozlabs.org/api/people/2701/","name":"Paolo Bonzini","email":"pbonzini@redhat.com"},"content":"On 22/09/2017 06:45, Alexey Kardashevskiy wrote:\n> On 21/09/17 23:57, Paolo Bonzini wrote:\n>> On 21/09/2017 15:39, Alexey Kardashevskiy wrote:\n>>> On 21/09/17 22:07, Paolo Bonzini wrote:\n>>>> A container can be used instead of an alias to allow switching between\n>>>> multiple subregions.  In this case we cannot directly share the\n>>>> subregions (since they only belong to a single parent), but if the\n>>>> subregions are aliases we can in turn walk those.\n>>>>\n>>>> While this does not reduce much the number of FlatViews that are created,\n>>>> it makes it possible to share the PCI bus master FlatViews and their\n>>>> AddressSpaceDispatch structures.  For 112 virtio-net-pci devices, boot time\n>>>> is reduced from 25 to 10 seconds and memory consumption from 1.4 to 1 G.\n>>>>\n>>>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>\n>>>> ---\n>>>>  memory.c | 41 +++++++++++++++++++++++++++++++++++------\n>>>>  1 file changed, 35 insertions(+), 6 deletions(-)\n>>>>\n>>>> diff --git a/memory.c b/memory.c\n>>>> index 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>>>\n>>> Can an MR have terminates==true and children by the same time? If so, what for?\n>>\n>> Yes, children override the parent. > But more important, !mr->terminates\n>> means that patch 3 doesn't think that MR produces an empty FlatView.\n> \n> \n> I see, after some debugging only MRs with @terminates==true appear in the\n> dispatch tree which makes sense. But I am still struggling to understand\n> what @terminates really means here in plain english.\n\nAs you found out, perhaps \"dispatched\" would be a better name than\n\"terminates\".  A MR can be \"alias\", \"terminates\" or \"!terminates\".\nAliases are resolved early.  If a range is allocated to a \"terminates\"\nregion A (and not to any other \"terminates\" region in A's subtree), it\ndispatches to A.\n\nIf a range is allocated to a \"!terminates\" region B (and to any other\n\"terminates\" region in B's subtree, QEMU doesn't add it to the FlatView\nand it will be dispatched to another memory region: B's parent, another\nregion in B's parent's subtree, B's grandparent, another region in B's\ngrandparent's subtree, and so on---if nobody accepts it, it goes to\nunassigned_mem_ops.\n\nPaolo","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-mx06.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx06.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 3xz4qk3Vsnz9sNc\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 22 Sep 2017 17:29:38 +1000 (AEST)","from localhost ([::1]:57069 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 1dvIP2-0000UW-KI\n\tfor incoming@patchwork.ozlabs.org; Fri, 22 Sep 2017 03:29:36 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:60730)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <pbonzini@redhat.com>) id 1dvINz-0008WI-Te\n\tfor qemu-devel@nongnu.org; Fri, 22 Sep 2017 03:28:33 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <pbonzini@redhat.com>) id 1dvINw-0005Zp-Ko\n\tfor qemu-devel@nongnu.org; Fri, 22 Sep 2017 03:28:31 -0400","from mx1.redhat.com ([209.132.183.28]:48464)\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 1dvINw-0005Zf-BF\n\tfor qemu-devel@nongnu.org; Fri, 22 Sep 2017 03:28:28 -0400","from smtp.corp.redhat.com\n\t(int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16])\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 6AF43267C4;\n\tFri, 22 Sep 2017 07:28:27 +0000 (UTC)","from [10.36.117.77] (ovpn-117-77.ams2.redhat.com [10.36.117.77])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id BFB2E5C549;\n\tFri, 22 Sep 2017 07:28:26 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 6AF43267C4","To":"Alexey Kardashevskiy <aik@ozlabs.ru>, qemu-devel@nongnu.org","References":"<20170921120751.3027-1-pbonzini@redhat.com>\n\t<20170921120751.3027-3-pbonzini@redhat.com>\n\t<1d5f2bb4-c330-98b9-bf1a-6024a9f9093d@ozlabs.ru>\n\t<d29597cd-773d-3268-4d27-a2f68c895d14@redhat.com>\n\t<a7cbb7ee-a3a7-7775-f146-4fca9960327a@ozlabs.ru>","From":"Paolo Bonzini <pbonzini@redhat.com>","Message-ID":"<cea99470-0eab-53d3-30dc-213ef14cd9aa@redhat.com>","Date":"Fri, 22 Sep 2017 09:28:25 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<a7cbb7ee-a3a7-7775-f146-4fca9960327a@ozlabs.ru>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.16","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.30]);\n\tFri, 22 Sep 2017 07:28:27 +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":"Re: [Qemu-devel] [PATCH 2/3] memory: seek FlatView sharing\n\tcandidates among 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>","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>"}}]