[{"id":1772078,"web_url":"http://patchwork.ozlabs.org/comment/1772078/","msgid":"<54984f46-f50b-8306-2229-15ea96cea7d6@redhat.com>","list_archive_url":null,"date":"2017-09-20T17:13:05","subject":"Re: [Qemu-devel] [PATCH qemu v4 15/18] memory: Share special empty\n\tFlatView","submitter":{"id":2701,"url":"http://patchwork.ozlabs.org/api/people/2701/","name":"Paolo Bonzini","email":"pbonzini@redhat.com"},"content":"On 20/09/2017 13:46, Alexey Kardashevskiy wrote:\n> This shares an cached empty FlatView among address spaces. The empty\n> FV is used every time when a root MR renders into a FV without memory\n> sections which happens when MR or its children are not enabled or\n> zero-sized. The empty_view is not NULL to keep the rest of memory\n> API intact; it also has a dispatch tree for the same reason.\n> \n> On POWER8 with 255 CPUs, 255 virtio-net, 40 PCI bridges guest this halves\n> the amount of FlatView's in use (557 -> 260) and dispatch tables\n> (~800000 -> ~370000), however the total memory footprint is pretty much\n> the same as RCU is holding all these temporary FVs which are created\n> (and then released) to make sure that they are empty and can be replaced\n> with @empty_view.\n> \n> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>\n> ---\n>  memory.c | 14 ++++++++++++++\n>  1 file changed, 14 insertions(+)\n> \n> diff --git a/memory.c b/memory.c\n> index 4add0fd030..92b1304a20 100644\n> --- a/memory.c\n> +++ b/memory.c\n> @@ -48,6 +48,7 @@ static QTAILQ_HEAD(, AddressSpace) address_spaces\n>      = QTAILQ_HEAD_INITIALIZER(address_spaces);\n>  \n>  static GHashTable *flat_views;\n> +static FlatView *empty_view;\n>  \n>  typedef struct AddrRange AddrRange;\n>  \n> @@ -755,6 +756,19 @@ static FlatView *generate_memory_topology(MemoryRegion *mr)\n>      }\n>      flatview_simplify(view);\n>  \n> +    if (!view->nr) {\n> +        flatview_unref(view);\n\nThis can be changed to flatview_destroy directly to avoid overloading\nRCU with all these temporary FlatViews.\n\nPaolo\n\n> +        if (!empty_view) {\n> +            empty_view = flatview_new(NULL);\n> +        }\n> +        view = empty_view;\n> +        flatview_ref(view);\n> +    }\n> +\n> +    if (view->dispatch) {\n> +        return view;\n> +    }\n> +\n>      view->dispatch = address_space_dispatch_new(view);\n>      for (i = 0; i < view->nr; i++) {\n>          MemoryRegionSection mrs =\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-mx01.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx01.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 3xy5tX3cpHz9s0Z\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 03:13:39 +1000 (AEST)","from localhost ([::1]:49854 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 1duiZ6-0006Z1-V4\n\tfor incoming@patchwork.ozlabs.org; Wed, 20 Sep 2017 13:13:36 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:45958)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <pbonzini@redhat.com>) id 1duiYi-0006YL-Mb\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 13:13:13 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <pbonzini@redhat.com>) id 1duiYg-0008A2-0D\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 13:13:12 -0400","from mx1.redhat.com ([209.132.183.28]:54828)\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 1duiYf-000891-Pd\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 13:13:09 -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 328E081E18;\n\tWed, 20 Sep 2017 17:13:08 +0000 (UTC)","from [10.36.117.211] (ovpn-117-211.ams2.redhat.com [10.36.117.211])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 88D285D75A;\n\tWed, 20 Sep 2017 17:13:07 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 328E081E18","To":"Alexey Kardashevskiy <aik@ozlabs.ru>, qemu-devel@nongnu.org","References":"<20170920114637.42004-1-aik@ozlabs.ru>\n\t<20170920114637.42004-16-aik@ozlabs.ru>","From":"Paolo Bonzini <pbonzini@redhat.com>","Message-ID":"<54984f46-f50b-8306-2229-15ea96cea7d6@redhat.com>","Date":"Wed, 20 Sep 2017 19:13:05 +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":"<20170920114637.42004-16-aik@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.15","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.25]);\n\tWed, 20 Sep 2017 17:13:08 +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 qemu v4 15/18] memory: Share special empty\n\tFlatView","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":1772319,"web_url":"http://patchwork.ozlabs.org/comment/1772319/","msgid":"<7a46de37-95dd-d662-3a4c-05421f5e8f1a@ozlabs.ru>","list_archive_url":null,"date":"2017-09-20T23:48:10","subject":"Re: [Qemu-devel] [PATCH qemu v4 15/18] memory: Share special empty\n\tFlatView","submitter":{"id":7621,"url":"http://patchwork.ozlabs.org/api/people/7621/","name":"Alexey Kardashevskiy","email":"aik@ozlabs.ru"},"content":"On 21/09/17 03:13, Paolo Bonzini wrote:\n> On 20/09/2017 13:46, Alexey Kardashevskiy wrote:\n>> This shares an cached empty FlatView among address spaces. The empty\n>> FV is used every time when a root MR renders into a FV without memory\n>> sections which happens when MR or its children are not enabled or\n>> zero-sized. The empty_view is not NULL to keep the rest of memory\n>> API intact; it also has a dispatch tree for the same reason.\n>>\n>> On POWER8 with 255 CPUs, 255 virtio-net, 40 PCI bridges guest this halves\n>> the amount of FlatView's in use (557 -> 260) and dispatch tables\n>> (~800000 -> ~370000), however the total memory footprint is pretty much\n>> the same as RCU is holding all these temporary FVs which are created\n>> (and then released) to make sure that they are empty and can be replaced\n>> with @empty_view.\n>>\n>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>\n>> ---\n>>  memory.c | 14 ++++++++++++++\n>>  1 file changed, 14 insertions(+)\n>>\n>> diff --git a/memory.c b/memory.c\n>> index 4add0fd030..92b1304a20 100644\n>> --- a/memory.c\n>> +++ b/memory.c\n>> @@ -48,6 +48,7 @@ static QTAILQ_HEAD(, AddressSpace) address_spaces\n>>      = QTAILQ_HEAD_INITIALIZER(address_spaces);\n>>  \n>>  static GHashTable *flat_views;\n>> +static FlatView *empty_view;\n>>  \n>>  typedef struct AddrRange AddrRange;\n>>  \n>> @@ -755,6 +756,19 @@ static FlatView *generate_memory_topology(MemoryRegion *mr)\n>>      }\n>>      flatview_simplify(view);\n>>  \n>> +    if (!view->nr) {\n>> +        flatview_unref(view);\n> \n> This can be changed to flatview_destroy directly to avoid overloading\n> RCU with all these temporary FlatViews.\n\n\nYeah, this or just allocate every new FlatView on the stack first, I\nthought about this a second after I posted this.\n\n\n> \n> Paolo\n> \n>> +        if (!empty_view) {\n>> +            empty_view = flatview_new(NULL);\n>> +        }\n>> +        view = empty_view;\n>> +        flatview_ref(view);\n>> +    }\n>> +\n>> +    if (view->dispatch) {\n>> +        return view;\n>> +    }\n>> +\n>>      view->dispatch = address_space_dispatch_new(view);\n>>      for (i = 0; i < view->nr; i++) {\n>>          MemoryRegionSection mrs =\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>)","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=\"e5SJVKV+\"; 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 3xyGfR1TGBz9s7g\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 09:48:45 +1000 (AEST)","from localhost ([::1]:51123 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 1duojS-00088l-LL\n\tfor incoming@patchwork.ozlabs.org; Wed, 20 Sep 2017 19:48:42 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:36014)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <aik@ozlabs.ru>) id 1duoj6-00088I-38\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 19:48:21 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <aik@ozlabs.ru>) id 1duoj3-0004vA-0z\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 19:48:20 -0400","from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:32782)\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 1duoj2-0004uE-N0\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 19:48:16 -0400","by mail-pg0-x242.google.com with SMTP id i130so2455937pgc.0\n\tfor <qemu-devel@nongnu.org>; Wed, 20 Sep 2017 16:48:16 -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\to5sm86279pfh.67.2017.09.20.16.48.12\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tWed, 20 Sep 2017 16:48:14 -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=skt3WGE3YUlfwFbU1l0CcjKr9sbxNsaM8uZsrLoHruI=;\n\tb=e5SJVKV+VnMHyUGMYZGTQNgEGjqSWxNZwHSJyWnlHw8T2rE9orRynioA63TMsTMu4d\n\thy+vbWTpjCbnBLWl04DRkfZ2yll0dCLnQaglJgPIeTtkjw4NMRZojHOcvIHimsEw8HY5\n\tG7bxxJLfYRk3Fmud2fsFZAiWcs+CdbORwFx8STKs6LQz7SG56qe6n/LfE0OEGsdJ0fmA\n\tSlubIBuHYMqoxeAFrbynCgYQy9GyEGGgoF5VFKRCdSqdz4UA5DzsIkbL0BYyA+7BcxpF\n\ty2SLaOgGmvYN+Z3V9CmYMz7nBTadKE9i6ZmHfaANFPy/XlP2PN8fYf+OigRoICOU4L5k\n\t1l4w==","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=skt3WGE3YUlfwFbU1l0CcjKr9sbxNsaM8uZsrLoHruI=;\n\tb=XBAmVelNnnJPuSNowdUk+j4/Jmo09iuBFve3UGL24cvzIM3Fa1lBUsq3RuvKE9iZb+\n\tRcDxgfgFlRkD4KAIUo9X9iVxYhUJontDFuPSJz/j51D7FuCl/OOqVdOc8b8bsjUfGaWg\n\tozwPxn35DxJz5QTGNi0Ga/RkMVedrY9FkAxI5HStJ25xNzvi1OvTiSRWT1CV9cBYiA/y\n\tDuQ9Ey1j8/GM9OB9xTcuIOq/rWJPtML7LOaD9xO523zF9Bi0CfEM10GB2Pus6ZBdS9ya\n\t8rYERC4ohIrxjl8rThDmesBovzUWbuhkYE2ej5Tz8TGdlZ2umG0fAYdyWbCH4bWN3+td\n\tlCpg==","X-Gm-Message-State":"AHPjjUjl6oszqcwqFmNuT5ESWBYW+Sy0VAWfH3D6YVe3JEEG3GWAe5af\n\tQ4heUkdwHtdcv4uu/LUV6QsdkOJ5","X-Google-Smtp-Source":"AOwi7QBzCKnf8UE+QIw6vVa44bh0esjVOTiFG7YwtYj1EPqQZ5Lxz03xJR/18LdRjVrj2BXilUeKRw==","X-Received":"by 10.99.122.29 with SMTP id v29mr3777214pgc.434.1505951294983; \n\tWed, 20 Sep 2017 16:48:14 -0700 (PDT)","To":"Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org","References":"<20170920114637.42004-1-aik@ozlabs.ru>\n\t<20170920114637.42004-16-aik@ozlabs.ru>\n\t<54984f46-f50b-8306-2229-15ea96cea7d6@redhat.com>","From":"Alexey Kardashevskiy <aik@ozlabs.ru>","Message-ID":"<7a46de37-95dd-d662-3a4c-05421f5e8f1a@ozlabs.ru>","Date":"Thu, 21 Sep 2017 09:48:10 +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":"<54984f46-f50b-8306-2229-15ea96cea7d6@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 qemu v4 15/18] memory: Share special empty\n\tFlatView","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>"}}]