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. ]
Unified · Split
| @@ -744,6 +744,20 @@ void __sched mutex_unlock(struct mutex *lock) · 743 unmodified lines | |||
| 744 | } | 744 | } |
| 745 | EXPORT_SYMBOL(mutex_unlock); | 745 | EXPORT_SYMBOL(mutex_unlock); |
| 746 | 746 | ||
| 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 | |||
| 747 | /** | 761 | /** |
| 748 | * ww_mutex_unlock - release the w/w mutex | 762 | * ww_mutex_unlock - release the w/w mutex |
| 749 | * @lock: the mutex to be released | 763 | * @lock: the mutex to be released |
| @@ -757,17 +771,7 @@ EXPORT_SYMBOL(mutex_unlock); · 7 unmodified lines | |||
| 757 | */ | 771 | */ |
| 758 | void __sched ww_mutex_unlock(struct ww_mutex *lock) | 772 | void __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 | } |
| 773 | EXPORT_SYMBOL(ww_mutex_unlock); | 777 | EXPORT_SYMBOL(ww_mutex_unlock); |