History

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. ]

Peter Zijlstra (Intel) committed 5 years ago

Commit aaa77de1 parent c0afb0f1 file · +15 −11Browse files

Unified · Split

kernel/locking/mutex.c+15−11
@@ -744,6 +744,20 @@ void __sched mutex_unlock(struct mutex *lock) · 743 unmodified lines
744}744}
745EXPORT_SYMBOL(mutex_unlock);745EXPORT_SYMBOL(mutex_unlock);
746 746
747static 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
747/**761/**
748 * ww_mutex_unlock - release the w/w mutex762 * ww_mutex_unlock - release the w/w mutex
749 * @lock: the mutex to be released763 * @lock: the mutex to be released
@@ -757,17 +771,7 @@ EXPORT_SYMBOL(mutex_unlock); · 7 unmodified lines
757 */771 */
758void __sched ww_mutex_unlock(struct ww_mutex *lock)772void __sched ww_mutex_unlock(struct ww_mutex *lock)
759{773{
760 /*774 __ww_mutex_unlock(lock);
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
771 mutex_unlock(&lock->base);775 mutex_unlock(&lock->base);
772}776}
773EXPORT_SYMBOL(ww_mutex_unlock);777EXPORT_SYMBOL(ww_mutex_unlock);