mm/balloon_compaction: assert that the balloon_pages_lock is held

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

Link: https://lkml.kernel.org/r/20260119230133.3551867-17-david@kernel.org
Signed-off-by: David Hildenbrand (Red Hat) <david@kernel.org>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Eugenio Pérez <eperezma@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Jerrin Shaji George <jerrin.shaji-george@broadcom.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: SeongJae Park <sj@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
David Hildenbrand (Red Hat) 2026-01-20 00:01:24 +01:00 committed by Andrew Morton
parent 03d6a2f684
commit 631eb22826

View File

@ -28,6 +28,7 @@ static DEFINE_SPINLOCK(balloon_pages_lock);
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);
@ -45,6 +46,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. */