From: "Tomáš Golembiovský" <tgolembi@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: linux-mm@kvack.org, virtualization@lists.linux-foundation.org,
qemu-devel@nongnu.org, kvm@vger.kernel.org,
virtio-dev@lists.oasis-open.org, Wei Wang <wei.w.wang@intel.com>,
Shaohua Li <shli@fb.com>, Huang Ying <ying.huang@intel.com>,
Jason Wang <jasowang@redhat.com>, Gal Hammer <ghammer@redhat.com>,
Amnon Ilan <ailan@redhat.com>
Subject: [virtio-dev] Re: [PATCH v2 1/1] virtio_balloon: include buffers and cached memory statistics
Date: Tue, 31 Oct 2017 13:20:19 +0100 [thread overview]
Message-ID: <20171031132019.76197945@fiorina> (raw)
In-Reply-To: <20171022200557.02558e37@fiorina>
ping
+Gil, +Amnon... could you maybe aid in reviewing the patch, please?
Tomas
On Sun, 22 Oct 2017 20:05:57 +0200
Tomáš Golembiovský <tgolembi@redhat.com> wrote:
> On Thu, 19 Oct 2017 16:12:20 +0300
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
>
> > On Thu, Sep 21, 2017 at 02:55:41PM +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ý <tgolembi@redhat.com>
> >
> > Does 'Buffers' actually make sense? It's a temporary storage -
> > wouldn't it be significantly out of date by the time
> > host receives it?
>
> That would be best answered by somebody from kernel. But my personal
> opinion is that it would not be out of date. The amount of memory
> dedicated to Buffers does not seem to fluctuate too much.
>
> Tomas
>
>
> > > ---
> > > 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..d5dc8a56a497 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 /* Buffers memory as in /proc */
> > > +#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);
> >
> > Need an ack from MM crowd on that.
> >
> > > --
> > > 2.14.1
>
>
> --
> Tomáš Golembiovský <tgolembi@redhat.com>
--
Tomáš Golembiovský <tgolembi@redhat.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
WARNING: multiple messages have this Message-ID (diff)
From: "Tomáš Golembiovský" <tgolembi@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: linux-mm@kvack.org, virtualization@lists.linux-foundation.org,
qemu-devel@nongnu.org, kvm@vger.kernel.org,
virtio-dev@lists.oasis-open.org, Wei Wang <wei.w.wang@intel.com>,
Shaohua Li <shli@fb.com>, Huang Ying <ying.huang@intel.com>,
Jason Wang <jasowang@redhat.com>, Gal Hammer <ghammer@redhat.com>,
Amnon Ilan <ailan@redhat.com>
Subject: Re: [PATCH v2 1/1] virtio_balloon: include buffers and cached memory statistics
Date: Tue, 31 Oct 2017 13:20:19 +0100 [thread overview]
Message-ID: <20171031132019.76197945@fiorina> (raw)
In-Reply-To: <20171022200557.02558e37@fiorina>
ping
+Gil, +Amnon... could you maybe aid in reviewing the patch, please?
Tomas
On Sun, 22 Oct 2017 20:05:57 +0200
Tomáš Golembiovský <tgolembi@redhat.com> wrote:
> On Thu, 19 Oct 2017 16:12:20 +0300
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
>
> > On Thu, Sep 21, 2017 at 02:55:41PM +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ý <tgolembi@redhat.com>
> >
> > Does 'Buffers' actually make sense? It's a temporary storage -
> > wouldn't it be significantly out of date by the time
> > host receives it?
>
> That would be best answered by somebody from kernel. But my personal
> opinion is that it would not be out of date. The amount of memory
> dedicated to Buffers does not seem to fluctuate too much.
>
> Tomas
>
>
> > > ---
> > > 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..d5dc8a56a497 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 /* Buffers memory as in /proc */
> > > +#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);
> >
> > Need an ack from MM crowd on that.
> >
> > > --
> > > 2.14.1
>
>
> --
> Tomáš Golembiovský <tgolembi@redhat.com>
--
Tomáš Golembiovský <tgolembi@redhat.com>
--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: "Tomáš Golembiovský" <tgolembi@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: linux-mm@kvack.org, virtualization@lists.linux-foundation.org,
qemu-devel@nongnu.org, kvm@vger.kernel.org,
virtio-dev@lists.oasis-open.org, Wei Wang <wei.w.wang@intel.com>,
Shaohua Li <shli@fb.com>, Huang Ying <ying.huang@intel.com>,
Jason Wang <jasowang@redhat.com>, Gal Hammer <ghammer@redhat.com>,
Amnon Ilan <ailan@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 1/1] virtio_balloon: include buffers and cached memory statistics
Date: Tue, 31 Oct 2017 13:20:19 +0100 [thread overview]
Message-ID: <20171031132019.76197945@fiorina> (raw)
In-Reply-To: <20171022200557.02558e37@fiorina>
ping
+Gil, +Amnon... could you maybe aid in reviewing the patch, please?
Tomas
On Sun, 22 Oct 2017 20:05:57 +0200
Tomáš Golembiovský <tgolembi@redhat.com> wrote:
> On Thu, 19 Oct 2017 16:12:20 +0300
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
>
> > On Thu, Sep 21, 2017 at 02:55:41PM +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ý <tgolembi@redhat.com>
> >
> > Does 'Buffers' actually make sense? It's a temporary storage -
> > wouldn't it be significantly out of date by the time
> > host receives it?
>
> That would be best answered by somebody from kernel. But my personal
> opinion is that it would not be out of date. The amount of memory
> dedicated to Buffers does not seem to fluctuate too much.
>
> Tomas
>
>
> > > ---
> > > 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..d5dc8a56a497 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 /* Buffers memory as in /proc */
> > > +#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);
> >
> > Need an ack from MM crowd on that.
> >
> > > --
> > > 2.14.1
>
>
> --
> Tomáš Golembiovský <tgolembi@redhat.com>
--
Tomáš Golembiovský <tgolembi@redhat.com>
next prev parent reply other threads:[~2017-10-31 12:20 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-21 12:55 [virtio-dev] [PATCH v2 0/1] linux: Buffers/caches in VirtIO Balloon driver stats Tomáš Golembiovský
2017-09-21 12:55 ` [Qemu-devel] " Tomáš Golembiovský
2017-09-21 12:55 ` Tomáš Golembiovský
2017-09-21 12:55 ` Tomáš Golembiovský
2017-09-21 12:55 ` [virtio-dev] [PATCH v2 1/1] virtio_balloon: include buffers and cached memory statistics Tomáš Golembiovský
2017-09-21 12:55 ` [Qemu-devel] " Tomáš Golembiovský
2017-09-21 12:55 ` Tomáš Golembiovský
2017-09-21 12:55 ` Tomáš Golembiovský
2017-10-19 13:12 ` [virtio-dev] " Michael S. Tsirkin
2017-10-19 13:12 ` [Qemu-devel] " Michael S. Tsirkin
2017-10-19 13:12 ` Michael S. Tsirkin
2017-10-19 13:12 ` Michael S. Tsirkin
2017-10-22 18:05 ` [virtio-dev] " Tomáš Golembiovský
2017-10-22 18:05 ` [Qemu-devel] " Tomáš Golembiovský
2017-10-22 18:05 ` Tomáš Golembiovský
2017-10-22 18:05 ` Tomáš Golembiovský
2017-10-31 12:20 ` Tomáš Golembiovský
2017-10-31 12:20 ` Tomáš Golembiovský [this message]
2017-10-31 12:20 ` [Qemu-devel] " Tomáš Golembiovský
2017-10-31 12:20 ` Tomáš Golembiovský
2017-10-31 16:15 ` [virtio-dev] " Michael S. Tsirkin
2017-10-31 16:15 ` [Qemu-devel] " Michael S. Tsirkin
2017-10-31 16:15 ` Michael S. Tsirkin
2017-10-31 16:15 ` Michael S. Tsirkin
2017-11-03 11:27 ` [virtio-dev] " Tomáš Golembiovský
2017-11-03 11:27 ` [Qemu-devel] " Tomáš Golembiovský
2017-11-03 11:27 ` Tomáš Golembiovský
2017-11-03 11:27 ` Tomáš Golembiovský
2017-10-31 16:15 ` Michael S. Tsirkin
2017-10-22 18:05 ` Tomáš Golembiovský
2017-10-19 13:12 ` Michael S. Tsirkin
2017-09-21 12:55 ` Tomáš Golembiovský
2017-10-05 13:51 ` [PATCH v2 0/1] linux: Buffers/caches in VirtIO Balloon driver stats Tomáš Golembiovský
2017-10-05 13:51 ` [virtio-dev] " Tomáš Golembiovský
2017-10-05 13:51 ` [Qemu-devel] " Tomáš Golembiovský
2017-10-05 13:51 ` Tomáš Golembiovský
2017-10-05 13:51 ` Tomáš Golembiovský
2017-10-19 12:33 ` Tomáš Golembiovský
2017-10-19 12:33 ` [virtio-dev] " Tomáš Golembiovský
2017-10-19 12:33 ` [Qemu-devel] " Tomáš Golembiovský
2017-10-19 12:33 ` Tomáš Golembiovský
2017-10-19 12:33 ` Tomáš Golembiovský
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171031132019.76197945@fiorina \
--to=tgolembi@redhat.com \
--cc=ailan@redhat.com \
--cc=ghammer@redhat.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=shli@fb.com \
--cc=virtio-dev@lists.oasis-open.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=wei.w.wang@intel.com \
--cc=ying.huang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.