]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
locking/mutex: Remove the list_head from struct mutex
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 5 Mar 2026 19:55:43 +0000 (19:55 +0000)
committerPeter Zijlstra <peterz@infradead.org>
Sun, 8 Mar 2026 10:06:52 +0000 (11:06 +0100)
commit25500ba7e77ce9d3d9b5a1929d41a2ee2e23f6fe
treee288e1e28cc98e4052ac617300be5b86f47f082c
parentb9bdd4b6840454ef87f61b6506c9635c57a81650
locking/mutex: Remove the list_head from struct mutex

Instead of embedding a list_head in struct mutex, 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, 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 mutex like struct file.

Some of the debug checks have to be deleted because there's no equivalent
to checking them in the new scheme (eg an empty waiter->list now means
that it is the only waiter, not that the waiter is no longer on the list).

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-4-willy@infradead.org
include/linux/mutex.h
include/linux/mutex_types.h
kernel/locking/mutex-debug.c
kernel/locking/mutex.c
kernel/locking/ww_mutex.h