On 11/20/26 3:34 AM, David Hildenbrand (Arm) wrote:
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: [email protected]
Reported-by: Shao Mingyin <[email protected]>
Closes: 
https://lore.kernel.org/r/[email protected]
Signed-off-by: David Hildenbrand (Arm) <[email protected]>

Acked-by: Nico Pache <[email protected]>

---
  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--;



Reply via email to