* [PATCH 0/2] mm: two NR_BALLOON_PAGES accounting fixes
@ 2026-11-20 10:34 David Hildenbrand (Arm)
2026-11-20 10:34 ` [PATCH 1/2] mm/balloon: fix NR_BALLOON_PAGES accounting during page migration David Hildenbrand (Arm)
2026-11-20 10:34 ` [PATCH 2/2] vmw_balloon: account 2 MiB pages in NR_BALLOON_PAGES David Hildenbrand (Arm)
0 siblings, 2 replies; 5+ messages in thread
From: David Hildenbrand (Arm) @ 2026-11-20 10:34 UTC (permalink / raw)
To: Andrew Morton, Nico Pache, Jerrin Shaji George,
Broadcom internal kernel review list, Arnd Bergmann,
Greg Kroah-Hartman, Lorenzo Stoakes (ARM)
Cc: linux-mm, virtualization, linux-kernel, David Hildenbrand (Arm),
stable, Shao Mingyin
Hi,
two simple fixes for NR_BALLOON_PAGES accounting. I can take both
through the mm-core tree.
I tested patch #1 briefly in a QEMU VM with two numa nodes.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
David Hildenbrand (Arm) (2):
mm/balloon: fix NR_BALLOON_PAGES accounting during page migration
vmw_balloon: account 2 MiB pages in NR_BALLOON_PAGES
drivers/misc/vmw_balloon.c | 4 ++++
mm/balloon.c | 5 +++++
2 files changed, 9 insertions(+)
---
base-commit: f7d95bf74091373fad7273db4557df9b5a902335
change-id: 20261120-b4-balloon_nr_pages-7ee96b3be36e
Best regards,
--
David Hildenbrand (Arm) <david@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 1/2] mm/balloon: fix NR_BALLOON_PAGES accounting during page migration 2026-11-20 10:34 [PATCH 0/2] mm: two NR_BALLOON_PAGES accounting fixes David Hildenbrand (Arm) @ 2026-11-20 10:34 ` David Hildenbrand (Arm) 2026-11-20 10:34 ` [PATCH 2/2] vmw_balloon: account 2 MiB pages in NR_BALLOON_PAGES David Hildenbrand (Arm) 1 sibling, 0 replies; 5+ messages in thread From: David Hildenbrand (Arm) @ 2026-11-20 10:34 UTC (permalink / raw) To: Andrew Morton, Nico Pache, Jerrin Shaji George, Broadcom internal kernel review list, Arnd Bergmann, Greg Kroah-Hartman, Lorenzo Stoakes (ARM) Cc: linux-mm, virtualization, linux-kernel, David Hildenbrand (Arm), stable, Shao Mingyin balloon_page_migrate() doesn't update NR_BALLOON_PAGES in two scenarios: (1) If the new page is on a different node than the old page. (2) If the old page was deflated but the new page could not be inflated, effectively deflating the balloon. Consequently the "Balloon" values in /proc/meminfo, the per-node meminfo etc. will be wrong. Fix it by adjusting the "Balloon" counters accordingly just after conditionally adjusting the manage page counts. This has low urgency. Fixes: 4d689474e1b2 ("balloon_compaction: update the NR_BALLOON_PAGES state") Cc: stable@vger.kernel.org Reported-by: Shao Mingyin <shao.mingyin@zte.com.cn> Closes: https://lore.kernel.org/r/20261115004708909xx05JgB9nXnOCG0zL7h_K@zte.com.cn Signed-off-by: David Hildenbrand (Arm) <david@kernel.org> --- mm/balloon.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/balloon.c b/mm/balloon.c index 96a8f1e20bc66..b31543dd4d4d2 100644 --- a/mm/balloon.c +++ b/mm/balloon.c @@ -310,12 +310,17 @@ static int balloon_page_migrate(struct page *newpage, struct page *page, adjust_managed_page_count(page, 1); adjust_managed_page_count(newpage, -1); } + if (page_pgdat(page) != page_pgdat(newpage)) { + dec_node_page_state(page, NR_BALLOON_PAGES); + inc_node_page_state(newpage, NR_BALLOON_PAGES); + } } else { /* Old page was deflated but new page not inflated. */ __count_vm_event(BALLOON_DEFLATE); if (b_dev_info->adjust_managed_page_count) adjust_managed_page_count(page, 1); + dec_node_page_state(page, NR_BALLOON_PAGES); } b_dev_info->isolated_pages--; -- 2.56.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] vmw_balloon: account 2 MiB pages in NR_BALLOON_PAGES 2026-11-20 10:34 [PATCH 0/2] mm: two NR_BALLOON_PAGES accounting fixes David Hildenbrand (Arm) 2026-11-20 10:34 ` [PATCH 1/2] mm/balloon: fix NR_BALLOON_PAGES accounting during page migration David Hildenbrand (Arm) @ 2026-11-20 10:34 ` David Hildenbrand (Arm) 2026-11-20 11:24 ` Greg Kroah-Hartman 2026-11-20 13:22 ` Lorenzo Stoakes (ARM) 1 sibling, 2 replies; 5+ messages in thread From: David Hildenbrand (Arm) @ 2026-11-20 10:34 UTC (permalink / raw) To: Andrew Morton, Nico Pache, Jerrin Shaji George, Broadcom internal kernel review list, Arnd Bergmann, Greg Kroah-Hartman, Lorenzo Stoakes (ARM) Cc: linux-mm, virtualization, linux-kernel, David Hildenbrand (Arm), stable vmw_balloon keeps 2 MiB balloon-inflated pages on its own list, not using balloon core that takes otherwise care of updating NR_BALLOON_PAGES for base pages. So far we didn't account 2 MiB pages under the "Balloon" counters, so /proc/meminfo etc. would not reflect them. Fix it by updating NR_BALLOON_PAGES when enqueuing and dequeuing for these pages manually. This has low urgency. Fixes: 4d689474e1b2 ("balloon_compaction: update the NR_BALLOON_PAGES state") Cc: stable@vger.kernel.org Signed-off-by: David Hildenbrand (Arm) <david@kernel.org> --- drivers/misc/vmw_balloon.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c index 3edb934dd7fd5..47dbcb3be6ed6 100644 --- a/drivers/misc/vmw_balloon.c +++ b/drivers/misc/vmw_balloon.c @@ -1005,6 +1005,8 @@ static void vmballoon_enqueue_page_list(struct vmballoon *b, list_for_each_entry(page, pages, lru) { vmballoon_mark_page_offline(page, VMW_BALLOON_2M_PAGE); + mod_node_page_state(page_pgdat(page), NR_BALLOON_PAGES, + 1 << VMW_BALLOON_2M_ORDER); } list_splice_init(pages, &b->huge_pages); @@ -1049,6 +1051,8 @@ static void vmballoon_dequeue_page_list(struct vmballoon *b, spin_lock(&b->huge_pages_lock); list_for_each_entry_safe(page, tmp, &b->huge_pages, lru) { vmballoon_mark_page_online(page, VMW_BALLOON_2M_PAGE); + mod_node_page_state(page_pgdat(page), NR_BALLOON_PAGES, + -(1 << VMW_BALLOON_2M_ORDER)); list_move(&page->lru, pages); if (++i == n_req_pages) -- 2.56.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] vmw_balloon: account 2 MiB pages in NR_BALLOON_PAGES 2026-11-20 10:34 ` [PATCH 2/2] vmw_balloon: account 2 MiB pages in NR_BALLOON_PAGES David Hildenbrand (Arm) @ 2026-11-20 11:24 ` Greg Kroah-Hartman 2026-11-20 13:22 ` Lorenzo Stoakes (ARM) 1 sibling, 0 replies; 5+ messages in thread From: Greg Kroah-Hartman @ 2026-11-20 11:24 UTC (permalink / raw) To: David Hildenbrand (Arm) Cc: Andrew Morton, Nico Pache, Jerrin Shaji George, Broadcom internal kernel review list, Arnd Bergmann, Lorenzo Stoakes (ARM), linux-mm, virtualization, linux-kernel, stable On Fri, Nov 20, 2026 at 11:34:43AM +0100, David Hildenbrand (Arm) wrote: > vmw_balloon keeps 2 MiB balloon-inflated pages on its own list, not > using balloon core that takes otherwise care of updating NR_BALLOON_PAGES > for base pages. > > So far we didn't account 2 MiB pages under the "Balloon" counters, so > /proc/meminfo etc. would not reflect them. > > Fix it by updating NR_BALLOON_PAGES when enqueuing and dequeuing for > these pages manually. > > This has low urgency. > > Fixes: 4d689474e1b2 ("balloon_compaction: update the NR_BALLOON_PAGES state") > Cc: stable@vger.kernel.org > Signed-off-by: David Hildenbrand (Arm) <david@kernel.org> > --- > drivers/misc/vmw_balloon.c | 4 ++++ > 1 file changed, 4 insertions(+) > Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] vmw_balloon: account 2 MiB pages in NR_BALLOON_PAGES 2026-11-20 10:34 ` [PATCH 2/2] vmw_balloon: account 2 MiB pages in NR_BALLOON_PAGES David Hildenbrand (Arm) 2026-11-20 11:24 ` Greg Kroah-Hartman @ 2026-11-20 13:22 ` Lorenzo Stoakes (ARM) 1 sibling, 0 replies; 5+ messages in thread From: Lorenzo Stoakes (ARM) @ 2026-11-20 13:22 UTC (permalink / raw) To: David Hildenbrand (Arm) Cc: Andrew Morton, Nico Pache, Jerrin Shaji George, Broadcom internal kernel review list, Arnd Bergmann, Greg Kroah-Hartman, linux-mm, virtualization, linux-kernel, stable On Fri, Nov 20, 2026 at 11:34:43AM +0100, David Hildenbrand (Arm) wrote: > vmw_balloon keeps 2 MiB balloon-inflated pages on its own list, not > using balloon core that takes otherwise care of updating NR_BALLOON_PAGES > for base pages. > > So far we didn't account 2 MiB pages under the "Balloon" counters, so > /proc/meminfo etc. would not reflect them. > > Fix it by updating NR_BALLOON_PAGES when enqueuing and dequeuing for > these pages manually. > > This has low urgency. > > Fixes: 4d689474e1b2 ("balloon_compaction: update the NR_BALLOON_PAGES state") > Cc: stable@vger.kernel.org > Signed-off-by: David Hildenbrand (Arm) <david@kernel.org> Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org> > --- > drivers/misc/vmw_balloon.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c > index 3edb934dd7fd5..47dbcb3be6ed6 100644 > --- a/drivers/misc/vmw_balloon.c > +++ b/drivers/misc/vmw_balloon.c > @@ -1005,6 +1005,8 @@ static void vmballoon_enqueue_page_list(struct vmballoon *b, > > list_for_each_entry(page, pages, lru) { > vmballoon_mark_page_offline(page, VMW_BALLOON_2M_PAGE); > + mod_node_page_state(page_pgdat(page), NR_BALLOON_PAGES, > + 1 << VMW_BALLOON_2M_ORDER); > } > > list_splice_init(pages, &b->huge_pages); > @@ -1049,6 +1051,8 @@ static void vmballoon_dequeue_page_list(struct vmballoon *b, > spin_lock(&b->huge_pages_lock); > list_for_each_entry_safe(page, tmp, &b->huge_pages, lru) { > vmballoon_mark_page_online(page, VMW_BALLOON_2M_PAGE); > + mod_node_page_state(page_pgdat(page), NR_BALLOON_PAGES, > + -(1 << VMW_BALLOON_2M_ORDER)); > > list_move(&page->lru, pages); > if (++i == n_req_pages) > > -- > 2.56.1 > -- Cheers, Lorenzo ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-20 13:22 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-11-20 10:34 [PATCH 0/2] mm: two NR_BALLOON_PAGES accounting fixes David Hildenbrand (Arm) 2026-11-20 10:34 ` [PATCH 1/2] mm/balloon: fix NR_BALLOON_PAGES accounting during page migration David Hildenbrand (Arm) 2026-11-20 10:34 ` [PATCH 2/2] vmw_balloon: account 2 MiB pages in NR_BALLOON_PAGES David Hildenbrand (Arm) 2026-11-20 11:24 ` Greg Kroah-Hartman 2026-11-20 13:22 ` Lorenzo Stoakes (ARM)
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®