Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/page_alloc: remove pcpu_spin_* wrappers

We only ever use pcpu_spin_trylock()/unlock() with struct per_cpu_pages so
refactor the helpers to remove the generic layer.

No functional change intended.

Link: https://lkml.kernel.org/r/20260227-b4-pcp-locking-cleanup-v1-3-f7e22e603447@kernel.org
Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Suggested-by: Matthew Wilcox <willy@infradead.org>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Brendan Jackman <jackmanb@google.com>
Cc: David Hildenbrand (Arm) <david@kernel.org>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Vlastimil Babka and committed by
Andrew Morton
e9c01915 0a2c52a9

+9 -15
+9 -15
mm/page_alloc.c
··· 111 111 #endif 112 112 113 113 /* 114 - * Generic helper to lookup and a per-cpu variable with an embedded spinlock. 115 - * Return value should be used with equivalent unlock helper. 114 + * A helper to lookup and trylock pcp with embedded spinlock. 115 + * The return value should be used with the unlock helper. 116 + * NULL return value means the trylock failed. 116 117 */ 117 - #define pcpu_spin_trylock(type, member, ptr) \ 118 + #ifdef CONFIG_SMP 119 + #define pcp_spin_trylock(ptr) \ 118 120 ({ \ 119 - type *_ret; \ 121 + struct per_cpu_pages *_ret; \ 120 122 pcpu_task_pin(); \ 121 123 _ret = this_cpu_ptr(ptr); \ 122 - if (!spin_trylock(&_ret->member)) { \ 124 + if (!spin_trylock(&_ret->lock)) { \ 123 125 pcpu_task_unpin(); \ 124 126 _ret = NULL; \ 125 127 } \ 126 128 _ret; \ 127 129 }) 128 130 129 - #define pcpu_spin_unlock(member, ptr) \ 131 + #define pcp_spin_unlock(ptr) \ 130 132 ({ \ 131 - spin_unlock(&ptr->member); \ 133 + spin_unlock(&ptr->lock); \ 132 134 pcpu_task_unpin(); \ 133 135 }) 134 - 135 - /* struct per_cpu_pages specific helpers.*/ 136 - #ifdef CONFIG_SMP 137 - #define pcp_spin_trylock(ptr) \ 138 - pcpu_spin_trylock(struct per_cpu_pages, lock, ptr) 139 - 140 - #define pcp_spin_unlock(ptr) \ 141 - pcpu_spin_unlock(lock, ptr) 142 136 143 137 /* 144 138 * On CONFIG_SMP=n the UP implementation of spin_trylock() never fails and thus