[PATCH v3 16/24] mm/balloon_compaction: assert that the balloon_pages_lock is held

David Hildenbrand (Red Hat) david at kernel.org
Tue Jan 20 10:01:24 AEDT 2026


Let's add some sanity checks for holding the balloon_pages_lock when
we're effectively inflating/deflating a page.

Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes at oracle.com>
Acked-by: Michael S. Tsirkin <mst at redhat.com>
Signed-off-by: David Hildenbrand (Red Hat) <david at kernel.org>
---
 mm/balloon_compaction.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c
index e0a4b481c3eda..bb2e5ec2cab36 100644
--- a/mm/balloon_compaction.c
+++ b/mm/balloon_compaction.c
@@ -33,6 +33,7 @@ static struct balloon_dev_info *balloon_page_device(struct page *page)
 static void balloon_page_insert(struct balloon_dev_info *balloon,
 				       struct page *page)
 {
+	lockdep_assert_held(&balloon_pages_lock);
 	__SetPageOffline(page);
 	if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) {
 		SetPageMovableOps(page);
@@ -50,6 +51,7 @@ static void balloon_page_insert(struct balloon_dev_info *balloon,
  */
 static void balloon_page_finalize(struct page *page)
 {
+	lockdep_assert_held(&balloon_pages_lock);
 	if (IS_ENABLED(CONFIG_BALLOON_COMPACTION))
 		set_page_private(page, 0);
 	/* PageOffline is sticky until the page is freed to the buddy. */
-- 
2.52.0



More information about the Linuxppc-dev mailing list