From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: virtio-dev-return-2557-cohuck=redhat.com@lists.oasis-open.org Sender: List-Post: List-Help: List-Unsubscribe: List-Subscribe: Received: from lists.oasis-open.org (oasis-open.org [66.179.20.138]) by lists.oasis-open.org (Postfix) with ESMTP id 6A10E581925E for ; Wed, 20 Sep 2017 09:01:20 -0700 (PDT) Date: Wed, 20 Sep 2017 18:01:13 +0200 From: =?UTF-8?B?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= Message-ID: <20170920180113.73b76041@fiorina> In-Reply-To: <0bc0c49663fafdf3b03844fe048cac3216d88c5b.1505922364.git.tgolembi@redhat.com> References: <0bc0c49663fafdf3b03844fe048cac3216d88c5b.1505922364.git.tgolembi@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [virtio-dev] Re: [PATCH] virtio_balloon: include buffers and chached memory statistics To: linux-mm@kvack.org, virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Cc: Wei Wang , Shaohua Li , Huang Ying , "Michael S. Tsirkin" , Jason Wang List-ID: On Wed, 20 Sep 2017 17:48:36 +0200 Tom=C3=A1=C5=A1 Golembiovsk=C3=BD wrote: > Add a new fields, VIRTIO_BALLOON_S_BUFFERS and VIRTIO_BALLOON_S_CACHED, > to virtio_balloon memory statistics protocol. The values correspond to > 'Buffers' and 'Cached' in /proc/meminfo. >=20 > To be able to compute the value of 'Cached' memory it is necessary to > export total_swapcache_pages() to modules. >=20 > Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD > --- > drivers/virtio/virtio_balloon.c | 11 +++++++++++ > include/uapi/linux/virtio_balloon.h | 4 +++- > mm/swap_state.c | 1 + > 3 files changed, 15 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_ball= oon.c > index f0b3a0b9d42f..c2558ec47a62 100644 > --- a/drivers/virtio/virtio_balloon.c > +++ b/drivers/virtio/virtio_balloon.c > @@ -244,12 +244,19 @@ static unsigned int update_balloon_stats(struct vir= tio_balloon *vb) > struct sysinfo i; > unsigned int idx =3D 0; > long available; > + long cached; > =20 > all_vm_events(events); > si_meminfo(&i); > =20 > available =3D si_mem_available(); > =20 > + cached =3D global_node_page_state(NR_FILE_PAGES) - > + total_swapcache_pages() - i.bufferram; > + if (cached < 0) > + cached =3D 0; > + > + > #ifdef CONFIG_VM_EVENT_COUNTERS > update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_IN, > pages_to_bytes(events[PSWPIN])); > @@ -264,6 +271,10 @@ static unsigned int update_balloon_stats(struct virt= io_balloon *vb) > pages_to_bytes(i.totalram)); > update_stat(vb, idx++, VIRTIO_BALLOON_S_AVAIL, > pages_to_bytes(available)); > + update_stat(vb, idx++, VIRTIO_BALLOON_S_BUFFERS, > + pages_to_bytes(i.bufferram)); > + update_stat(vb, idx++, VIRTIO_BALLOON_S_CACHED, > + pages_to_bytes(cached)); > =20 > return idx; > } > diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/vir= tio_balloon.h > index 343d7ddefe04..119224c34389 100644 > --- a/include/uapi/linux/virtio_balloon.h > +++ b/include/uapi/linux/virtio_balloon.h > @@ -52,7 +52,9 @@ struct virtio_balloon_config { > #define VIRTIO_BALLOON_S_MEMFREE 4 /* Total amount of free memory */ > #define VIRTIO_BALLOON_S_MEMTOT 5 /* Total amount of memory */ > #define VIRTIO_BALLOON_S_AVAIL 6 /* Available memory as in /proc */ > -#define VIRTIO_BALLOON_S_NR 7 > +#define VIRTIO_BALLOON_S_BUFFERS 7 /* Bufferes memory as in /proc */ I've just noticed I have a typo in the comment: 'Bufferes' should be 'Buffers'. > +#define VIRTIO_BALLOON_S_CACHED 8 /* Cached memory as in /proc */ > +#define VIRTIO_BALLOON_S_NR 9 > =20 > /* > * Memory statistics structure. > diff --git a/mm/swap_state.c b/mm/swap_state.c > index 71ce2d1ccbf7..f3a4ff7d6c52 100644 > --- a/mm/swap_state.c > +++ b/mm/swap_state.c > @@ -95,6 +95,7 @@ unsigned long total_swapcache_pages(void) > rcu_read_unlock(); > return ret; > } > +EXPORT_SYMBOL_GPL(total_swapcache_pages); > =20 > static atomic_t swapin_readahead_hits =3D ATOMIC_INIT(4); > =20 > --=20 > 2.14.1 >=20 --=20 Tom=C3=A1=C5=A1 Golembiovsk=C3=BD --------------------------------------------------------------------- To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?B?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= Subject: Re: [PATCH] virtio_balloon: include buffers and chached memory statistics Date: Wed, 20 Sep 2017 18:01:13 +0200 Message-ID: <20170920180113.73b76041@fiorina> References: <0bc0c49663fafdf3b03844fe048cac3216d88c5b.1505922364.git.tgolembi@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Cc: Wei Wang , Shaohua Li , Huang Ying , "Michael S. Tsirkin" , Jason Wang To: linux-mm@kvack.org, virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Return-path: Received: from mail-wr0-f170.google.com ([209.85.128.170]:53401 "EHLO mail-wr0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751550AbdITQBS (ORCPT ); Wed, 20 Sep 2017 12:01:18 -0400 Received: by mail-wr0-f170.google.com with SMTP id l22so2575927wrc.10 for ; Wed, 20 Sep 2017 09:01:18 -0700 (PDT) In-Reply-To: <0bc0c49663fafdf3b03844fe048cac3216d88c5b.1505922364.git.tgolembi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, 20 Sep 2017 17:48:36 +0200 Tomáš Golembiovský wrote: > Add a new fields, VIRTIO_BALLOON_S_BUFFERS and VIRTIO_BALLOON_S_CACHED, > to virtio_balloon memory statistics protocol. The values correspond to > 'Buffers' and 'Cached' in /proc/meminfo. > > To be able to compute the value of 'Cached' memory it is necessary to > export total_swapcache_pages() to modules. > > Signed-off-by: Tomáš Golembiovský > --- > drivers/virtio/virtio_balloon.c | 11 +++++++++++ > include/uapi/linux/virtio_balloon.h | 4 +++- > mm/swap_state.c | 1 + > 3 files changed, 15 insertions(+), 1 deletion(-) > > diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c > index f0b3a0b9d42f..c2558ec47a62 100644 > --- a/drivers/virtio/virtio_balloon.c > +++ b/drivers/virtio/virtio_balloon.c > @@ -244,12 +244,19 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb) > struct sysinfo i; > unsigned int idx = 0; > long available; > + long cached; > > all_vm_events(events); > si_meminfo(&i); > > available = si_mem_available(); > > + cached = global_node_page_state(NR_FILE_PAGES) - > + total_swapcache_pages() - i.bufferram; > + if (cached < 0) > + cached = 0; > + > + > #ifdef CONFIG_VM_EVENT_COUNTERS > update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_IN, > pages_to_bytes(events[PSWPIN])); > @@ -264,6 +271,10 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb) > pages_to_bytes(i.totalram)); > update_stat(vb, idx++, VIRTIO_BALLOON_S_AVAIL, > pages_to_bytes(available)); > + update_stat(vb, idx++, VIRTIO_BALLOON_S_BUFFERS, > + pages_to_bytes(i.bufferram)); > + update_stat(vb, idx++, VIRTIO_BALLOON_S_CACHED, > + pages_to_bytes(cached)); > > return idx; > } > diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h > index 343d7ddefe04..119224c34389 100644 > --- a/include/uapi/linux/virtio_balloon.h > +++ b/include/uapi/linux/virtio_balloon.h > @@ -52,7 +52,9 @@ struct virtio_balloon_config { > #define VIRTIO_BALLOON_S_MEMFREE 4 /* Total amount of free memory */ > #define VIRTIO_BALLOON_S_MEMTOT 5 /* Total amount of memory */ > #define VIRTIO_BALLOON_S_AVAIL 6 /* Available memory as in /proc */ > -#define VIRTIO_BALLOON_S_NR 7 > +#define VIRTIO_BALLOON_S_BUFFERS 7 /* Bufferes memory as in /proc */ I've just noticed I have a typo in the comment: 'Bufferes' should be 'Buffers'. > +#define VIRTIO_BALLOON_S_CACHED 8 /* Cached memory as in /proc */ > +#define VIRTIO_BALLOON_S_NR 9 > > /* > * Memory statistics structure. > diff --git a/mm/swap_state.c b/mm/swap_state.c > index 71ce2d1ccbf7..f3a4ff7d6c52 100644 > --- a/mm/swap_state.c > +++ b/mm/swap_state.c > @@ -95,6 +95,7 @@ unsigned long total_swapcache_pages(void) > rcu_read_unlock(); > return ret; > } > +EXPORT_SYMBOL_GPL(total_swapcache_pages); > > static atomic_t swapin_readahead_hits = ATOMIC_INIT(4); > > -- > 2.14.1 > -- Tomáš Golembiovský From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f197.google.com (mail-wr0-f197.google.com [209.85.128.197]) by kanga.kvack.org (Postfix) with ESMTP id C8D5A6B0033 for ; Wed, 20 Sep 2017 12:01:19 -0400 (EDT) Received: by mail-wr0-f197.google.com with SMTP id 97so3516455wrb.1 for ; Wed, 20 Sep 2017 09:01:19 -0700 (PDT) Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id i48sor926327wrf.19.2017.09.20.09.01.18 for (Google Transport Security); Wed, 20 Sep 2017 09:01:18 -0700 (PDT) Date: Wed, 20 Sep 2017 18:01:13 +0200 From: =?UTF-8?B?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= Subject: Re: [PATCH] virtio_balloon: include buffers and chached memory statistics Message-ID: <20170920180113.73b76041@fiorina> In-Reply-To: <0bc0c49663fafdf3b03844fe048cac3216d88c5b.1505922364.git.tgolembi@redhat.com> References: <0bc0c49663fafdf3b03844fe048cac3216d88c5b.1505922364.git.tgolembi@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: To: linux-mm@kvack.org, virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Cc: Wei Wang , Shaohua Li , Huang Ying , "Michael S. Tsirkin" , Jason Wang On Wed, 20 Sep 2017 17:48:36 +0200 Tom=C3=A1=C5=A1 Golembiovsk=C3=BD wrote: > Add a new fields, VIRTIO_BALLOON_S_BUFFERS and VIRTIO_BALLOON_S_CACHED, > to virtio_balloon memory statistics protocol. The values correspond to > 'Buffers' and 'Cached' in /proc/meminfo. >=20 > To be able to compute the value of 'Cached' memory it is necessary to > export total_swapcache_pages() to modules. >=20 > Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD > --- > drivers/virtio/virtio_balloon.c | 11 +++++++++++ > include/uapi/linux/virtio_balloon.h | 4 +++- > mm/swap_state.c | 1 + > 3 files changed, 15 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_ball= oon.c > index f0b3a0b9d42f..c2558ec47a62 100644 > --- a/drivers/virtio/virtio_balloon.c > +++ b/drivers/virtio/virtio_balloon.c > @@ -244,12 +244,19 @@ static unsigned int update_balloon_stats(struct vir= tio_balloon *vb) > struct sysinfo i; > unsigned int idx =3D 0; > long available; > + long cached; > =20 > all_vm_events(events); > si_meminfo(&i); > =20 > available =3D si_mem_available(); > =20 > + cached =3D global_node_page_state(NR_FILE_PAGES) - > + total_swapcache_pages() - i.bufferram; > + if (cached < 0) > + cached =3D 0; > + > + > #ifdef CONFIG_VM_EVENT_COUNTERS > update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_IN, > pages_to_bytes(events[PSWPIN])); > @@ -264,6 +271,10 @@ static unsigned int update_balloon_stats(struct virt= io_balloon *vb) > pages_to_bytes(i.totalram)); > update_stat(vb, idx++, VIRTIO_BALLOON_S_AVAIL, > pages_to_bytes(available)); > + update_stat(vb, idx++, VIRTIO_BALLOON_S_BUFFERS, > + pages_to_bytes(i.bufferram)); > + update_stat(vb, idx++, VIRTIO_BALLOON_S_CACHED, > + pages_to_bytes(cached)); > =20 > return idx; > } > diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/vir= tio_balloon.h > index 343d7ddefe04..119224c34389 100644 > --- a/include/uapi/linux/virtio_balloon.h > +++ b/include/uapi/linux/virtio_balloon.h > @@ -52,7 +52,9 @@ struct virtio_balloon_config { > #define VIRTIO_BALLOON_S_MEMFREE 4 /* Total amount of free memory */ > #define VIRTIO_BALLOON_S_MEMTOT 5 /* Total amount of memory */ > #define VIRTIO_BALLOON_S_AVAIL 6 /* Available memory as in /proc */ > -#define VIRTIO_BALLOON_S_NR 7 > +#define VIRTIO_BALLOON_S_BUFFERS 7 /* Bufferes memory as in /proc */ I've just noticed I have a typo in the comment: 'Bufferes' should be 'Buffers'. > +#define VIRTIO_BALLOON_S_CACHED 8 /* Cached memory as in /proc */ > +#define VIRTIO_BALLOON_S_NR 9 > =20 > /* > * Memory statistics structure. > diff --git a/mm/swap_state.c b/mm/swap_state.c > index 71ce2d1ccbf7..f3a4ff7d6c52 100644 > --- a/mm/swap_state.c > +++ b/mm/swap_state.c > @@ -95,6 +95,7 @@ unsigned long total_swapcache_pages(void) > rcu_read_unlock(); > return ret; > } > +EXPORT_SYMBOL_GPL(total_swapcache_pages); > =20 > static atomic_t swapin_readahead_hits =3D ATOMIC_INIT(4); > =20 > --=20 > 2.14.1 >=20 --=20 Tom=C3=A1=C5=A1 Golembiovsk=C3=BD -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44157) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duhRD-0000dx-3G for qemu-devel@nongnu.org; Wed, 20 Sep 2017 12:01:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duhR9-0008NH-2l for qemu-devel@nongnu.org; Wed, 20 Sep 2017 12:01:23 -0400 Received: from mail-wr0-f181.google.com ([209.85.128.181]:55002) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1duhR8-0008LL-St for qemu-devel@nongnu.org; Wed, 20 Sep 2017 12:01:19 -0400 Received: by mail-wr0-f181.google.com with SMTP id g29so2557178wrg.11 for ; Wed, 20 Sep 2017 09:01:18 -0700 (PDT) Date: Wed, 20 Sep 2017 18:01:13 +0200 From: =?UTF-8?B?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= Message-ID: <20170920180113.73b76041@fiorina> In-Reply-To: <0bc0c49663fafdf3b03844fe048cac3216d88c5b.1505922364.git.tgolembi@redhat.com> References: <0bc0c49663fafdf3b03844fe048cac3216d88c5b.1505922364.git.tgolembi@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] virtio_balloon: include buffers and chached memory statistics List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: linux-mm@kvack.org, virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Cc: Wei Wang , Shaohua Li , Huang Ying , "Michael S. Tsirkin" , Jason Wang On Wed, 20 Sep 2017 17:48:36 +0200 Tom=C3=A1=C5=A1 Golembiovsk=C3=BD wrote: > Add a new fields, VIRTIO_BALLOON_S_BUFFERS and VIRTIO_BALLOON_S_CACHED, > to virtio_balloon memory statistics protocol. The values correspond to > 'Buffers' and 'Cached' in /proc/meminfo. >=20 > To be able to compute the value of 'Cached' memory it is necessary to > export total_swapcache_pages() to modules. >=20 > Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD > --- > drivers/virtio/virtio_balloon.c | 11 +++++++++++ > include/uapi/linux/virtio_balloon.h | 4 +++- > mm/swap_state.c | 1 + > 3 files changed, 15 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_ball= oon.c > index f0b3a0b9d42f..c2558ec47a62 100644 > --- a/drivers/virtio/virtio_balloon.c > +++ b/drivers/virtio/virtio_balloon.c > @@ -244,12 +244,19 @@ static unsigned int update_balloon_stats(struct vir= tio_balloon *vb) > struct sysinfo i; > unsigned int idx =3D 0; > long available; > + long cached; > =20 > all_vm_events(events); > si_meminfo(&i); > =20 > available =3D si_mem_available(); > =20 > + cached =3D global_node_page_state(NR_FILE_PAGES) - > + total_swapcache_pages() - i.bufferram; > + if (cached < 0) > + cached =3D 0; > + > + > #ifdef CONFIG_VM_EVENT_COUNTERS > update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_IN, > pages_to_bytes(events[PSWPIN])); > @@ -264,6 +271,10 @@ static unsigned int update_balloon_stats(struct virt= io_balloon *vb) > pages_to_bytes(i.totalram)); > update_stat(vb, idx++, VIRTIO_BALLOON_S_AVAIL, > pages_to_bytes(available)); > + update_stat(vb, idx++, VIRTIO_BALLOON_S_BUFFERS, > + pages_to_bytes(i.bufferram)); > + update_stat(vb, idx++, VIRTIO_BALLOON_S_CACHED, > + pages_to_bytes(cached)); > =20 > return idx; > } > diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/vir= tio_balloon.h > index 343d7ddefe04..119224c34389 100644 > --- a/include/uapi/linux/virtio_balloon.h > +++ b/include/uapi/linux/virtio_balloon.h > @@ -52,7 +52,9 @@ struct virtio_balloon_config { > #define VIRTIO_BALLOON_S_MEMFREE 4 /* Total amount of free memory */ > #define VIRTIO_BALLOON_S_MEMTOT 5 /* Total amount of memory */ > #define VIRTIO_BALLOON_S_AVAIL 6 /* Available memory as in /proc */ > -#define VIRTIO_BALLOON_S_NR 7 > +#define VIRTIO_BALLOON_S_BUFFERS 7 /* Bufferes memory as in /proc */ I've just noticed I have a typo in the comment: 'Bufferes' should be 'Buffers'. > +#define VIRTIO_BALLOON_S_CACHED 8 /* Cached memory as in /proc */ > +#define VIRTIO_BALLOON_S_NR 9 > =20 > /* > * Memory statistics structure. > diff --git a/mm/swap_state.c b/mm/swap_state.c > index 71ce2d1ccbf7..f3a4ff7d6c52 100644 > --- a/mm/swap_state.c > +++ b/mm/swap_state.c > @@ -95,6 +95,7 @@ unsigned long total_swapcache_pages(void) > rcu_read_unlock(); > return ret; > } > +EXPORT_SYMBOL_GPL(total_swapcache_pages); > =20 > static atomic_t swapin_readahead_hits =3D ATOMIC_INIT(4); > =20 > --=20 > 2.14.1 >=20 --=20 Tom=C3=A1=C5=A1 Golembiovsk=C3=BD