Skip to content

Commit aaa77de

Browse files
Peter Zijlstra (Intel)ingomolnar
authored andcommitted
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
1 parent c0afb0f commit aaa77de

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

‎kernel/locking/mutex.c‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,20 @@ void __sched mutex_unlock(struct mutex *lock)
744744
}
745745
EXPORT_SYMBOL(mutex_unlock);
746746

747+
static void __ww_mutex_unlock(struct ww_mutex *lock)
748+
{
749+
/*
750+
* The unlocking fastpath is the 0->1 transition from 'locked'
751+
* into 'unlocked' state:
752+
*/
753+
if (lock->ctx) {
754+
MUTEX_WARN_ON(!lock->ctx->acquired);
755+
if (lock->ctx->acquired > 0)
756+
lock->ctx->acquired--;
757+
lock->ctx = NULL;
758+
}
759+
}
760+
747761
/**
748762
* ww_mutex_unlock - release the w/w mutex
749763
* @lock: the mutex to be released
@@ -757,17 +771,7 @@ EXPORT_SYMBOL(mutex_unlock);
757771
*/
758772
void __sched ww_mutex_unlock(struct ww_mutex *lock)
759773
{
760-
/*
761-
* The unlocking fastpath is the 0->1 transition from 'locked'
762-
* into 'unlocked' state:
763-
*/
764-
if (lock->ctx) {
765-
MUTEX_WARN_ON(!lock->ctx->acquired);
766-
if (lock->ctx->acquired > 0)
767-
lock->ctx->acquired--;
768-
lock->ctx = NULL;
769-
}
770-
774+
__ww_mutex_unlock(lock);
771775
mutex_unlock(&lock->base);
772776
}
773777
EXPORT_SYMBOL(ww_mutex_unlock);

0 commit comments

Comments
 (0)