Re: [RFC PATCH 07/11] sched: Add proxy execution
From: Peter Zijlstra
Date: Sat Oct 15 2022 - 11:10:16 EST
On Mon, Oct 03, 2022 at 09:44:57PM +0000, Connor O'Brien wrote:
> @@ -703,15 +707,28 @@ __mutex_lock_common(struct mutex *lock, unsigned int state, unsigned int subclas
> break;
>
> if (first) {
> + bool acquired;
> +
> + /*
> + * XXX connoro: mutex_optimistic_spin() can schedule, so
I'm thinking it might be better to remove that schedule point for
PROXY_EXEC instead of doing this.
Getting preempted right after acquiring a lock is less of a problem with
PE on than it is without it.
> + * we need to release these locks before calling it.
> + * This needs refactoring though b/c currently we take
> + * the locks earlier than necessary when proxy exec is
> + * disabled and release them unnecessarily when it's
> + * enabled. At a minimum, need to verify that releasing
> + * blocked_lock here doesn't create any races.
> + */
> + raw_spin_unlock(¤t->blocked_lock);
> + raw_spin_unlock_irqrestore(&lock->wait_lock, flags);
> trace_contention_begin(lock, LCB_F_MUTEX | LCB_F_SPIN);
> - if (mutex_optimistic_spin(lock, ww_ctx, &waiter))
> + acquired = mutex_optimistic_spin(lock, ww_ctx, &waiter);
> + raw_spin_lock_irqsave(&lock->wait_lock, flags);
> + raw_spin_lock(¤t->blocked_lock);
> + if (acquired)
> break;
> trace_contention_begin(lock, LCB_F_MUTEX);
> }