Tomáš Golembiovský
2017-Sep-21 12:55 UTC
[PATCH v2 0/1] linux: Buffers/caches in VirtIO Balloon driver stats
Linux driver part v2: - fixed typos Tom?? Golembiovsk? (1): virtio_balloon: include buffers and cached memory statistics 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(-) -- 2.14.1
Tomáš Golembiovský
2017-Sep-21 12:55 UTC
[PATCH v2 1/1] virtio_balloon: include buffers and cached memory statistics
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 at redhat.com> --- 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); -- 2.14.1
Tomáš Golembiovský
2017-Oct-05 13:51 UTC
[PATCH v2 0/1] linux: Buffers/caches in VirtIO Balloon driver stats
On Thu, 21 Sep 2017 14:55:40 +0200 Tom?? Golembiovsk? <tgolembi at redhat.com> wrote:> Linux driver part > > v2: > - fixed typos > > Tom?? Golembiovsk? (1): > virtio_balloon: include buffers and cached memory statistics > > 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(-) > > -- > 2.14.1 >ping -- Tom?? Golembiovsk? <tgolembi at redhat.com>
Tomáš Golembiovský
2017-Oct-19 12:33 UTC
[PATCH v2 0/1] linux: Buffers/caches in VirtIO Balloon driver stats
On Thu, 5 Oct 2017 15:51:18 +0200 Tom?? Golembiovsk? <tgolembi at redhat.com> wrote:> On Thu, 21 Sep 2017 14:55:40 +0200 > Tom?? Golembiovsk? <tgolembi at redhat.com> wrote: > > > Linux driver part > > > > v2: > > - fixed typos > > > > Tom?? Golembiovsk? (1): > > virtio_balloon: include buffers and cached memory statistics > > > > 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(-) > > > > -- > > 2.14.1 > > > > pingping -- Tom?? Golembiovsk? <tgolembi at redhat.com>
Michael S. Tsirkin
2017-Oct-19 13:12 UTC
[PATCH v2 1/1] virtio_balloon: include buffers and cached memory statistics
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 at 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?> --- > 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
Apparently Analagous Threads
- [PATCH v2 1/1] virtio_balloon: include buffers and cached memory statistics
- [PATCH v2 1/1] virtio_balloon: include buffers and cached memory statistics
- [PATCH v2 1/1] virtio_balloon: include buffers and cached memory statistics
- [PATCH v2 0/1] linux: Buffers/caches in VirtIO Balloon driver stats
- [PATCH v2 0/1] linux: Buffers/caches in VirtIO Balloon driver stats