diff options
author | Peter Zijlstra (Intel) <peterz@infradead.org> | 2021-08-17 17:19:04 +0300 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2021-08-17 20:04:44 +0300 |
commit | aaa77de10b7c86fa779b2108802fa9e785fbe2e9 (patch) | |
tree | 416842266fe77db606c1d9e48a1d79480fc077d5 /kernel/locking/mutex.c | |
parent | c0afb0ffc06e6b4e492a3b711f1fb32074f9949c (diff) | |
download | linux-aaa77de10b7c86fa779b2108802fa9e785fbe2e9.tar.xz |
locking/ww_mutex: Split up ww_mutex_unlock()
Split the ww related part out into a helper function so it can be reused
for a rtmutex based ww_mutex implementation.
[ mingo: Fixed bisection failure. ]
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.340166556@linutronix.de
Diffstat (limited to 'kernel/locking/mutex.c')
-rw-r--r-- | kernel/locking/mutex.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c index 6cb27c51a6e0..070f6f1119cd 100644 --- a/kernel/locking/mutex.c +++ b/kernel/locking/mutex.c @@ -744,6 +744,20 @@ void __sched mutex_unlock(struct mutex *lock) } EXPORT_SYMBOL(mutex_unlock); +static void __ww_mutex_unlock(struct ww_mutex *lock) +{ + /* + * The unlocking fastpath is the 0->1 transition from 'locked' + * into 'unlocked' state: + */ + if (lock->ctx) { + MUTEX_WARN_ON(!lock->ctx->acquired); + if (lock->ctx->acquired > 0) + lock->ctx->acquired--; + lock->ctx = NULL; + } +} + /** * ww_mutex_unlock - release the w/w mutex * @lock: the mutex to be released @@ -757,17 +771,7 @@ EXPORT_SYMBOL(mutex_unlock); */ void __sched ww_mutex_unlock(struct ww_mutex *lock) { - /* - * The unlocking fastpath is the 0->1 transition from 'locked' - * into 'unlocked' state: - */ - if (lock->ctx) { - MUTEX_WARN_ON(!lock->ctx->acquired); - if (lock->ctx->acquired > 0) - lock->ctx->acquired--; - lock->ctx = NULL; - } - + __ww_mutex_unlock(lock); mutex_unlock(&lock->base); } EXPORT_SYMBOL(ww_mutex_unlock); |