diff options
| author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2026-03-05 22:55:42 +0300 |
|---|---|---|
| committer | Peter Zijlstra <peterz@infradead.org> | 2026-03-08 13:06:52 +0300 |
| commit | b9bdd4b6840454ef87f61b6506c9635c57a81650 (patch) | |
| tree | 72739b8a22862bdf1de150c58277635986e7e4bf /include | |
| parent | 1ea4b473504b6dc6a0d21c298519aff2d52433c9 (diff) | |
| download | linux-b9bdd4b6840454ef87f61b6506c9635c57a81650.tar.xz | |
locking/semaphore: Remove the list_head from struct semaphore
Instead of embedding a list_head in struct semaphore, store a pointer to
the first waiter. The list of waiters remains a doubly linked list so
we can efficiently add to the tail of the list and remove from the front
(or middle) of the list.
Some of the list manipulation becomes more complicated, but it's a
reasonable tradeoff on the slow paths to shrink data structures
which embed a semaphore.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260305195545.3707590-3-willy@infradead.org
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/semaphore.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h index 89706157e622..a4c8651ef021 100644 --- a/include/linux/semaphore.h +++ b/include/linux/semaphore.h @@ -15,7 +15,7 @@ struct semaphore { raw_spinlock_t lock; unsigned int count; - struct list_head wait_list; + struct semaphore_waiter *first_waiter; #ifdef CONFIG_DETECT_HUNG_TASK_BLOCKER unsigned long last_holder; @@ -33,7 +33,7 @@ struct semaphore { { \ .lock = __RAW_SPIN_LOCK_UNLOCKED((name).lock), \ .count = n, \ - .wait_list = LIST_HEAD_INIT((name).wait_list) \ + .first_waiter = NULL \ __LAST_HOLDER_SEMAPHORE_INITIALIZER \ } |
