]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
vmw_balloon: stop using the balloon_dev_info lock
authorDavid Hildenbrand (Red Hat) <david@kernel.org>
Mon, 19 Jan 2026 23:01:15 +0000 (00:01 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 31 Jan 2026 22:22:32 +0000 (14:22 -0800)
Let's not piggy-back on the existing lock and use a separate lock for the
huge page list.  Now that we use a separate lock, there is no need to
disable interrupts, so use the non-irqsave variants.  We only required the
irqsave variants because of the balloon device lock.

This is a preparation for changing the locking used to protect
balloon_dev_info.

While at it, talk about "page migration" instead of "page compaction".
We'll change that in core code soon as well.

Link: https://lkml.kernel.org/r/20260119230133.3551867-8-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>
drivers/misc/vmw_balloon.c

index 52b8c0f1eead79dcdbe0e4e6138c320f12985dc4..53e9335b6718cc62e2f2227b1a9be5d686553a84 100644 (file)
@@ -354,10 +354,15 @@ struct vmballoon {
        /**
         * @huge_pages - list of the inflated 2MB pages.
         *
-        * Protected by @b_dev_info.pages_lock .
+        * Protected by @huge_pages_lock.
         */
        struct list_head huge_pages;
 
+       /**
+        * @huge_pages_lock: lock for the list of inflated 2MB pages.
+        */
+       spinlock_t huge_pages_lock;
+
        /**
         * @vmci_doorbell.
         *
@@ -987,7 +992,6 @@ static void vmballoon_enqueue_page_list(struct vmballoon *b,
                                        unsigned int *n_pages,
                                        enum vmballoon_page_size_type page_size)
 {
-       unsigned long flags;
        struct page *page;
 
        if (page_size == VMW_BALLOON_4K_PAGE) {
@@ -995,9 +999,9 @@ static void vmballoon_enqueue_page_list(struct vmballoon *b,
        } else {
                /*
                 * Keep the huge pages in a local list which is not available
-                * for the balloon compaction mechanism.
+                * for the balloon page migration.
                 */
-               spin_lock_irqsave(&b->b_dev_info.pages_lock, flags);
+               spin_lock(&b->huge_pages_lock);
 
                list_for_each_entry(page, pages, lru) {
                        vmballoon_mark_page_offline(page, VMW_BALLOON_2M_PAGE);
@@ -1006,7 +1010,7 @@ static void vmballoon_enqueue_page_list(struct vmballoon *b,
                list_splice_init(pages, &b->huge_pages);
                __count_vm_events(BALLOON_INFLATE, *n_pages *
                                  vmballoon_page_in_frames(VMW_BALLOON_2M_PAGE));
-               spin_unlock_irqrestore(&b->b_dev_info.pages_lock, flags);
+               spin_unlock(&b->huge_pages_lock);
        }
 
        *n_pages = 0;
@@ -1033,7 +1037,6 @@ static void vmballoon_dequeue_page_list(struct vmballoon *b,
 {
        struct page *page, *tmp;
        unsigned int i = 0;
-       unsigned long flags;
 
        /* In the case of 4k pages, use the compaction infrastructure */
        if (page_size == VMW_BALLOON_4K_PAGE) {
@@ -1043,7 +1046,7 @@ static void vmballoon_dequeue_page_list(struct vmballoon *b,
        }
 
        /* 2MB pages */
-       spin_lock_irqsave(&b->b_dev_info.pages_lock, flags);
+       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);
 
@@ -1054,7 +1057,7 @@ static void vmballoon_dequeue_page_list(struct vmballoon *b,
 
        __count_vm_events(BALLOON_DEFLATE,
                          i * vmballoon_page_in_frames(VMW_BALLOON_2M_PAGE));
-       spin_unlock_irqrestore(&b->b_dev_info.pages_lock, flags);
+       spin_unlock(&b->huge_pages_lock);
        *n_pages = i;
 }
 
@@ -1828,6 +1831,7 @@ static int __init vmballoon_init(void)
                balloon.b_dev_info.migratepage = vmballoon_migratepage;
 
        INIT_LIST_HEAD(&balloon.huge_pages);
+       spin_lock_init(&balloon.huge_pages_lock);
        spin_lock_init(&balloon.comm_lock);
        init_rwsem(&balloon.conf_sem);
        balloon.vmci_doorbell = VMCI_INVALID_HANDLE;