track memory used by balloon drivers
Subsystems (15)
cover track memory used by balloon drivers
This series introduces a way to track memory used by balloon drivers.
Add a NR_BALLOON_PAGES counter to track how many pages are reclaimed by the balloon drivers. First add the accounting, then updates the balloon drivers (virtio, Hyper-V, VMware, and Xen) to maintain this counter.
This makes the information visible in memory reporting interfaces like /proc/meminfo, show_mem, and OOM reporting.
This provides admins visibility into their VM balloon sizes without requiring different virtualization tooling. Furthermore, this information is helpful when debugging an OOM inside a VM.
Tested: virtio_balloon, run stress-ng, inflate balloon, oom prints
Nico Pache (5):
meminfo: add a per node counter for balloon drivers
virtio_balloon: update the NR_BALLOON_PAGES state
hv_balloon: update the NR_BALLOON_PAGES state
vmx_balloon: update the NR_BALLOON_PAGES state
xen: balloon: update the NR_BALLOON_PAGES state
drivers/hv/hv_balloon.c | 2 ++ drivers/misc/vmw_balloon.c | 5 ++++- drivers/virtio/virtio_balloon.c | 4 ++++ drivers/xen/balloon.c | 4 ++++ fs/proc/meminfo.c | 2 ++ include/linux/mmzone.h | 1 + mm/memcontrol.c | 1 + mm/show_mem.c | 4 +++- mm/vmstat.c | 1 + 9 files changed, 22 insertions(+), 2 deletions(-)
Signature · 1 line
2.48.1
RFC 1/5 meminfo: add a per node counter for balloon drivers
Add NR_BALLOON_PAGES counter to track memory used by balloon drivers and expose it through /proc/meminfo and other memory reporting interfaces.
--- fs/proc/meminfo.c | 2 ++ include/linux/mmzone.h | 1 + mm/memcontrol.c | 1 + mm/show_mem.c | 4 +++- mm/vmstat.c | 1 + 5 files changed, 8 insertions(+), 1 deletion(-)
fs/proc/meminfo.c +2 -0
@@ -162,6 +162,8 @@ static int meminfo_proc_show(struct seq_file *m, void *v)show_val_kb (m,"Unaccepted: " ,global_zone_page_state (NR_UNACCEPTED ));#endif +show_val_kb (m,"Balloon: " , +global_node_page_state (NR_BALLOON_PAGES ));hugetlb_report_meminfo (m);
include/linux/mmzone.h +1 -0
@@ -223,6 +223,7 @@ enum node_stat_item {#ifdef CONFIG_HUGETLB_PAGE NR_HUGETLB , #endif +NR_BALLOON_PAGES ,NR_VM_NODE_STAT_ITEMS };
mm/memcontrol.c +1 -0
@@ -1377,6 +1377,7 @@ static const struct memory_stat memory_stats[] = { #ifdef CONFIG_HUGETLB_PAGE { "hugetlb", NR_HUGETLB }, #endif + { "nr_balloon_pages", NR_BALLOON_PAGES }, /* The memory events */ { "workingset_refault_anon", WORKINGSET_REFAULT_ANON },
mm/show_mem.c +3 -1
@@ -260,6 +260,7 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z" pagetables:%lukB" " sec_pagetables:%lukB" " all_unreclaimable? %s" +" Balloon:%lukB" "\n" , pgdat->node_id, K(node_page_state(pgdat, NR_ACTIVE_ANON)),
@@ -285,7 +286,8 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z#endif K (node_page_state (pgdat,NR_PAGETABLE )),K (node_page_state (pgdat,NR_SECONDARY_PAGETABLE )), - str_yes_no(pgdat->kswapd_failures >= MAX_RECLAIM_RETRIES)); +str_yes_no (pgdat->kswapd_failures >=MAX_RECLAIM_RETRIES ), + K(node_page_state(pgdat, NR_BALLOON_PAGES))); }for_each_populated_zone (zone) {
mm/vmstat.c +1 -0
@@ -1276,6 +1276,7 @@ const char * const vmstat_text[] = {#ifdef CONFIG_HUGETLB_PAGE "nr_hugetlb" , #endif +"nr_balloon_pages" ,/* system-wide enum vm_stat_item counters */ "nr_dirty_threshold" , "nr_dirty_background_threshold",
Signature · 1 line
2.48.1
RFC 2/5 virtio_balloon: update the NR_BALLOON_PAGES state
In reply to Nico PacheUpdate the NR_BALLOON_PAGES counter when pages are added to or removed from the virtio balloon.
--- drivers/virtio/virtio_balloon.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/virtio/virtio_balloon.c +4 -0
@@ -274,6 +274,8 @@ static unsigned int fill_balloon(struct virtio_balloon *vb, size_t num)set_page_pfns (vb, vb->pfns + vb->num_pfns, page); vb->num_pages +=VIRTIO_BALLOON_PAGES_PER_PAGE ; +mod_node_page_state (page_pgdat (page),NR_BALLOON_PAGES , +VIRTIO_BALLOON_PAGES_PER_PAGE );if (!virtio_has_feature (vb->vdev,VIRTIO_BALLOON_F_DEFLATE_ON_OOM ))adjust_managed_page_count (page,-1 );
@@ -324,6 +326,8 @@ static unsigned int leak_balloon(struct virtio_balloon *vb, size_t num)set_page_pfns (vb, vb->pfns + vb->num_pfns, page);list_add (&page->lru, &pages); vb->num_pages -=VIRTIO_BALLOON_PAGES_PER_PAGE ; +mod_node_page_state (page_pgdat (page),NR_BALLOON_PAGES , + -VIRTIO_BALLOON_PAGES_PER_PAGE ); } num_freed_pages = vb->num_pfns;
Signature · 1 line
2.48.1
RFC 3/5 hv_balloon: update the NR_BALLOON_PAGES state
In reply to Nico PacheUpdate the NR_BALLOON_PAGES counter when pages are added to or removed from the Hyper-V balloon.
--- drivers/hv/hv_balloon.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hv/hv_balloon.c +2 -0
@@ -1192,6 +1192,7 @@ static void free_balloon_pages(struct hv_dynmem_device *dm,__ClearPageOffline (pg);__free_page (pg); dm->num_pages_ballooned--; +mod_node_page_state (page_pgdat (pg),NR_BALLOON_PAGES ,-1 );adjust_managed_page_count (pg,1 ); } }
@@ -1221,6 +1222,7 @@ static unsigned int alloc_balloon_pages(struct hv_dynmem_device *dm,return i * alloc_unit; dm->num_pages_ballooned += alloc_unit; +mod_node_page_state (page_pgdat (pg),NR_BALLOON_PAGES , alloc_unit);/* * If we allocatted 2M pages; split them so we
Signature · 1 line
2.48.1
RFC 4/5 vmx_balloon: update the NR_BALLOON_PAGES state
In reply to Nico PacheUpdate the NR_BALLOON_PAGES counter when pages are added to or removed from the VMware balloon.
--- drivers/misc/vmw_balloon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/misc/vmw_balloon.c +4 -1
@@ -673,6 +673,8 @@ static int vmballoon_alloc_page_list(struct vmballoon *b,vmballoon_stats_page_inc (b,VMW_BALLOON_PAGE_STAT_ALLOC , ctl->page_size); +mod_node_page_state (page_pgdat (page),NR_BALLOON_PAGES , +vmballoon_page_in_frames (ctl->page_size)); }if (page) {
@@ -915,6 +917,8 @@ static void vmballoon_release_page_list(struct list_head *page_list,list_for_each_entry_safe (page, tmp, page_list, lru) {list_del (&page->lru);__free_pages (page,vmballoon_page_order (page_size)); +mod_node_page_state (page_pgdat (page),NR_BALLOON_PAGES , + -vmballoon_page_in_frames (page_size)); }if (n_pages)
@@ -1129,7 +1133,6 @@ static void vmballoon_inflate(struct vmballoon *b)/* Update the balloon size */ atomic64_add (ctl.n_pages * page_in_frames, &b->size); -vmballoon_enqueue_page_list (b, &ctl.pages, &ctl.n_pages, ctl.page_size);
Signature · 1 line
2.48.1
RFC 5/5 xen: balloon: update the NR_BALLOON_PAGES state
In reply to Nico PacheUpdate the NR_BALLOON_PAGES counter when pages are added to or removed from the Xen balloon.
--- drivers/xen/balloon.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/xen/balloon.c +4 -0
@@ -157,6 +157,8 @@ static void balloon_append(struct page *page)list_add (&page->lru, &ballooned_pages); balloon_stats.balloon_low++; } +inc_node_page_state (page,NR_BALLOON_PAGES ); +wake_up (&balloon_wq); }
@@ -179,6 +181,8 @@ static struct page *balloon_retrieve(bool require_lowmem) balloon_stats.balloon_low--;__ClearPageOffline (page); +dec_node_page_state (page,NR_BALLOON_PAGES ); +return page; }
Signature · 1 line
2.48.1
Shakeel Butt
maintainerRe: [RFC 1/5] meminfo: add a per node counter for balloon drivers
In reply to Nico PacheQuoted 42 lines · Nico Pache
Add
NR_BALLOON_PAGEScounter to track memory used by balloon drivers and expose it through/proc/meminfoand other memory reporting interfaces.Signed-off-by Nico Pache <[email protected]>--- fs/proc/meminfo.c | 2 ++ include/linux/mmzone.h | 1 + mm/memcontrol.c | 1 + mm/show_mem.c | 4 +++- mm/vmstat.c | 1 + 5 files changed, 8 insertions(+), 1 deletion(-)fs/proc/meminfo.c +2
-0@@ -162,6 +162,8 @@ static int meminfo_proc_show(struct seq_file *m, void *v)show_val_kb (m,"Unaccepted: " ,global_zone_page_state (NR_UNACCEPTED ));#endif +show_val_kb (m,"Balloon: " , +global_node_page_state (NR_BALLOON_PAGES ));hugetlb_report_meminfo (m);include/linux/mmzone.h +1
-0@@ -223,6 +223,7 @@ enum node_stat_item {#ifdef CONFIG_HUGETLB_PAGE NR_HUGETLB , #endif +NR_BALLOON_PAGES ,NR_VM_NODE_STAT_ITEMS };mm/memcontrol.c +0
-0
mm/memcontrol.c static const struct memory_stat memory_stats[] = { · line 1380
Quoted 4 lines
mm/memcontrol.c +1
-0@@ -1377,6 +1377,7 @@ static const struct memory_stat memory_stats[] = { #ifdef CONFIG_HUGETLB_PAGE { "hugetlb", NR_HUGETLB }, #endif + { "nr_balloon_pages", NR_BALLOON_PAGES },
Please remove the above counter from memcontrol.c as I don't think this memory is accounted towards memcg.
Michael S. Tsirkin
maintainerRe: [RFC 2/5] virtio_balloon: update the NR_BALLOON_PAGES state
In reply to Nico PacheQuoted 13 lines · Nico Pache
Update the
NR_BALLOON_PAGEScounter when pages are added to or removed from the virtio balloon.Signed-off-by Nico Pache <[email protected]>--- drivers/virtio/virtio_balloon.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/virtio/virtio_balloon.c +0
-0
drivers/virtio/virtio_balloon.c static unsigned int fill_balloon(struct virtio_balloon *vb, size_t num) · line 281
Quoted 8 lines
drivers/virtio/virtio_balloon.c +2
-0@@ -274,6 +274,8 @@ static unsigned int fill_balloon(struct virtio_balloon *vb, size_t num)set_page_pfns (vb, vb->pfns + vb->num_pfns, page); vb->num_pages +=VIRTIO_BALLOON_PAGES_PER_PAGE ; +mod_node_page_state (page_pgdat (page),NR_BALLOON_PAGES , +VIRTIO_BALLOON_PAGES_PER_PAGE );if (!virtio_has_feature (vb->vdev,VIRTIO_BALLOON_F_DEFLATE_ON_OOM ))adjust_managed_page_count (page,-1 );
This means the counter is in virtio balloon page units, which runs counter to the declared goal of making the interface hypervisor-agnostic.
drivers/virtio/virtio_balloon.c static unsigned int leak_balloon(struct virtio_balloon *vb, size_t num) · line 330
Quoted 6 lines
drivers/virtio/virtio_balloon.c +2
-0@@ -324,6 +326,8 @@ static unsigned int leak_balloon(struct virtio_balloon *vb, size_t num)set_page_pfns (vb, vb->pfns + vb->num_pfns, page);list_add (&page->lru, &pages); vb->num_pages -=VIRTIO_BALLOON_PAGES_PER_PAGE ; +mod_node_page_state (page_pgdat (page),NR_BALLOON_PAGES , + -VIRTIO_BALLOON_PAGES_PER_PAGE );
Same.
Thanks,
Quoted 5 lines
drivers/virtio/virtio_balloon.c +0
-0} num_freed_pages = vb->num_pfns;Signature · 1 line
2.48.1
Michael S. Tsirkin
maintainerRe: [RFC 4/5] vmx_balloon: update the NR_BALLOON_PAGES state
In reply to Nico PacheQuoted 13 lines · Nico Pache
Update the
NR_BALLOON_PAGEScounter when pages are added to or removed from the VMware balloon.Signed-off-by Nico Pache <[email protected]>--- drivers/misc/vmw_balloon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/misc/vmw_balloon.c +0
-0
drivers/misc/vmw_balloon.c static int vmballoon_alloc_page_list(struct vmballoon *b, · line 677
Quoted 5 lines
drivers/misc/vmw_balloon.c +2
-0@@ -673,6 +673,8 @@ static int vmballoon_alloc_page_list(struct vmballoon *b,vmballoon_stats_page_inc (b,VMW_BALLOON_PAGE_STAT_ALLOC , ctl->page_size); +mod_node_page_state (page_pgdat (page),NR_BALLOON_PAGES , +vmballoon_page_in_frames (ctl->page_size));
same issue as virtio I think - this counts frames not pages.
Quoted 13 lines
drivers/misc/vmw_balloon.c +2
-0}if (page) {@@ -915,6 +917,8 @@ static void vmballoon_release_page_list(struct list_head *page_list,list_for_each_entry_safe (page, tmp, page_list, lru) {list_del (&page->lru);__free_pages (page,vmballoon_page_order (page_size)); +mod_node_page_state (page_pgdat (page),NR_BALLOON_PAGES , + -vmballoon_page_in_frames (page_size)); }if (n_pages)
drivers/misc/vmw_balloon.c static void vmballoon_inflate(struct vmballoon *b) · line 1132
Quoted 4 lines
drivers/misc/vmw_balloon.c +0
-1@@ -1129,7 +1133,6 @@ static void vmballoon_inflate(struct vmballoon *b)/* Update the balloon size */ atomic64_add (ctl.n_pages * page_in_frames, &b->size); -
unrelated change
Quoted 5 lines
drivers/misc/vmw_balloon.c +0
-0vmballoon_enqueue_page_list (b, &ctl.pages, &ctl.n_pages, ctl.page_size);Signature · 1 line
2.48.1
Re: [RFC 4/5] vmx_balloon: update the NR_BALLOON_PAGES state
Quoted 16 lines · Michael S. Tsirkin
Quoted 14 lines · Nico Pache
Update the
NR_BALLOON_PAGEScounter when pages are added to or removed from the VMware balloon.Signed-off-by Nico Pache <[email protected]>--- drivers/misc/vmw_balloon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/misc/vmw_balloon.c +0
-0@@ -673,6 +673,8 @@ static int vmballoon_alloc_page_list(struct vmballoon *b,
Quoted 7 lines
drivers/misc/vmw_balloon.c static int vmballoon_alloc_page_list(struct vmballoon *b, · line 677
Quoted 4 lines
drivers/misc/vmw_balloon.c +2
-0vmballoon_stats_page_inc (b,VMW_BALLOON_PAGE_STAT_ALLOC , ctl->page_size); +mod_node_page_state (page_pgdat (page),NR_BALLOON_PAGES , +vmballoon_page_in_frames (ctl->page_size));same issue as virtio I think - this counts frames not pages.
I agree with the viritio issue since PAGE_SIZE can be larger than VIRTIO_BALLOON_PFN_SHIFT, resulting in multiple virtio_balloon pages for each page. I fixed that one, thanks!
For the Vmware one, the code is littered with mentions of counting in 4k or 2M but as far as I can tell from looking at the code it actually operates in PAGE_SIZE or PMD size chunks and this count would be correct.
Perhaps I am missing something though.
Quoted 15 lines
Quoted 15 lines
drivers/misc/vmw_balloon.c +2
-0}if (page) {@@ -915,6 +917,8 @@ static void vmballoon_release_page_list(struct list_head *page_list,list_for_each_entry_safe (page, tmp, page_list, lru) {list_del (&page->lru);__free_pages (page,vmballoon_page_order (page_size)); +mod_node_page_state (page_pgdat (page),NR_BALLOON_PAGES , + -vmballoon_page_in_frames (page_size)); }if (n_pages)@@ -1129,7 +1133,6 @@ static void vmballoon_inflate(struct vmballoon *b)
Quoted 6 lines
drivers/misc/vmw_balloon.c static void vmballoon_inflate(struct vmballoon *b) · line 1132
Quoted 3 lines
drivers/misc/vmw_balloon.c +0
-1/* Update the balloon size */ atomic64_add (ctl.n_pages * page_in_frames, &b->size); -unrelated change
Fixed, Thanks for reviewing!
Quoted 7 lines
Quoted 6 lines
drivers/misc/vmw_balloon.c +0
-1vmballoon_enqueue_page_list (b, &ctl.pages, &ctl.n_pages, ctl.page_size); --2.48.1
Re: [RFC 1/5] meminfo: add a per node counter for balloon drivers
In reply to Shakeel ButtQuoted 39 lines · Shakeel Butt
Quoted 37 lines · Nico Pache
Add
NR_BALLOON_PAGEScounter to track memory used by balloon drivers and expose it through/proc/meminfoand other memory reporting interfaces.Signed-off-by Nico Pache <[email protected]>--- fs/proc/meminfo.c | 2 ++ include/linux/mmzone.h | 1 + mm/memcontrol.c | 1 + mm/show_mem.c | 4 +++- mm/vmstat.c | 1 + 5 files changed, 8 insertions(+), 1 deletion(-)fs/proc/meminfo.c +2
-0@@ -162,6 +162,8 @@ static int meminfo_proc_show(struct seq_file *m, void *v)show_val_kb (m,"Unaccepted: " ,global_zone_page_state (NR_UNACCEPTED ));#endif +show_val_kb (m,"Balloon: " , +global_node_page_state (NR_BALLOON_PAGES ));hugetlb_report_meminfo (m);include/linux/mmzone.h +1
-0@@ -223,6 +223,7 @@ enum node_stat_item {#ifdef CONFIG_HUGETLB_PAGE NR_HUGETLB , #endif +NR_BALLOON_PAGES ,NR_VM_NODE_STAT_ITEMS };
Quoted 12 lines
mm/memcontrol.c static const struct memory_stat memory_stats[] = { · line 1380
Quoted 9 lines
mm/memcontrol.c +1
-0@@ -1377,6 +1377,7 @@ static const struct memory_stat memory_stats[] = { #ifdef CONFIG_HUGETLB_PAGE { "hugetlb", NR_HUGETLB }, #endif + { "nr_balloon_pages", NR_BALLOON_PAGES },Please remove the above counter from
memcontrol.cas I don't think this memory is accounted towards memcg.
Fixed-- Thank you!
Quoted 1 line
Michael S. Tsirkin
maintainerRe: [RFC 4/5] vmx_balloon: update the NR_BALLOON_PAGES state
In reply to Nico PacheQuoted 28 lines · Nico Pache
Quoted 16 lines · Michael S. Tsirkin
Quoted 14 lines · Nico Pache
Update the
NR_BALLOON_PAGEScounter when pages are added to or removed from the VMware balloon.Signed-off-by Nico Pache <[email protected]>--- drivers/misc/vmw_balloon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/misc/vmw_balloon.c +0
-0@@ -673,6 +673,8 @@ static int vmballoon_alloc_page_list(struct vmballoon *b,Quoted 7 lines
drivers/misc/vmw_balloon.c static int vmballoon_alloc_page_list(struct vmballoon *b, · line 677
Quoted 4 lines
drivers/misc/vmw_balloon.c +2
-0vmballoon_stats_page_inc (b,VMW_BALLOON_PAGE_STAT_ALLOC , ctl->page_size); +mod_node_page_state (page_pgdat (page),NR_BALLOON_PAGES , +vmballoon_page_in_frames (ctl->page_size));same issue as virtio I think - this counts frames not pages.
I agree with the viritio issue since
PAGE_SIZEcan be larger thanVIRTIO_BALLOON_PFN_SHIFT, resulting in multiplevirtio_balloonpages for each page. I fixed that one, thanks!
Quoted 5 lines
For the Vmware one, the code is littered with mentions of counting in 4k or 2M but as far as I can tell from looking at the code it actually operates in
PAGE_SIZEor PMD size chunks and this count would be correct.
Perhaps I am missing something though.
Can't say for sure. This needs an ack from the maintainer.
Quoted 29 lines
Quoted 15 lines
Quoted 15 lines
drivers/misc/vmw_balloon.c +2
-0}if (page) {@@ -915,6 +917,8 @@ static void vmballoon_release_page_list(struct list_head *page_list,list_for_each_entry_safe (page, tmp, page_list, lru) {list_del (&page->lru);__free_pages (page,vmballoon_page_order (page_size)); +mod_node_page_state (page_pgdat (page),NR_BALLOON_PAGES , + -vmballoon_page_in_frames (page_size)); }if (n_pages)@@ -1129,7 +1133,6 @@ static void vmballoon_inflate(struct vmballoon *b)Quoted 6 lines
drivers/misc/vmw_balloon.c static void vmballoon_inflate(struct vmballoon *b) · line 1132
Quoted 3 lines
drivers/misc/vmw_balloon.c +0
-1/* Update the balloon size */ atomic64_add (ctl.n_pages * page_in_frames, &b->size); -unrelated change
Fixed, Thanks for reviewing!
Quoted 7 lines
Quoted 6 lines
drivers/misc/vmw_balloon.c +0
-1vmballoon_enqueue_page_list (b, &ctl.pages, &ctl.n_pages, ctl.page_size); --2.48.1
Re: [RFC 4/5] vmx_balloon: update the NR_BALLOON_PAGES state
In reply to Nico PacheQuoted 28 lines · Nico Pache
Quoted 16 lines · Michael S. Tsirkin
Quoted 14 lines · Nico Pache
Update the
NR_BALLOON_PAGEScounter when pages are added to or removed from the VMware balloon.Signed-off-by Nico Pache <[email protected]>--- drivers/misc/vmw_balloon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/misc/vmw_balloon.c +0
-0@@ -673,6 +673,8 @@ static int vmballoon_alloc_page_list(struct vmballoon *b,Quoted 7 lines
drivers/misc/vmw_balloon.c static int vmballoon_alloc_page_list(struct vmballoon *b, · line 677
Quoted 4 lines
drivers/misc/vmw_balloon.c +2
-0vmballoon_stats_page_inc (b,VMW_BALLOON_PAGE_STAT_ALLOC , ctl->page_size); +mod_node_page_state (page_pgdat (page),NR_BALLOON_PAGES , +vmballoon_page_in_frames (ctl->page_size));same issue as virtio I think - this counts frames not pages.
I agree with the viritio issue since
PAGE_SIZEcan be larger thanVIRTIO_BALLOON_PFN_SHIFT, resulting in multiplevirtio_balloonpages for each page. I fixed that one, thanks!
Quoted 5 lines
For the Vmware one, the code is littered with mentions of counting in 4k or 2M but as far as I can tell from looking at the code it actually operates in
PAGE_SIZEor PMD size chunks and this count would be correct.
Perhaps I am missing something though.
vmballoon_page_in_frames() documents to "Return: the number of 4k frames.", because it supports either 4k or 2M chunks IIRC.
I think the catch is that PAGE_SIZE will in these configs always be 4k. Otherwise things like vmballoon_mark_page_offline() wouldn't work as expected.
So I think this is correct.
Signature · 3 lines
Cheers, David / dhildenb
Re: [RFC 1/5] meminfo: add a per node counter for balloon drivers
In reply to Nico PacheQuoted 2 lines · Nico Pache
Add
NR_BALLOON_PAGEScounter to track memory used by balloon drivers and expose it through/proc/meminfoand other memory reporting interfaces.
In balloon_page_enqueue_one(), we perform a
__count_vm_event(BALLOON_INFLATE)
and in balloon_page_list_dequeue
__count_vm_event(BALLOON_DEFLATE);
Should we maybe simply do the per-node accounting similarly there?
Signature · 3 lines
Cheers, David / dhildenb
Re: [RFC 1/5] meminfo: add a per node counter for balloon drivers
Quoted 7 lines · David Hildenbrand
Quoted 2 lines · Nico Pache
Add
NR_BALLOON_PAGEScounter to track memory used by balloon drivers and expose it through/proc/meminfoand other memory reporting interfaces.In
balloon_page_enqueue_one(), we perform a
Quoted 8 lines
__count_vm_event(BALLOON_INFLATE)and in
balloon_page_list_dequeue
__count_vm_event(BALLOON_DEFLATE);Should we maybe simply do the per-node accounting similarly there?
I think the issue is that some balloon drivers use the balloon_compaction interface while others use their own.
This would require unifying all the drivers under a single api which may be tricky if they all have different behavior
Quoted 6 lines
--
Cheers,David / dhildenb
Michael S. Tsirkin
maintainerRe: [RFC 1/5] meminfo: add a per node counter for balloon drivers
In reply to David HildenbrandQuoted 6 lines · David Hildenbrand
Quoted 2 lines · Nico Pache
Add
NR_BALLOON_PAGEScounter to track memory used by balloon drivers and expose it through/proc/meminfoand other memory reporting interfaces.In
balloon_page_enqueue_one(), we perform a
Quoted 8 lines
__count_vm_event(BALLOON_INFLATE)and in
balloon_page_list_dequeue
__count_vm_event(BALLOON_DEFLATE);Should we maybe simply do the per-node accounting similarly there?
BTW should virtio mem be tied into this too, in some way? or is it too different?
Quoted 4 lines
Signature · 3 lines
Cheers, David / dhildenb
Re: [RFC 1/5] meminfo: add a per node counter for balloon drivers
Quoted 11 lines · Michael S. Tsirkin
Quoted 10 lines · David Hildenbrand
Quoted 2 lines · Nico Pache
Add
NR_BALLOON_PAGEScounter to track memory used by balloon drivers and expose it through/proc/meminfoand other memory reporting interfaces.In
balloon_page_enqueue_one(), we perform a
__count_vm_event(BALLOON_INFLATE)and in
balloon_page_list_dequeue
Quoted 8 lines
Quoted 4 lines
__count_vm_event(BALLOON_DEFLATE);Should we maybe simply do the per-node accounting similarly there?
BTW should virtio mem be tied into this too, in some way? or is it too different?
No, we should limit it to actual balloon drivers that e.g., never completely remove memory.
Signature · 3 lines
Cheers, David / dhildenb
Re: [RFC 1/5] meminfo: add a per node counter for balloon drivers
In reply to Nico PacheQuoted 15 lines · Nico Pache
Quoted 14 lines · David Hildenbrand
Quoted 2 lines · Nico Pache
Add
NR_BALLOON_PAGEScounter to track memory used by balloon drivers and expose it through/proc/meminfoand other memory reporting interfaces.In
balloon_page_enqueue_one(), we perform a
__count_vm_event(BALLOON_INFLATE)and in
balloon_page_list_dequeue
__count_vm_event(BALLOON_DEFLATE);
Quoted 7 lines
Quoted 1 line
Should we maybe simply do the per-node accounting similarly there?
I think the issue is that some balloon drivers use the
balloon_compactioninterface while others use their own.This would require unifying all the drivers under a single api which may be tricky if they all have different behavior
Why would that be required? Simply implement it in the balloon compaction logic, and in addition separately in the ones that don't implement it.
That's the same as how we handle PageOffline today.
In summary, we have
virtio-balloon: balloon compaction
hv-balloon: no balloon compaction
xen-balloon: no balloon compaction
vmx-balloon: balloon compaction
pseries-cmm: balloon compaction
So you'd handle 3 balloon drivers in one go.
(this series didn't touch pseries-cmm)
Signature · 3 lines
Cheers, David / dhildenb
Re: [RFC 1/5] meminfo: add a per node counter for balloon drivers
Quoted 22 lines · David Hildenbrand
Quoted 20 lines · Nico Pache
Quoted 7 lines · David Hildenbrand
Quoted 2 lines · Nico Pache
Add
NR_BALLOON_PAGEScounter to track memory used by balloon drivers and expose it through/proc/meminfoand other memory reporting interfaces.In
balloon_page_enqueue_one(), we perform aQuoted 8 lines
__count_vm_event(BALLOON_INFLATE)and in
balloon_page_list_dequeue
__count_vm_event(BALLOON_DEFLATE);Should we maybe simply do the per-node accounting similarly there?
I think the issue is that some balloon drivers use the
balloon_compactioninterface while others use their own.
Quoted 6 lines
Quoted 2 lines
This would require unifying all the drivers under a single api which may be tricky if they all have different behavior
Why would that be required? Simply implement it in the balloon compaction logic, and in addition separately in the ones that don't implement it.
Ah ok that makes sense!
Quoted 10 lines
That's the same as how we handle PageOffline today.
In summary, we have
virtio-balloon: balloon compaction
hv-balloon: no balloon compaction
xen-balloon: no balloon compaction
vmx-balloon: balloon compaction
pseries-cmm: balloon compaction
I'm having a hard time verifying this... it looks like only vmx-balloon uses the balloon_compaction balloon_page_list_enqueue function that calls balloon_page_enqueue_one.
Quoted 4 lines
So you'd handle 3 balloon drivers in one go.
(this series didn't touch pseries-cmm)
Ah I didn't realize that was a balloon driver. Ill add that one to the todo.
Quoted 6 lines
--
Cheers,David / dhildenb
Re: [RFC 1/5] meminfo: add a per node counter for balloon drivers
Quoted 43 lines · Nico Pache
Quoted 22 lines · David Hildenbrand
Quoted 20 lines · Nico Pache
Quoted 7 lines · David Hildenbrand
Quoted 2 lines · Nico Pache
Add
NR_BALLOON_PAGEScounter to track memory used by balloon drivers and expose it through/proc/meminfoand other memory reporting interfaces.In
balloon_page_enqueue_one(), we perform aQuoted 8 lines
__count_vm_event(BALLOON_INFLATE)and in
balloon_page_list_dequeue
__count_vm_event(BALLOON_DEFLATE);Should we maybe simply do the per-node accounting similarly there?
I think the issue is that some balloon drivers use the
balloon_compactioninterface while others use their own.Quoted 6 lines
Quoted 2 lines
This would require unifying all the drivers under a single api which may be tricky if they all have different behavior
Why would that be required? Simply implement it in the balloon compaction logic, and in addition separately in the ones that don't implement it.
Ah ok that makes sense!
Quoted 10 lines
That's the same as how we handle PageOffline today.
In summary, we have
virtio-balloon: balloon compaction
hv-balloon: no balloon compaction
xen-balloon: no balloon compaction
vmx-balloon: balloon compaction
pseries-cmm: balloon compaction
Quoted 3 lines
I'm having a hard time verifying this... it looks like only vmx-balloon uses the
balloon_compactionballoon_page_list_enqueuefunction that callsballoon_page_enqueue_one.
Also check balloon_page_enqueue, which ends up calling balloon_page_enqueue_one.
Quoted 6 lines
Quoted 5 lines
So you'd handle 3 balloon drivers in one go.
(this series didn't touch pseries-cmm)
Ah I didn't realize that was a balloon driver. Ill add that one to the todo.
Well, by implementing it in the compaction code that todo would be done :)
Signature · 3 lines
Cheers, David / dhildenb