]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mm: use zone lock guard in free_pcppages_bulk()
authorDmitry Ilvokhin <d@ilvokhin.com>
Wed, 29 Apr 2026 12:02:12 +0000 (12:02 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 29 May 2026 04:05:06 +0000 (21:05 -0700)
Use spinlock_irqsave zone lock guard in free_pcppages_bulk() to replace
the explicit lock/unlock pattern with automatic scope-based cleanup.

Link: https://lore.kernel.org/aafc2d660057a91eb40417f8ff4645b0a8c525e2.1777462630.git.d@ilvokhin.com
Signed-off-by: Dmitry Ilvokhin <d@ilvokhin.com>
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Brendan Jackman <jackmanb@google.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/page_alloc.c

index 49711916703eaadc93eb26091eb69aaab1059d09..8835064aaa8c0f3b66e086c83d9669af15bc3e4e 100644 (file)
@@ -1469,7 +1469,6 @@ static void free_pcppages_bulk(struct zone *zone, int count,
                                        struct per_cpu_pages *pcp,
                                        int pindex)
 {
-       unsigned long flags;
        unsigned int order;
        struct page *page;
 
@@ -1482,7 +1481,7 @@ static void free_pcppages_bulk(struct zone *zone, int count,
        /* Ensure requested pindex is drained first. */
        pindex = pindex - 1;
 
-       spin_lock_irqsave(&zone->lock, flags);
+       guard(spinlock_irqsave)(&zone->lock);
 
        while (count > 0) {
                struct list_head *list;
@@ -1514,8 +1513,6 @@ static void free_pcppages_bulk(struct zone *zone, int count,
                        trace_mm_page_pcpu_drain(page, order, mt);
                } while (count > 0 && !list_empty(list));
        }
-
-       spin_unlock_irqrestore(&zone->lock, flags);
 }
 
 /* Split a multi-block free page into its individual pageblocks. */