[{"id":1790547,"web_url":"http://patchwork.ozlabs.org/comment/1790547/","msgid":"<20171019160405-mutt-send-email-mst@kernel.org>","list_archive_url":null,"date":"2017-10-19T13:12:20","subject":"Re: [Qemu-devel] [PATCH v2 1/1] virtio_balloon: include buffers and\n\tcached memory statistics","submitter":{"id":2235,"url":"http://patchwork.ozlabs.org/api/people/2235/","name":"Michael S. Tsirkin","email":"mst@redhat.com"},"content":"On Thu, Sep 21, 2017 at 02:55:41PM +0200, Tomáš Golembiovský wrote:\n> Add a new fields, VIRTIO_BALLOON_S_BUFFERS and VIRTIO_BALLOON_S_CACHED,\n> to virtio_balloon memory statistics protocol. The values correspond to\n> 'Buffers' and 'Cached' in /proc/meminfo.\n> \n> To be able to compute the value of 'Cached' memory it is necessary to\n> export total_swapcache_pages() to modules.\n> \n> Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>\n\nDoes 'Buffers' actually make sense? It's a temporary storage -\nwouldn't it be significantly out of date by the time\nhost receives it?\n\n> ---\n>  drivers/virtio/virtio_balloon.c     | 11 +++++++++++\n>  include/uapi/linux/virtio_balloon.h |  4 +++-\n>  mm/swap_state.c                     |  1 +\n>  3 files changed, 15 insertions(+), 1 deletion(-)\n> \n> diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c\n> index f0b3a0b9d42f..c2558ec47a62 100644\n> --- a/drivers/virtio/virtio_balloon.c\n> +++ b/drivers/virtio/virtio_balloon.c\n> @@ -244,12 +244,19 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)\n>  \tstruct sysinfo i;\n>  \tunsigned int idx = 0;\n>  \tlong available;\n> +\tlong cached;\n>  \n>  \tall_vm_events(events);\n>  \tsi_meminfo(&i);\n>  \n>  \tavailable = si_mem_available();\n>  \n> +\tcached = global_node_page_state(NR_FILE_PAGES) -\n> +\t\t\ttotal_swapcache_pages() - i.bufferram;\n> +\tif (cached < 0)\n> +\t\tcached = 0;\n> +\n> +\n>  #ifdef CONFIG_VM_EVENT_COUNTERS\n>  \tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_IN,\n>  \t\t\t\tpages_to_bytes(events[PSWPIN]));\n> @@ -264,6 +271,10 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)\n>  \t\t\t\tpages_to_bytes(i.totalram));\n>  \tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_AVAIL,\n>  \t\t\t\tpages_to_bytes(available));\n> +\tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_BUFFERS,\n> +\t\t\t\tpages_to_bytes(i.bufferram));\n> +\tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_CACHED,\n> +\t\t\t\tpages_to_bytes(cached));\n>  \n>  \treturn idx;\n>  }\n> diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h\n> index 343d7ddefe04..d5dc8a56a497 100644\n> --- a/include/uapi/linux/virtio_balloon.h\n> +++ b/include/uapi/linux/virtio_balloon.h\n> @@ -52,7 +52,9 @@ struct virtio_balloon_config {\n>  #define VIRTIO_BALLOON_S_MEMFREE  4   /* Total amount of free memory */\n>  #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */\n>  #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */\n> -#define VIRTIO_BALLOON_S_NR       7\n> +#define VIRTIO_BALLOON_S_BUFFERS  7   /* Buffers memory as in /proc */\n> +#define VIRTIO_BALLOON_S_CACHED   8   /* Cached memory as in /proc */\n> +#define VIRTIO_BALLOON_S_NR       9\n>  \n>  /*\n>   * Memory statistics structure.\n> diff --git a/mm/swap_state.c b/mm/swap_state.c\n> index 71ce2d1ccbf7..f3a4ff7d6c52 100644\n> --- a/mm/swap_state.c\n> +++ b/mm/swap_state.c\n> @@ -95,6 +95,7 @@ unsigned long total_swapcache_pages(void)\n>  \trcu_read_unlock();\n>  \treturn ret;\n>  }\n> +EXPORT_SYMBOL_GPL(total_swapcache_pages);\n>  \n>  static atomic_t swapin_readahead_hits = ATOMIC_INIT(4);\n\nNeed an ack from MM crowd on that.\n\n> -- \n> 2.14.1","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-mx10.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx10.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=mst@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 3yHq9S6Sm6z9sBd\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 20 Oct 2017 00:13:00 +1100 (AEDT)","from localhost ([::1]:49298 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 1e5Ad9-0007df-1E\n\tfor incoming@patchwork.ozlabs.org; Thu, 19 Oct 2017 09:12:59 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:34022)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <mst@redhat.com>) id 1e5Acd-0007cL-PI\n\tfor qemu-devel@nongnu.org; Thu, 19 Oct 2017 09:12:28 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <mst@redhat.com>) id 1e5AcZ-0001WD-ME\n\tfor qemu-devel@nongnu.org; Thu, 19 Oct 2017 09:12:27 -0400","from mx1.redhat.com ([209.132.183.28]:60240)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <mst@redhat.com>) id 1e5AcZ-0001U6-DV\n\tfor qemu-devel@nongnu.org; Thu, 19 Oct 2017 09:12:23 -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 979EB5F7BF;\n\tThu, 19 Oct 2017 13:12:21 +0000 (UTC)","from redhat.com (ovpn-122-110.rdu2.redhat.com [10.10.122.110])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 8D080BA200;\n\tThu, 19 Oct 2017 13:12:20 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 979EB5F7BF","Date":"Thu, 19 Oct 2017 16:12:20 +0300","From":"\"Michael S. Tsirkin\" <mst@redhat.com>","To":"=?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= <tgolembi@redhat.com>","Message-ID":"<20171019160405-mutt-send-email-mst@kernel.org>","References":"<cover.1505998455.git.tgolembi@redhat.com>\n\t<b13f11c03ed394bd8ad367dc90996ed134ea98da.1505998455.git.tgolembi@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<b13f11c03ed394bd8ad367dc90996ed134ea98da.1505998455.git.tgolembi@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.39]);\n\tThu, 19 Oct 2017 13:12:21 +0000 (UTC)","Content-Transfer-Encoding":"quoted-printable","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 v2 1/1] virtio_balloon: include buffers and\n\tcached memory statistics","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":"virtio-dev@lists.oasis-open.org, kvm@vger.kernel.org,\n\tJason Wang <jasowang@redhat.com>, qemu-devel@nongnu.org,\n\tvirtualization@lists.linux-foundation.org, linux-mm@kvack.org,\n\tWei Wang <wei.w.wang@intel.com>, Shaohua Li <shli@fb.com>,\n\tHuang Ying <ying.huang@intel.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>"}},{"id":1792257,"web_url":"http://patchwork.ozlabs.org/comment/1792257/","msgid":"<20171022200557.02558e37@fiorina>","list_archive_url":null,"date":"2017-10-22T18:05:57","subject":"Re: [Qemu-devel] [PATCH v2 1/1] virtio_balloon: include buffers and\n\tcached memory statistics","submitter":{"id":69377,"url":"http://patchwork.ozlabs.org/api/people/69377/","name":"Tomáš Golembiovský","email":"tgolembi@redhat.com"},"content":"On Thu, 19 Oct 2017 16:12:20 +0300\n\"Michael S. Tsirkin\" <mst@redhat.com> wrote:\n\n> On Thu, Sep 21, 2017 at 02:55:41PM +0200, Tomáš Golembiovský wrote:\n> > Add a new fields, VIRTIO_BALLOON_S_BUFFERS and VIRTIO_BALLOON_S_CACHED,\n> > to virtio_balloon memory statistics protocol. The values correspond to\n> > 'Buffers' and 'Cached' in /proc/meminfo.\n> > \n> > To be able to compute the value of 'Cached' memory it is necessary to\n> > export total_swapcache_pages() to modules.\n> > \n> > Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>\n> \n> Does 'Buffers' actually make sense? It's a temporary storage -\n> wouldn't it be significantly out of date by the time\n> host receives it?\n\nThat would be best answered by somebody from kernel. But my personal\nopinion is that it would not be out of date. The amount of memory\ndedicated to Buffers does not seem to fluctuate too much.\n\n    Tomas\n\n\n> > ---\n> >  drivers/virtio/virtio_balloon.c     | 11 +++++++++++\n> >  include/uapi/linux/virtio_balloon.h |  4 +++-\n> >  mm/swap_state.c                     |  1 +\n> >  3 files changed, 15 insertions(+), 1 deletion(-)\n> > \n> > diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c\n> > index f0b3a0b9d42f..c2558ec47a62 100644\n> > --- a/drivers/virtio/virtio_balloon.c\n> > +++ b/drivers/virtio/virtio_balloon.c\n> > @@ -244,12 +244,19 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)\n> >  \tstruct sysinfo i;\n> >  \tunsigned int idx = 0;\n> >  \tlong available;\n> > +\tlong cached;\n> >  \n> >  \tall_vm_events(events);\n> >  \tsi_meminfo(&i);\n> >  \n> >  \tavailable = si_mem_available();\n> >  \n> > +\tcached = global_node_page_state(NR_FILE_PAGES) -\n> > +\t\t\ttotal_swapcache_pages() - i.bufferram;\n> > +\tif (cached < 0)\n> > +\t\tcached = 0;\n> > +\n> > +\n> >  #ifdef CONFIG_VM_EVENT_COUNTERS\n> >  \tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_IN,\n> >  \t\t\t\tpages_to_bytes(events[PSWPIN]));\n> > @@ -264,6 +271,10 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)\n> >  \t\t\t\tpages_to_bytes(i.totalram));\n> >  \tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_AVAIL,\n> >  \t\t\t\tpages_to_bytes(available));\n> > +\tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_BUFFERS,\n> > +\t\t\t\tpages_to_bytes(i.bufferram));\n> > +\tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_CACHED,\n> > +\t\t\t\tpages_to_bytes(cached));\n> >  \n> >  \treturn idx;\n> >  }\n> > diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h\n> > index 343d7ddefe04..d5dc8a56a497 100644\n> > --- a/include/uapi/linux/virtio_balloon.h\n> > +++ b/include/uapi/linux/virtio_balloon.h\n> > @@ -52,7 +52,9 @@ struct virtio_balloon_config {\n> >  #define VIRTIO_BALLOON_S_MEMFREE  4   /* Total amount of free memory */\n> >  #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */\n> >  #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */\n> > -#define VIRTIO_BALLOON_S_NR       7\n> > +#define VIRTIO_BALLOON_S_BUFFERS  7   /* Buffers memory as in /proc */\n> > +#define VIRTIO_BALLOON_S_CACHED   8   /* Cached memory as in /proc */\n> > +#define VIRTIO_BALLOON_S_NR       9\n> >  \n> >  /*\n> >   * Memory statistics structure.\n> > diff --git a/mm/swap_state.c b/mm/swap_state.c\n> > index 71ce2d1ccbf7..f3a4ff7d6c52 100644\n> > --- a/mm/swap_state.c\n> > +++ b/mm/swap_state.c\n> > @@ -95,6 +95,7 @@ unsigned long total_swapcache_pages(void)\n> >  \trcu_read_unlock();\n> >  \treturn ret;\n> >  }\n> > +EXPORT_SYMBOL_GPL(total_swapcache_pages);\n> >  \n> >  static atomic_t swapin_readahead_hits = ATOMIC_INIT(4);\n> \n> Need an ack from MM crowd on that.\n> \n> > -- \n> > 2.14.1","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 3yKnY95by4z9sBd\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 23 Oct 2017 05:06:52 +1100 (AEDT)","from localhost ([::1]:33843 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 1e6Ke8-0006XG-Ii\n\tfor incoming@patchwork.ozlabs.org; Sun, 22 Oct 2017 14:06:48 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:60191)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <tgolembi@redhat.com>) id 1e6KdZ-0006Qm-QN\n\tfor qemu-devel@nongnu.org; Sun, 22 Oct 2017 14:06:14 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <tgolembi@redhat.com>) id 1e6KdW-0001SN-Jw\n\tfor qemu-devel@nongnu.org; Sun, 22 Oct 2017 14:06:13 -0400","from mail-wr0-f193.google.com ([209.85.128.193]:49456)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <tgolembi@redhat.com>) id 1e6KdW-0001Rp-D2\n\tfor qemu-devel@nongnu.org; Sun, 22 Oct 2017 14:06:10 -0400","by mail-wr0-f193.google.com with SMTP id g90so15242311wrd.6\n\tfor <qemu-devel@nongnu.org>; Sun, 22 Oct 2017 11:06:09 -0700 (PDT)","from fiorina (ip-94-112-73-67.net.upcbroadband.cz. [94.112.73.67])\n\tby smtp.gmail.com with ESMTPSA id\n\t92sm3492026wrd.15.2017.10.22.11.06.07\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tSun, 22 Oct 2017 11:06:08 -0700 (PDT)"],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to\n\t:references:organization:mime-version:content-transfer-encoding;\n\tbh=HcrYSP7f+lbEhTPTBhQY5X0MTJFjCieVH+GyMWoQWJ8=;\n\tb=RWLeu7GwwNiyA0rdVi2kOP5ywLabLwtG8rPJf51osANjRg9iSfJxrjcGtI6qZGmt4e\n\tyzKUXOhee0FRjIfxx5n+AcD1NjO7JiPnkPpChGSQQnlwpgbcnSt9Yj8A4UGmX84CRwQY\n\tEJmuQ20tzifVpwih+lCMeMps7eoqcqr/JiYcsvTGwU3yXnjNHCwZ//VRb1r3NlMer7XR\n\tit3tig8dMW0YYmkEsUNKiDTK63K4D++Ks2leOvw9cYWd2k2nIgG3HJFw5keHLcyNsO7T\n\t7SOte7oiAruT+5U8wHPDkCzZF0x2lCq8wSmkHXTyNR+CTFNz6zPJ27dA53OGoRLiygkT\n\tEmnQ==","X-Gm-Message-State":"AMCzsaUYqiaes3f0UZWyp7xE1Bn8jp0bLkCp0TS1zW4SX0rTTnu1qI55\n\t4SRdqSZuRxbeRQXDAB/a3MSrfA==","X-Google-Smtp-Source":"ABhQp+Qm9ogs//QjhVK9JkhhqiAO0nOAbyZ+CKBc+pmMarwBhIjtqUSw6djODF148dWbfNNbkB8ENg==","X-Received":"by 10.223.187.65 with SMTP id x1mr3021498wrg.26.1508695568396;\n\tSun, 22 Oct 2017 11:06:08 -0700 (PDT)","Date":"Sun, 22 Oct 2017 20:05:57 +0200","From":"=?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= <tgolembi@redhat.com>","To":"\"Michael S. Tsirkin\" <mst@redhat.com>","Message-ID":"<20171022200557.02558e37@fiorina>","In-Reply-To":"<20171019160405-mutt-send-email-mst@kernel.org>","References":"<cover.1505998455.git.tgolembi@redhat.com>\n\t<b13f11c03ed394bd8ad367dc90996ed134ea98da.1505998455.git.tgolembi@redhat.com>\n\t<20171019160405-mutt-send-email-mst@kernel.org>","Organization":"Red Hat","X-Mailer":"Claws Mail 3.15.1-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu)","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"quoted-printable","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.85.128.193","Subject":"Re: [Qemu-devel] [PATCH v2 1/1] virtio_balloon: include buffers and\n\tcached memory statistics","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":"virtio-dev@lists.oasis-open.org, kvm@vger.kernel.org,\n\tJason Wang <jasowang@redhat.com>, qemu-devel@nongnu.org,\n\tvirtualization@lists.linux-foundation.org, linux-mm@kvack.org,\n\tWei Wang <wei.w.wang@intel.com>, Shaohua Li <shli@fb.com>,\n\tHuang Ying <ying.huang@intel.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>"}},{"id":1796617,"web_url":"http://patchwork.ozlabs.org/comment/1796617/","msgid":"<20171031132019.76197945@fiorina>","list_archive_url":null,"date":"2017-10-31T12:20:19","subject":"Re: [Qemu-devel] [PATCH v2 1/1] virtio_balloon: include buffers and\n\tcached memory statistics","submitter":{"id":69377,"url":"http://patchwork.ozlabs.org/api/people/69377/","name":"Tomáš Golembiovský","email":"tgolembi@redhat.com"},"content":"ping\n\n+Gil, +Amnon... could you maybe aid in reviewing the patch, please?\n\n\n    Tomas\n\nOn Sun, 22 Oct 2017 20:05:57 +0200\nTomáš Golembiovský <tgolembi@redhat.com> wrote:\n\n> On Thu, 19 Oct 2017 16:12:20 +0300\n> \"Michael S. Tsirkin\" <mst@redhat.com> wrote:\n> \n> > On Thu, Sep 21, 2017 at 02:55:41PM +0200, Tomáš Golembiovský wrote:  \n> > > Add a new fields, VIRTIO_BALLOON_S_BUFFERS and VIRTIO_BALLOON_S_CACHED,\n> > > to virtio_balloon memory statistics protocol. The values correspond to\n> > > 'Buffers' and 'Cached' in /proc/meminfo.\n> > > \n> > > To be able to compute the value of 'Cached' memory it is necessary to\n> > > export total_swapcache_pages() to modules.\n> > > \n> > > Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>  \n> > \n> > Does 'Buffers' actually make sense? It's a temporary storage -\n> > wouldn't it be significantly out of date by the time\n> > host receives it?  \n> \n> That would be best answered by somebody from kernel. But my personal\n> opinion is that it would not be out of date. The amount of memory\n> dedicated to Buffers does not seem to fluctuate too much.\n> \n>     Tomas\n> \n> \n> > > ---\n> > >  drivers/virtio/virtio_balloon.c     | 11 +++++++++++\n> > >  include/uapi/linux/virtio_balloon.h |  4 +++-\n> > >  mm/swap_state.c                     |  1 +\n> > >  3 files changed, 15 insertions(+), 1 deletion(-)\n> > > \n> > > diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c\n> > > index f0b3a0b9d42f..c2558ec47a62 100644\n> > > --- a/drivers/virtio/virtio_balloon.c\n> > > +++ b/drivers/virtio/virtio_balloon.c\n> > > @@ -244,12 +244,19 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)\n> > >  \tstruct sysinfo i;\n> > >  \tunsigned int idx = 0;\n> > >  \tlong available;\n> > > +\tlong cached;\n> > >  \n> > >  \tall_vm_events(events);\n> > >  \tsi_meminfo(&i);\n> > >  \n> > >  \tavailable = si_mem_available();\n> > >  \n> > > +\tcached = global_node_page_state(NR_FILE_PAGES) -\n> > > +\t\t\ttotal_swapcache_pages() - i.bufferram;\n> > > +\tif (cached < 0)\n> > > +\t\tcached = 0;\n> > > +\n> > > +\n> > >  #ifdef CONFIG_VM_EVENT_COUNTERS\n> > >  \tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_IN,\n> > >  \t\t\t\tpages_to_bytes(events[PSWPIN]));\n> > > @@ -264,6 +271,10 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)\n> > >  \t\t\t\tpages_to_bytes(i.totalram));\n> > >  \tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_AVAIL,\n> > >  \t\t\t\tpages_to_bytes(available));\n> > > +\tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_BUFFERS,\n> > > +\t\t\t\tpages_to_bytes(i.bufferram));\n> > > +\tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_CACHED,\n> > > +\t\t\t\tpages_to_bytes(cached));\n> > >  \n> > >  \treturn idx;\n> > >  }\n> > > diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h\n> > > index 343d7ddefe04..d5dc8a56a497 100644\n> > > --- a/include/uapi/linux/virtio_balloon.h\n> > > +++ b/include/uapi/linux/virtio_balloon.h\n> > > @@ -52,7 +52,9 @@ struct virtio_balloon_config {\n> > >  #define VIRTIO_BALLOON_S_MEMFREE  4   /* Total amount of free memory */\n> > >  #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */\n> > >  #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */\n> > > -#define VIRTIO_BALLOON_S_NR       7\n> > > +#define VIRTIO_BALLOON_S_BUFFERS  7   /* Buffers memory as in /proc */\n> > > +#define VIRTIO_BALLOON_S_CACHED   8   /* Cached memory as in /proc */\n> > > +#define VIRTIO_BALLOON_S_NR       9\n> > >  \n> > >  /*\n> > >   * Memory statistics structure.\n> > > diff --git a/mm/swap_state.c b/mm/swap_state.c\n> > > index 71ce2d1ccbf7..f3a4ff7d6c52 100644\n> > > --- a/mm/swap_state.c\n> > > +++ b/mm/swap_state.c\n> > > @@ -95,6 +95,7 @@ unsigned long total_swapcache_pages(void)\n> > >  \trcu_read_unlock();\n> > >  \treturn ret;\n> > >  }\n> > > +EXPORT_SYMBOL_GPL(total_swapcache_pages);\n> > >  \n> > >  static atomic_t swapin_readahead_hits = ATOMIC_INIT(4);  \n> > \n> > Need an ack from MM crowd on that.\n> >   \n> > > -- \n> > > 2.14.1  \n> \n> \n> -- \n> Tomáš Golembiovský <tgolembi@redhat.com>","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 3yR9Rx5865z9t2l\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 31 Oct 2017 23:21:00 +1100 (AEDT)","from localhost ([::1]:45380 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 1e9VXG-0005Z9-B1\n\tfor incoming@patchwork.ozlabs.org; Tue, 31 Oct 2017 08:20:50 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:46024)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <tgolembi@redhat.com>) id 1e9VWx-0005Yc-B2\n\tfor qemu-devel@nongnu.org; Tue, 31 Oct 2017 08:20:32 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <tgolembi@redhat.com>) id 1e9VWr-0003Vy-M2\n\tfor qemu-devel@nongnu.org; Tue, 31 Oct 2017 08:20:28 -0400","from mail-wr0-f195.google.com ([209.85.128.195]:57183)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <tgolembi@redhat.com>) id 1e9VWr-0003VK-Dg\n\tfor qemu-devel@nongnu.org; Tue, 31 Oct 2017 08:20:25 -0400","by mail-wr0-f195.google.com with SMTP id r79so15705212wrb.13\n\tfor <qemu-devel@nongnu.org>; Tue, 31 Oct 2017 05:20:24 -0700 (PDT)","from fiorina (nat-pool-brq-t.redhat.com. [213.175.37.10])\n\tby smtp.gmail.com with ESMTPSA id\n\tp128sm1313642wmb.1.2017.10.31.05.20.23\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tTue, 31 Oct 2017 05:20:23 -0700 (PDT)"],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to\n\t:references:organization:mime-version:content-transfer-encoding;\n\tbh=9wDQV1I+wLCbFrj/ZOwQs+45OUOGyr4CRFlDB+AE3YE=;\n\tb=BHhBZbHi6qkTI2sePZgcFZZwSQlE75TIXgnaN9TLC+uYpTFqw2PrMsSNr8S1k+qIU+\n\tz8ydyidnUVCDpGYVHzdzNKVRdntROs8pVrfLkgrux+q/STnBcEgp9hca0/2v3Lkm5VnJ\n\t03yHizmuV6PBp84tHoLJBxRxArxncfMZ7yAuW4D1NlNpeOmi9UBaD0mAp488RIuKCc2/\n\tnX0wYQ0/tDVeirIKXxUa8sp2e1DZS8dv4FdX6kpNZnxCQ8MsfMcUIrFckSjItyu8BuM9\n\t2LvZa3yj3PM637lyfmelpUsLryW85YMdgNt8ctoCd7nxrBBDvQMaowD133mQVTf3dsv1\n\tmUvw==","X-Gm-Message-State":"AMCzsaVp2WxNCQM/NBk90nRUEKDMr192lXR2FzfqMTN1yZsJ+nydJ0Nm\n\t8KIx9bgfeJeEdcO9yoP1SM/aKw==","X-Google-Smtp-Source":"ABhQp+RpmtNkP/UZdQ9lkUloxiuhCPqfS0GIJDY+hdavbyLUmWTsGusShckOR94xUGhhJWu8iL7rGw==","X-Received":"by 10.223.172.3 with SMTP id v3mr1737400wrc.195.1509452423728;\n\tTue, 31 Oct 2017 05:20:23 -0700 (PDT)","Date":"Tue, 31 Oct 2017 13:20:19 +0100","From":"=?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= <tgolembi@redhat.com>","To":"\"Michael S. Tsirkin\" <mst@redhat.com>","Message-ID":"<20171031132019.76197945@fiorina>","In-Reply-To":"<20171022200557.02558e37@fiorina>","References":"<cover.1505998455.git.tgolembi@redhat.com>\n\t<b13f11c03ed394bd8ad367dc90996ed134ea98da.1505998455.git.tgolembi@redhat.com>\n\t<20171019160405-mutt-send-email-mst@kernel.org>\n\t<20171022200557.02558e37@fiorina>","Organization":"Red Hat","X-Mailer":"Claws Mail 3.15.1-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu)","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"quoted-printable","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.85.128.195","Subject":"Re: [Qemu-devel] [PATCH v2 1/1] virtio_balloon: include buffers and\n\tcached memory statistics","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":"virtio-dev@lists.oasis-open.org, kvm@vger.kernel.org,\n\tGal Hammer <ghammer@redhat.com>,\n\tJason Wang <jasowang@redhat.com>, qemu-devel@nongnu.org,\n\tvirtualization@lists.linux-foundation.org, linux-mm@kvack.org,\n\tWei Wang <wei.w.wang@intel.com>, Shaohua Li <shli@fb.com>,\n\tHuang Ying <ying.huang@intel.com>, Amnon Ilan <ailan@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>"}},{"id":1796738,"web_url":"http://patchwork.ozlabs.org/comment/1796738/","msgid":"<20171031180315-mutt-send-email-mst@kernel.org>","list_archive_url":null,"date":"2017-10-31T16:15:48","subject":"Re: [Qemu-devel] [PATCH v2 1/1] virtio_balloon: include buffers and\n\tcached memory statistics","submitter":{"id":2235,"url":"http://patchwork.ozlabs.org/api/people/2235/","name":"Michael S. Tsirkin","email":"mst@redhat.com"},"content":"On Tue, Oct 31, 2017 at 01:20:19PM +0100, Tomáš Golembiovský wrote:\n> ping\n> \n> +Gil, +Amnon... could you maybe aid in reviewing the patch, please?\n> \n> \n>     Tomas\n> \n> On Sun, 22 Oct 2017 20:05:57 +0200\n> Tomáš Golembiovský <tgolembi@redhat.com> wrote:\n> \n> > On Thu, 19 Oct 2017 16:12:20 +0300\n> > \"Michael S. Tsirkin\" <mst@redhat.com> wrote:\n> > \n> > > On Thu, Sep 21, 2017 at 02:55:41PM +0200, Tomáš Golembiovský wrote:  \n> > > > Add a new fields, VIRTIO_BALLOON_S_BUFFERS and VIRTIO_BALLOON_S_CACHED,\n> > > > to virtio_balloon memory statistics protocol. The values correspond to\n> > > > 'Buffers' and 'Cached' in /proc/meminfo.\n> > > > \n> > > > To be able to compute the value of 'Cached' memory it is necessary to\n> > > > export total_swapcache_pages() to modules.\n> > > > \n> > > > Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>  \n> > > \n> > > Does 'Buffers' actually make sense? It's a temporary storage -\n> > > wouldn't it be significantly out of date by the time\n> > > host receives it?  \n> > \n> > That would be best answered by somebody from kernel. But my personal\n> > opinion is that it would not be out of date. The amount of memory\n> > dedicated to Buffers does not seem to fluctuate too much.\n> > \n> >     Tomas\n> > \n\nI would be inclined to say, just report\nglobal_node_page_state(NR_FILE_PAGES).\nMaybe subtract buffer ram.\n\nIt's not clear host cares about the distinction,\nit's all memory that can shrink in response to\nmemory pressure such as inflating the balloon.\n\nThis statistic is portable as well I think, most guests have\nstorage cache.\n\n\n> > > > ---\n> > > >  drivers/virtio/virtio_balloon.c     | 11 +++++++++++\n> > > >  include/uapi/linux/virtio_balloon.h |  4 +++-\n> > > >  mm/swap_state.c                     |  1 +\n> > > >  3 files changed, 15 insertions(+), 1 deletion(-)\n> > > > \n> > > > diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c\n> > > > index f0b3a0b9d42f..c2558ec47a62 100644\n> > > > --- a/drivers/virtio/virtio_balloon.c\n> > > > +++ b/drivers/virtio/virtio_balloon.c\n> > > > @@ -244,12 +244,19 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)\n> > > >  \tstruct sysinfo i;\n> > > >  \tunsigned int idx = 0;\n> > > >  \tlong available;\n> > > > +\tlong cached;\n> > > >  \n> > > >  \tall_vm_events(events);\n> > > >  \tsi_meminfo(&i);\n> > > >  \n> > > >  \tavailable = si_mem_available();\n> > > >  \n> > > > +\tcached = global_node_page_state(NR_FILE_PAGES) -\n> > > > +\t\t\ttotal_swapcache_pages() - i.bufferram;\n> > > > +\tif (cached < 0)\n> > > > +\t\tcached = 0;\n> > > > +\n> > > > +\n> > > >  #ifdef CONFIG_VM_EVENT_COUNTERS\n> > > >  \tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_IN,\n> > > >  \t\t\t\tpages_to_bytes(events[PSWPIN]));\n> > > > @@ -264,6 +271,10 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)\n> > > >  \t\t\t\tpages_to_bytes(i.totalram));\n> > > >  \tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_AVAIL,\n> > > >  \t\t\t\tpages_to_bytes(available));\n> > > > +\tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_BUFFERS,\n> > > > +\t\t\t\tpages_to_bytes(i.bufferram));\n> > > > +\tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_CACHED,\n> > > > +\t\t\t\tpages_to_bytes(cached));\n> > > >  \n> > > >  \treturn idx;\n> > > >  }\n> > > > diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h\n> > > > index 343d7ddefe04..d5dc8a56a497 100644\n> > > > --- a/include/uapi/linux/virtio_balloon.h\n> > > > +++ b/include/uapi/linux/virtio_balloon.h\n> > > > @@ -52,7 +52,9 @@ struct virtio_balloon_config {\n> > > >  #define VIRTIO_BALLOON_S_MEMFREE  4   /* Total amount of free memory */\n> > > >  #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */\n> > > >  #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */\n> > > > -#define VIRTIO_BALLOON_S_NR       7\n> > > > +#define VIRTIO_BALLOON_S_BUFFERS  7   /* Buffers memory as in /proc */\n> > > > +#define VIRTIO_BALLOON_S_CACHED   8   /* Cached memory as in /proc */\n> > > > +#define VIRTIO_BALLOON_S_NR       9\n> > > >  \n> > > >  /*\n> > > >   * Memory statistics structure.\n> > > > diff --git a/mm/swap_state.c b/mm/swap_state.c\n> > > > index 71ce2d1ccbf7..f3a4ff7d6c52 100644\n> > > > --- a/mm/swap_state.c\n> > > > +++ b/mm/swap_state.c\n> > > > @@ -95,6 +95,7 @@ unsigned long total_swapcache_pages(void)\n> > > >  \trcu_read_unlock();\n> > > >  \treturn ret;\n> > > >  }\n> > > > +EXPORT_SYMBOL_GPL(total_swapcache_pages);\n> > > >  \n> > > >  static atomic_t swapin_readahead_hits = ATOMIC_INIT(4);  \n> > > \n> > > Need an ack from MM crowd on that.\n> > >   \n> > > > -- \n> > > > 2.14.1  \n> > \n> > \n> > -- \n> > Tomáš Golembiovský <tgolembi@redhat.com>\n> \n> \n> -- \n> Tomáš Golembiovský <tgolembi@redhat.com>","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=mst@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 3yRGgb3mFSz9sP1\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed,  1 Nov 2017 03:16:26 +1100 (AEDT)","from localhost ([::1]:46498 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 1e9ZDC-0003FK-2t\n\tfor incoming@patchwork.ozlabs.org; Tue, 31 Oct 2017 12:16:22 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:56548)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <mst@redhat.com>) id 1e9ZCr-0003F3-6E\n\tfor qemu-devel@nongnu.org; Tue, 31 Oct 2017 12:16:02 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <mst@redhat.com>) id 1e9ZCn-0001JH-61\n\tfor qemu-devel@nongnu.org; Tue, 31 Oct 2017 12:16:01 -0400","from mx1.redhat.com ([209.132.183.28]:46928)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <mst@redhat.com>) id 1e9ZCm-0001Ih-Su\n\tfor qemu-devel@nongnu.org; Tue, 31 Oct 2017 12:15:57 -0400","from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])\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 8470821902;\n\tTue, 31 Oct 2017 16:15:55 +0000 (UTC)","from redhat.com (ovpn-124-174.rdu2.redhat.com [10.10.124.174])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id F3E9B600CA;\n\tTue, 31 Oct 2017 16:15:53 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 8470821902","Date":"Tue, 31 Oct 2017 18:15:48 +0200","From":"\"Michael S. Tsirkin\" <mst@redhat.com>","To":"=?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= <tgolembi@redhat.com>","Message-ID":"<20171031180315-mutt-send-email-mst@kernel.org>","References":"<cover.1505998455.git.tgolembi@redhat.com>\n\t<b13f11c03ed394bd8ad367dc90996ed134ea98da.1505998455.git.tgolembi@redhat.com>\n\t<20171019160405-mutt-send-email-mst@kernel.org>\n\t<20171022200557.02558e37@fiorina> <20171031132019.76197945@fiorina>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20171031132019.76197945@fiorina>","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.11","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.25]);\n\tTue, 31 Oct 2017 16:15:55 +0000 (UTC)","Content-Transfer-Encoding":"quoted-printable","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 v2 1/1] virtio_balloon: include buffers and\n\tcached memory statistics","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":"virtio-dev@lists.oasis-open.org, kvm@vger.kernel.org,\n\tGal Hammer <ghammer@redhat.com>,\n\tJason Wang <jasowang@redhat.com>, qemu-devel@nongnu.org,\n\tvirtualization@lists.linux-foundation.org, linux-mm@kvack.org,\n\tWei Wang <wei.w.wang@intel.com>, Shaohua Li <shli@fb.com>,\n\tHuang Ying <ying.huang@intel.com>, Amnon Ilan <ailan@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>"}},{"id":1798552,"web_url":"http://patchwork.ozlabs.org/comment/1798552/","msgid":"<20171103122714.1e2da10d@fiorina>","list_archive_url":null,"date":"2017-11-03T11:27:14","subject":"Re: [Qemu-devel] [PATCH v2 1/1] virtio_balloon: include buffers and\n\tcached memory statistics","submitter":{"id":69377,"url":"http://patchwork.ozlabs.org/api/people/69377/","name":"Tomáš Golembiovský","email":"tgolembi@redhat.com"},"content":"On Tue, 31 Oct 2017 18:15:48 +0200\n\"Michael S. Tsirkin\" <mst@redhat.com> wrote:\n\n> On Tue, Oct 31, 2017 at 01:20:19PM +0100, Tomáš Golembiovský wrote:\n> > ping\n> > \n> > +Gil, +Amnon... could you maybe aid in reviewing the patch, please?\n> > \n> > \n> >     Tomas\n> > \n> > On Sun, 22 Oct 2017 20:05:57 +0200\n> > Tomáš Golembiovský <tgolembi@redhat.com> wrote:\n> > \n> > > On Thu, 19 Oct 2017 16:12:20 +0300\n> > > \"Michael S. Tsirkin\" <mst@redhat.com> wrote:\n> > > \n> > > > On Thu, Sep 21, 2017 at 02:55:41PM +0200, Tomáš Golembiovský wrote:  \n> > > > > Add a new fields, VIRTIO_BALLOON_S_BUFFERS and VIRTIO_BALLOON_S_CACHED,\n> > > > > to virtio_balloon memory statistics protocol. The values correspond to\n> > > > > 'Buffers' and 'Cached' in /proc/meminfo.\n> > > > > \n> > > > > To be able to compute the value of 'Cached' memory it is necessary to\n> > > > > export total_swapcache_pages() to modules.\n> > > > > \n> > > > > Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>  \n> > > > \n> > > > Does 'Buffers' actually make sense? It's a temporary storage -\n> > > > wouldn't it be significantly out of date by the time\n> > > > host receives it?  \n> > > \n> > > That would be best answered by somebody from kernel. But my personal\n> > > opinion is that it would not be out of date. The amount of memory\n> > > dedicated to Buffers does not seem to fluctuate too much.\n> > > \n> > >     Tomas\n> > > \n> \n> I would be inclined to say, just report\n> global_node_page_state(NR_FILE_PAGES).\n> Maybe subtract buffer ram.\n> \n> It's not clear host cares about the distinction,\n> it's all memory that can shrink in response to\n> memory pressure such as inflating the balloon.\n\nSo in procfs terms we'd be sending sum Cached+SwapCahced.\nMartin, would that be good enough?\n\nI wonder whether it would still make sense to send Buffers as a separate\nvalue though. Maybe we should forget about having some granularity here\nand just report all the disk caches as one value.\n\n    Tomas\n\n> \n> This statistic is portable as well I think, most guests have\n> storage cache.\n> \n> \n> > > > > ---\n> > > > >  drivers/virtio/virtio_balloon.c     | 11 +++++++++++\n> > > > >  include/uapi/linux/virtio_balloon.h |  4 +++-\n> > > > >  mm/swap_state.c                     |  1 +\n> > > > >  3 files changed, 15 insertions(+), 1 deletion(-)\n> > > > > \n> > > > > diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c\n> > > > > index f0b3a0b9d42f..c2558ec47a62 100644\n> > > > > --- a/drivers/virtio/virtio_balloon.c\n> > > > > +++ b/drivers/virtio/virtio_balloon.c\n> > > > > @@ -244,12 +244,19 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)\n> > > > >  \tstruct sysinfo i;\n> > > > >  \tunsigned int idx = 0;\n> > > > >  \tlong available;\n> > > > > +\tlong cached;\n> > > > >  \n> > > > >  \tall_vm_events(events);\n> > > > >  \tsi_meminfo(&i);\n> > > > >  \n> > > > >  \tavailable = si_mem_available();\n> > > > >  \n> > > > > +\tcached = global_node_page_state(NR_FILE_PAGES) -\n> > > > > +\t\t\ttotal_swapcache_pages() - i.bufferram;\n> > > > > +\tif (cached < 0)\n> > > > > +\t\tcached = 0;\n> > > > > +\n> > > > > +\n> > > > >  #ifdef CONFIG_VM_EVENT_COUNTERS\n> > > > >  \tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_IN,\n> > > > >  \t\t\t\tpages_to_bytes(events[PSWPIN]));\n> > > > > @@ -264,6 +271,10 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)\n> > > > >  \t\t\t\tpages_to_bytes(i.totalram));\n> > > > >  \tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_AVAIL,\n> > > > >  \t\t\t\tpages_to_bytes(available));\n> > > > > +\tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_BUFFERS,\n> > > > > +\t\t\t\tpages_to_bytes(i.bufferram));\n> > > > > +\tupdate_stat(vb, idx++, VIRTIO_BALLOON_S_CACHED,\n> > > > > +\t\t\t\tpages_to_bytes(cached));\n> > > > >  \n> > > > >  \treturn idx;\n> > > > >  }\n> > > > > diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h\n> > > > > index 343d7ddefe04..d5dc8a56a497 100644\n> > > > > --- a/include/uapi/linux/virtio_balloon.h\n> > > > > +++ b/include/uapi/linux/virtio_balloon.h\n> > > > > @@ -52,7 +52,9 @@ struct virtio_balloon_config {\n> > > > >  #define VIRTIO_BALLOON_S_MEMFREE  4   /* Total amount of free memory */\n> > > > >  #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */\n> > > > >  #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */\n> > > > > -#define VIRTIO_BALLOON_S_NR       7\n> > > > > +#define VIRTIO_BALLOON_S_BUFFERS  7   /* Buffers memory as in /proc */\n> > > > > +#define VIRTIO_BALLOON_S_CACHED   8   /* Cached memory as in /proc */\n> > > > > +#define VIRTIO_BALLOON_S_NR       9\n> > > > >  \n> > > > >  /*\n> > > > >   * Memory statistics structure.\n> > > > > diff --git a/mm/swap_state.c b/mm/swap_state.c\n> > > > > index 71ce2d1ccbf7..f3a4ff7d6c52 100644\n> > > > > --- a/mm/swap_state.c\n> > > > > +++ b/mm/swap_state.c\n> > > > > @@ -95,6 +95,7 @@ unsigned long total_swapcache_pages(void)\n> > > > >  \trcu_read_unlock();\n> > > > >  \treturn ret;\n> > > > >  }\n> > > > > +EXPORT_SYMBOL_GPL(total_swapcache_pages);\n> > > > >  \n> > > > >  static atomic_t swapin_readahead_hits = ATOMIC_INIT(4);  \n> > > > \n> > > > Need an ack from MM crowd on that.\n> > > >   \n> > > > > -- \n> > > > > 2.14.1  \n> > > \n> > > \n> > > -- \n> > > Tomáš Golembiovský <tgolembi@redhat.com>\n> > \n> > \n> > -- \n> > Tomáš Golembiovský <tgolembi@redhat.com>","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 3yT085704Wz9sNc\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  3 Nov 2017 22:28:37 +1100 (AEDT)","from localhost ([::1]:36014 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 1eAa9M-0000bz-3y\n\tfor incoming@patchwork.ozlabs.org; Fri, 03 Nov 2017 07:28:36 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:57855)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <tgolembi@redhat.com>) id 1eAa89-0008SO-H0\n\tfor qemu-devel@nongnu.org; Fri, 03 Nov 2017 07:27:22 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <tgolembi@redhat.com>) id 1eAa86-00009I-BG\n\tfor qemu-devel@nongnu.org; Fri, 03 Nov 2017 07:27:21 -0400","from mail-wm0-f66.google.com ([74.125.82.66]:48293)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <tgolembi@redhat.com>) id 1eAa86-00008c-2H\n\tfor qemu-devel@nongnu.org; Fri, 03 Nov 2017 07:27:18 -0400","by mail-wm0-f66.google.com with SMTP id p75so824196wmg.3\n\tfor <qemu-devel@nongnu.org>; Fri, 03 Nov 2017 04:27:17 -0700 (PDT)","from fiorina (ip-94-112-73-67.net.upcbroadband.cz. [94.112.73.67])\n\tby smtp.gmail.com with ESMTPSA id\n\th56sm7677596ede.15.2017.11.03.04.27.16\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tFri, 03 Nov 2017 04:27:16 -0700 (PDT)"],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to\n\t:references:organization:mime-version:content-transfer-encoding;\n\tbh=GKfpMkdcSqYihay+GGIeCf2kXMHvTm/3qsUIQbR7Y5c=;\n\tb=J0/bzueaXXLKZHlS3VizoUSQf2kNi9FFj3difFvwszoeQyggs0WUlqkvlYntKJdSru\n\t+3auhYLjqvnP9GYzTRJrwcbCZOXACJvOQ1pzBn/vcW7OKdzw4A3FA/EKJQyXbpwc+v4r\n\tGGKwg88c3I8RVCcK+D0NshgLB5d479+hoJw+iqcC/leBYHlPHa7gWxy5/nmeL8VKlxrf\n\toPYtxYleowJGZJlSzY+owpyrrrR8dU5aRUvtCsBOQMYy5WwLt3cVg7TROrjaetTRhMy3\n\toATds5yG2HRJ78ofR5rImnWoUIFCRFkcRtXG9uEE+sy8xTo99HOepg/jdIzkzGdSoN/o\n\tMULw==","X-Gm-Message-State":"AMCzsaWL8ZDNIOk8R6MA5noZ6EKGmcSdK/y6rg3NdJwOfxIQCid3YhbY\n\tT05zb+CwkI6zXImqpausyLIspg==","X-Google-Smtp-Source":"ABhQp+QsBKcSS1K4+gnNGp8shQV37AMzTTZ7rZ8RujQUTNH2TPGaWLKnC6DjmNJGRKUDvTX5dVP0TQ==","X-Received":"by 10.80.145.134 with SMTP id g6mr8632103eda.140.1509708436933; \n\tFri, 03 Nov 2017 04:27:16 -0700 (PDT)","Date":"Fri, 3 Nov 2017 12:27:14 +0100","From":"=?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= <tgolembi@redhat.com>","To":"Martin Sivak <msivak@redhat.com>","Message-ID":"<20171103122714.1e2da10d@fiorina>","In-Reply-To":"<20171031180315-mutt-send-email-mst@kernel.org>","References":"<cover.1505998455.git.tgolembi@redhat.com>\n\t<b13f11c03ed394bd8ad367dc90996ed134ea98da.1505998455.git.tgolembi@redhat.com>\n\t<20171019160405-mutt-send-email-mst@kernel.org>\n\t<20171022200557.02558e37@fiorina> <20171031132019.76197945@fiorina>\n\t<20171031180315-mutt-send-email-mst@kernel.org>","Organization":"Red Hat","X-Mailer":"Claws Mail 3.15.1-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu)","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"quoted-printable","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"74.125.82.66","Subject":"Re: [Qemu-devel] [PATCH v2 1/1] virtio_balloon: include buffers and\n\tcached memory statistics","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":"virtio-dev@lists.oasis-open.org, kvm@vger.kernel.org,\n\t\"Michael S. Tsirkin\" <mst@redhat.com>, Gal Hammer <ghammer@redhat.com>,\n\tJason Wang <jasowang@redhat.com>, qemu-devel@nongnu.org,\n\tvirtualization@lists.linux-foundation.org, linux-mm@kvack.org,\n\tWei Wang <wei.w.wang@intel.com>, Shaohua Li <shli@fb.com>,\n\tHuang Ying <ying.huang@intel.com>, Amnon Ilan <ailan@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>"}}]