Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [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)
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ 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] 9+ 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-21  1:23   ` Nico Pache
  2026-11-23  5:38   ` Lance Yang
  2026-11-20 10:34 ` [PATCH 2/2] vmw_balloon: account 2 MiB pages in NR_BALLOON_PAGES David Hildenbrand (Arm)
  2026-11-21 12:26 ` [PATCH 0/2] mm: two NR_BALLOON_PAGES accounting fixes David Hildenbrand
  2 siblings, 2 replies; 9+ 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 related	[flat|nested] 9+ 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
                     ` (2 more replies)
  2026-11-21 12:26 ` [PATCH 0/2] mm: two NR_BALLOON_PAGES accounting fixes David Hildenbrand
  2 siblings, 3 replies; 9+ 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 related	[flat|nested] 9+ 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)
  2026-11-23  6:34   ` Lance Yang
  2 siblings, 0 replies; 9+ 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] 9+ 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)
  2026-11-23  6:34   ` Lance Yang
  2 siblings, 0 replies; 9+ 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] 9+ messages in thread

* Re: [PATCH 1/2] mm/balloon: fix NR_BALLOON_PAGES accounting during page migration
  2026-11-20 10:34 ` [PATCH 1/2] mm/balloon: fix NR_BALLOON_PAGES accounting during page migration David Hildenbrand (Arm)
@ 2026-11-21  1:23   ` Nico Pache
  2026-11-23  5:38   ` Lance Yang
  1 sibling, 0 replies; 9+ messages in thread
From: Nico Pache @ 2026-11-21  1:23 UTC (permalink / raw)
  To: David Hildenbrand (Arm), Andrew Morton, Jerrin Shaji George,
	Broadcom internal kernel review list, Arnd Bergmann,
	Greg Kroah-Hartman, Lorenzo Stoakes (ARM)
  Cc: linux-mm, virtualization, linux-kernel, stable, Shao Mingyin



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

Acked-by: Nico Pache <nico.pache@linux.dev>

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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/2] mm: two NR_BALLOON_PAGES accounting fixes
  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-21 12:26 ` David Hildenbrand
  2 siblings, 0 replies; 9+ messages in thread
From: David Hildenbrand @ 2026-11-21 12:26 UTC (permalink / raw)
  To: Andrew Morton, Nico Pache, Jerrin Shaji George,
	Broadcom internal kernel review list, Arnd Bergmann,
	Greg Kroah-Hartman, Lorenzo Stoakes (ARM),
	David Hildenbrand (Arm)
  Cc: linux-mm, virtualization, linux-kernel, stable, Shao Mingyin

On Fri, 20 Nov 2026 11:34:41 +0100, David Hildenbrand (Arm) wrote:
> 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.

Applied, thanks!

tree: mm/core.git
branch: balloon-7.5.misc

Applied patches will appear soon in mm-next, followed by linux-next.

Please report any outstanding bugs that were missed during review, so we
can either drop the patch series or decide how to fix it up.

It is encouraged to provide Acked-bys, Reviewed-bys, and Tested-bys even
though the patches have already been applied. If possible, patch trailers
will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. Further, this is not a guarantee that the
patches will go upstream. If in doubt, please check the listed branch.

[1/2] mm/balloon: fix NR_BALLOON_PAGES accounting during page migration
      https://git.kernel.org/mm/core/c/99d23a24
[2/2] vmw_balloon: account 2 MiB pages in NR_BALLOON_PAGES
      https://git.kernel.org/mm/core/c/7e980d06

-- 
Cheers,

David



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] mm/balloon: fix NR_BALLOON_PAGES accounting during page migration
  2026-11-20 10:34 ` [PATCH 1/2] mm/balloon: fix NR_BALLOON_PAGES accounting during page migration David Hildenbrand (Arm)
  2026-11-21  1:23   ` Nico Pache
@ 2026-11-23  5:38   ` Lance Yang
  1 sibling, 0 replies; 9+ messages in thread
From: Lance Yang @ 2026-11-23  5:38 UTC (permalink / raw)
  To: david
  Cc: akpm, nico.pache, jerrin.shaji-george, bcm-kernel-feedback-list,
	arnd, gregkh, ljs, linux-mm, virtualization, linux-kernel, stable,
	shao.mingyin


On Fri, Nov 20, 2026 at 11:34:42AM +0100, 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: 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>
>---

Reviewed-by: Lance Yang <lance.yang@linux.dev>


^ permalink raw reply	[flat|nested] 9+ 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)
@ 2026-11-23  6:34   ` Lance Yang
  2 siblings, 0 replies; 9+ messages in thread
From: Lance Yang @ 2026-11-23  6:34 UTC (permalink / raw)
  To: david
  Cc: akpm, nico.pache, jerrin.shaji-george, bcm-kernel-feedback-list,
	arnd, gregkh, ljs, 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>
>---

Reviewed-by: Lance Yang <lance.yang@linux.dev>


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-11-23  6:34 UTC | newest]

Thread overview: 9+ 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-21  1:23   ` Nico Pache
2026-11-23  5:38   ` Lance Yang
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)
2026-11-23  6:34   ` Lance Yang
2026-11-21 12:26 ` [PATCH 0/2] mm: two NR_BALLOON_PAGES accounting fixes David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox