Skip to content

Commit bdb1891

Browse files
Peter Zijlstraingomolnar
authored andcommitted
locking/ww_mutex: Abstract out mutex types
Some ww_mutex helper functions use pointers for the underlying mutex and mutex_waiter. The upcoming rtmutex based implementation needs to share these functions. Add and use defines for the types and replace the direct types in the affected functions. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20210815211304.678720245@linutronix.de
1 parent 9934ccc commit bdb1891

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

‎kernel/locking/ww_mutex.h‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/* SPDX-License-Identifier: GPL-2.0-only */
22

3+
#define MUTEX mutex
4+
#define MUTEX_WAITER mutex_waiter
5+
36
static inline struct mutex_waiter *
47
__ww_waiter_first(struct mutex *lock)
58
{
@@ -143,7 +146,7 @@ __ww_ctx_stamp_after(struct ww_acquire_ctx *a, struct ww_acquire_ctx *b)
143146
* __ww_mutex_check_kill() wake any but the earliest context.
144147
*/
145148
static bool
146-
__ww_mutex_die(struct mutex *lock, struct mutex_waiter *waiter,
149+
__ww_mutex_die(struct MUTEX *lock, struct MUTEX_WAITER *waiter,
147150
struct ww_acquire_ctx *ww_ctx)
148151
{
149152
if (!ww_ctx->is_wait_die)
@@ -165,7 +168,7 @@ __ww_mutex_die(struct mutex *lock, struct mutex_waiter *waiter,
165168
* the lock holders. Even if multiple waiters may wound the lock holder,
166169
* it's sufficient that only one does.
167170
*/
168-
static bool __ww_mutex_wound(struct mutex *lock,
171+
static bool __ww_mutex_wound(struct MUTEX *lock,
169172
struct ww_acquire_ctx *ww_ctx,
170173
struct ww_acquire_ctx *hold_ctx)
171174
{
@@ -220,9 +223,9 @@ static bool __ww_mutex_wound(struct mutex *lock,
220223
* The current task must not be on the wait list.
221224
*/
222225
static void
223-
__ww_mutex_check_waiters(struct mutex *lock, struct ww_acquire_ctx *ww_ctx)
226+
__ww_mutex_check_waiters(struct MUTEX *lock, struct ww_acquire_ctx *ww_ctx)
224227
{
225-
struct mutex_waiter *cur;
228+
struct MUTEX_WAITER *cur;
226229

227230
lockdep_assert_held(&lock->wait_lock);
228231

@@ -278,7 +281,7 @@ ww_mutex_set_context_fastpath(struct ww_mutex *lock, struct ww_acquire_ctx *ctx)
278281
}
279282

280283
static __always_inline int
281-
__ww_mutex_kill(struct mutex *lock, struct ww_acquire_ctx *ww_ctx)
284+
__ww_mutex_kill(struct MUTEX *lock, struct ww_acquire_ctx *ww_ctx)
282285
{
283286
if (ww_ctx->acquired > 0) {
284287
#ifdef CONFIG_DEBUG_MUTEXES
@@ -306,12 +309,12 @@ __ww_mutex_kill(struct mutex *lock, struct ww_acquire_ctx *ww_ctx)
306309
* look at waiters before us in the wait-list.
307310
*/
308311
static inline int
309-
__ww_mutex_check_kill(struct mutex *lock, struct mutex_waiter *waiter,
312+
__ww_mutex_check_kill(struct MUTEX *lock, struct MUTEX_WAITER *waiter,
310313
struct ww_acquire_ctx *ctx)
311314
{
312315
struct ww_mutex *ww = container_of(lock, struct ww_mutex, base);
313316
struct ww_acquire_ctx *hold_ctx = READ_ONCE(ww->ctx);
314-
struct mutex_waiter *cur;
317+
struct MUTEX_WAITER *cur;
315318

316319
if (ctx->acquired == 0)
317320
return 0;
@@ -354,11 +357,11 @@ __ww_mutex_check_kill(struct mutex *lock, struct mutex_waiter *waiter,
354357
* Wound-Wait ensure we wound the owning context when it is younger.
355358
*/
356359
static inline int
357-
__ww_mutex_add_waiter(struct mutex_waiter *waiter,
358-
struct mutex *lock,
360+
__ww_mutex_add_waiter(struct MUTEX_WAITER *waiter,
361+
struct MUTEX *lock,
359362
struct ww_acquire_ctx *ww_ctx)
360363
{
361-
struct mutex_waiter *cur, *pos = NULL;
364+
struct MUTEX_WAITER *cur, *pos = NULL;
362365
bool is_wait_die;
363366

364367
if (!ww_ctx) {

0 commit comments

Comments
 (0)