Re: [PATCH RFC] locking/mutexes: don't spin on owner when wait list is not NULL.

From: Davidlohr Bueso
Date: Fri Jan 22 2016 - 11:46:46 EST

On Fri, 22 Jan 2016, Waiman Long wrote:

The patch that I sent out is just a proof of concept to make sure
that it can fix that particular case. I do plan to refactor it if I
decide to go ahead with an official one. Unlike the OSQ, there can be
no more than one waiter spinner as the wakeup function is directed to
only the first task in the wait list and the spinning won't happen
until the task is first woken up. In the worst case scenario, there
are only 2 spinners spinning on the lock and the owner field, one
from OSQ and one from the wait list. That shouldn't put too much
cacheline contention traffic to the system.

Similarly, I guess we should also wakeup the next waiter in line after
releasing the wait_lock via wake_q. This would allow the woken waiter a
slightly better chance of finding the wait_lock free when continuing to
take the mutex.