From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>,
Nico Pache <nico.pache@linux.dev>,
Jerrin Shaji George <jerrin.shaji-george@broadcom.com>,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Cc: linux-mm@kvack.org, virtualization@lists.linux.dev,
linux-kernel@vger.kernel.org,
"David Hildenbrand (Arm)" <david@kernel.org>,
stable@vger.kernel.org, Shao Mingyin <shao.mingyin@zte.com.cn>
Subject: [PATCH 1/2] mm/balloon: fix NR_BALLOON_PAGES accounting during page migration
Date: Fri, 20 Nov 2026 11:34:42 +0100 [thread overview]
Message-ID: <20261120-b4-balloon_nr_pages-v1-1-d8944b587819@kernel.org> (raw)
In-Reply-To: <20261120-b4-balloon_nr_pages-v1-0-d8944b587819@kernel.org>
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
next prev parent reply other threads:[~2026-11-20 10:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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) [this message]
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)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261120-b4-balloon_nr_pages-v1-1-d8944b587819@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=gregkh@linuxfoundation.org \
--cc=jerrin.shaji-george@broadcom.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=nico.pache@linux.dev \
--cc=shao.mingyin@zte.com.cn \
--cc=stable@vger.kernel.org \
--cc=virtualization@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®