{"id":816317,"url":"http://patchwork.ozlabs.org/api/patches/816317/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170920114637.42004-16-aik@ozlabs.ru/","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":"<20170920114637.42004-16-aik@ozlabs.ru>","list_archive_url":null,"date":"2017-09-20T11:46:34","name":"[qemu,v4,15/18] memory: Share special empty FlatView","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"81f28a0ce175c1cc50ac427fe71b13c60a4950b0","submitter":{"id":7621,"url":"http://patchwork.ozlabs.org/api/people/7621/?format=json","name":"Alexey Kardashevskiy","email":"aik@ozlabs.ru"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170920114637.42004-16-aik@ozlabs.ru/mbox/","series":[{"id":4138,"url":"http://patchwork.ozlabs.org/api/series/4138/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=4138","date":"2017-09-20T11:46:20","name":"memory: Reduce memory use","version":4,"mbox":"http://patchwork.ozlabs.org/series/4138/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/816317/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/816317/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>)","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 3xy3qq1dg6z9s8J\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 01:41:10 +1000 (AEST)","from localhost ([::1]:48962 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 1duh7c-0008Ax-VB\n\tfor incoming@patchwork.ozlabs.org; Wed, 20 Sep 2017 11:41:09 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:56439)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <aik@ozlabs.ru>) id 1dufmK-0003SO-4W\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 10:15:05 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <aik@ozlabs.ru>) id 1dufmD-00057U-GP\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 10:15:04 -0400","from ozlabs.ru ([107.173.13.209]:59740)\n\tby eggs.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <aik@ozlabs.ru>) id 1dufmD-00056x-9x\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 10:14:57 -0400","from vpl1.ozlabs.ibm.com (localhost [IPv6:::1])\n\tby ozlabs.ru (Postfix) with ESMTP id C09DF3A6005E;\n\tWed, 20 Sep 2017 07:48:14 -0400 (EDT)"],"From":"Alexey Kardashevskiy <aik@ozlabs.ru>","To":"qemu-devel@nongnu.org","Date":"Wed, 20 Sep 2017 21:46:34 +1000","Message-Id":"<20170920114637.42004-16-aik@ozlabs.ru>","X-Mailer":"git-send-email 2.11.0","In-Reply-To":"<20170920114637.42004-1-aik@ozlabs.ru>","References":"<20170920114637.42004-1-aik@ozlabs.ru>","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 3.x [fuzzy]","X-Received-From":"107.173.13.209","Subject":"[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>","Cc":"Alexey Kardashevskiy <aik@ozlabs.ru>, Paolo Bonzini <pbonzini@redhat.com>","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":"This shares an cached empty FlatView among address spaces. The empty\nFV is used every time when a root MR renders into a FV without memory\nsections which happens when MR or its children are not enabled or\nzero-sized. The empty_view is not NULL to keep the rest of memory\nAPI intact; it also has a dispatch tree for the same reason.\n\nOn POWER8 with 255 CPUs, 255 virtio-net, 40 PCI bridges guest this halves\nthe amount of FlatView's in use (557 -> 260) and dispatch tables\n(~800000 -> ~370000), however the total memory footprint is pretty much\nthe 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\nwith @empty_view.\n\nSigned-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>\n---\n memory.c | 14 ++++++++++++++\n 1 file changed, 14 insertions(+)","diff":"diff --git a/memory.c b/memory.c\nindex 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+        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","prefixes":["qemu","v4","15/18"]}