@@ -349,9 +349,9 @@ static __always_inline void ww_mutex_lock_acquired(struct ww
* Look out! "owner" is an entirely speculative pointer
* access and not reliable.
*/
-static noinline
-bool mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner,
- bool use_ww_ctx, struct ww_acquire_ctx *ww_ctx)
+static __always_inline
+bool __mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner,
+ const bool use_ww_ctx, struct ww_acquire_ctx *ww_ctx)
{
bool ret = true;
@@ -403,6 +403,19 @@ bool mutex_spin_on_owner(struct mutex *lock, struct task_st
return ret;
}
+static noinline
+bool mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner)
+{
+ return __mutex_spin_on_owner(lock, owner, false, NULL);
+}
+
+static noinline
+bool ww_mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner,
+ struct ww_acquire_ctx *ww_ctx)
+{
+ return __mutex_spin_on_owner(lock, owner, true, ww_ctx);
+}
+
/*
* Initial check for entering the mutex spinning loop
*/
@@ -489,13 +502,17 @@ static bool mutex_optimistic_spin(struct mutex *lock,
*/
owner = __mutex_owner(lock);
if (owner) {
+ bool spin_ok;
+
if (waiter && owner == task) {
smp_mb(); /* ACQUIRE */
break;
}
- if (!mutex_spin_on_owner(lock, owner, use_ww_ctx,
- ww_ctx))
+ spin_ok = use_ww_ctx
+ ? ww_mutex_spin_on_owner(lock, owner, ww_ctx)
+ : mutex_spin_on_owner(lock, owner);
+ if (!spin_ok)
goto fail_unlock;
}