[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260119152708.0737b211a2167054cf6eb18c@linux-foundation.org>
Date: Mon, 19 Jan 2026 15:27:08 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: "David Hildenbrand (Red Hat)" <david@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
linuxppc-dev@...ts.ozlabs.org, Broadcom internal kernel review list
<bcm-kernel-feedback-list@...adcom.com>, linux-doc@...r.kernel.org,
virtualization@...ts.linux.dev, Oscar Salvador <osalvador@...e.de>, Lorenzo
Stoakes <lorenzo.stoakes@...cle.com>, "Liam R. Howlett"
<Liam.Howlett@...cle.com>, Vlastimil Babka <vbabka@...e.cz>, Mike Rapoport
<rppt@...nel.org>, Suren Baghdasaryan <surenb@...gle.com>, Michal Hocko
<mhocko@...e.com>, Jonathan Corbet <corbet@....net>, Madhavan Srinivasan
<maddy@...ux.ibm.com>, Michael Ellerman <mpe@...erman.id.au>, Nicholas
Piggin <npiggin@...il.com>, Christophe Leroy <christophe.leroy@...roup.eu>,
Arnd Bergmann <arnd@...db.de>, Greg Kroah-Hartman
<gregkh@...uxfoundation.org>, Jerrin Shaji George
<jerrin.shaji-george@...adcom.com>, "Michael S. Tsirkin" <mst@...hat.com>,
Jason Wang <jasowang@...hat.com>, Xuan Zhuo <xuanzhuo@...ux.alibaba.com>,
Eugenio Pérez <eperezma@...hat.com>, Zi Yan
<ziy@...dia.com>
Subject: Re: [PATCH v3 00/24] mm: balloon infrastructure cleanups
On Tue, 20 Jan 2026 00:01:08 +0100 "David Hildenbrand (Red Hat)" <david@...nel.org> wrote:
> I started with wanting to remove the dependency of the balloon
> infrastructure on the page lock, but ended up performing various other
> cleanups, some of which I had on my todo list for years.
>
> This series heavily cleans up and simplifies our balloon infrastructure,
> including our balloon page migration functionality.
Updated, thanks.
fwiw, below is how v3 altered mm.git:
--- a/include/linux/balloon.h~b
+++ a/include/linux/balloon.h
@@ -22,9 +22,9 @@
*
* As the page isolation scanning step a compaction thread does is a lockless
* procedure (from a page standpoint), it might bring some racy situations while
- * performing balloon page compaction. In order to sort out these racy scenarios
- * and safely perform balloon's page compaction and migration we must, always,
- * ensure following these simple rules:
+ * performing balloon page migration. In order to sort out these racy scenarios
+ * and safely perform balloon's page migration we must, always, ensure following
+ * these simple rules:
*
* i. Inflation/deflation must set/clear page->private under the
* balloon_pages_lock
@@ -47,8 +47,8 @@
* Balloon device information descriptor.
* This struct is used to allow the common balloon page migration interface
* procedures to find the proper balloon device holding memory pages they'll
- * have to cope for page compaction / migration, as well as it serves the
- * balloon driver as a page book-keeper for its registered balloon devices.
+ * have to cope for page migration, as well as it serves the balloon driver as
+ * a page book-keeper for its registered balloon devices.
*/
struct balloon_dev_info {
unsigned long isolated_pages; /* # of isolated pages for migration */
--- a/mm/balloon.c~b
+++ a/mm/balloon.c
@@ -16,7 +16,7 @@
*/
static DEFINE_SPINLOCK(balloon_pages_lock);
-static inline struct balloon_dev_info *balloon_page_device(struct page *page)
+static struct balloon_dev_info *balloon_page_device(struct page *page)
{
return (struct balloon_dev_info *)page_private(page);
}
@@ -29,7 +29,7 @@ static inline struct balloon_dev_info *b
*
* Caller must ensure the balloon_pages_lock is held.
*/
-static inline void balloon_page_insert(struct balloon_dev_info *balloon,
+static void balloon_page_insert(struct balloon_dev_info *balloon,
struct page *page)
{
lockdep_assert_held(&balloon_pages_lock);
@@ -48,7 +48,7 @@ static inline void balloon_page_insert(s
*
* Caller must ensure the balloon_pages_lock is held.
*/
-static inline void balloon_page_finalize(struct page *page)
+static void balloon_page_finalize(struct page *page)
{
lockdep_assert_held(&balloon_pages_lock);
if (IS_ENABLED(CONFIG_BALLOON_MIGRATION))
@@ -262,7 +262,11 @@ static void balloon_page_putback(struct
struct balloon_dev_info *b_dev_info = balloon_page_device(page);
unsigned long flags;
- /* Isolated balloon pages cannot get deflated. */
+ /*
+ * When we isolated the page, the page was still inflated in a balloon
+ * device. As isolated balloon pages cannot get deflated, we still have
+ * a balloon device here.
+ */
if (WARN_ON_ONCE(!b_dev_info))
return;
@@ -279,18 +283,22 @@ static int balloon_page_migrate(struct p
unsigned long flags;
int rc;
- /* Isolated balloon pages cannot get deflated. */
+ /*
+ * When we isolated the page, the page was still inflated in a balloon
+ * device. As isolated balloon pages cannot get deflated, we still have
+ * a balloon device here.
+ */
if (WARN_ON_ONCE(!b_dev_info))
return -EAGAIN;
rc = b_dev_info->migratepage(b_dev_info, newpage, page, mode);
- switch (rc) {
- case 0:
- spin_lock_irqsave(&balloon_pages_lock, flags);
+ if (rc < 0 && rc != -ENOENT)
+ return rc;
+ spin_lock_irqsave(&balloon_pages_lock, flags);
+ if (!rc) {
/* Insert the new page into the balloon list. */
get_page(newpage);
-
balloon_page_insert(b_dev_info, newpage);
__count_vm_event(BALLOON_MIGRATE);
@@ -303,18 +311,12 @@ static int balloon_page_migrate(struct p
adjust_managed_page_count(page, 1);
adjust_managed_page_count(newpage, -1);
}
- break;
- case -ENOENT:
- spin_lock_irqsave(&balloon_pages_lock, flags);
-
+ } 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);
- break;
- default:
- return rc;
}
b_dev_info->isolated_pages--;
_
Powered by blists - more mailing lists