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

From: Waiman Long
Date: Fri Jan 22 2016 - 08:42:00 EST


On 01/22/2016 03:54 AM, Peter Zijlstra wrote:
On Thu, Jan 21, 2016 at 06:02:34PM -0500, Waiman Long wrote:
This patch attempts to fix this live-lock condition by enabling the
a woken task in the wait list to enter optimistic spinning loop itself
with precedence over the ones in the OSQ. This should prevent the
live-lock
condition from happening.

So I think having the top waiter going back in to contend on the OSQ is
an excellent idea, but I'm not sure the wlh_spinning thing is important.

Yes, that is optional. I put it there just to make it is more likely for the waiter spinner to get the lock. Without that, the chance will be 50/50 on average. I can certainly take that out.

The OSQ itself is FIFO fair, and the waiters retain the wait_list
position. So having the top wait_list entry contending on the OSQ
ensures we cannot starve (I think).

Also, as Davidlohr said, we cannot copy/paste this much code.

As I said in the previous mail, I do intend to refactor it before sending out the official patch.

Cheers,
Longman