[PATCH 1/2] mm/balloon: fix NR_BALLOON_PAGES accounting during page migration
From: David Hildenbrand (Arm)
Date: Fri Nov 20 2026 - 05:35:07 EST
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@xxxxxxxxxxxxxxx
Reported-by: Shao Mingyin <shao.mingyin@xxxxxxxxxx>
Closes: https://lore.kernel.org/r/20261115004708909xx05JgB9nXnOCG0zL7h_K@xxxxxxxxxx
Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
---
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