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

Showing the changes to kernel/locking (1 of 1 file). Show all

Unified · Split

kernel/locking/mutex.c+15−11
@@ -744,6 +744,20 @@ void __sched mutex_unlock(struct mutex *lock) · 743 unmodified lines
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); · 7 unmodified lines
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);