On Wed, 2014-02-05 at 16:44 -0500, Waiman Long wrote:On 01/29/2014 06:51 AM, Peter Zijlstra wrote:So one of the concerns I had with the approach of skipping nodes wasOn Tue, Jan 28, 2014 at 02:51:35PM -0800, Jason Low wrote:I have an alternative way of breaking out of the MCS lock waiting queueOK, please have a very careful look at the below. It survived a bootBut urgh, nasty problem. Lemme ponder this a bit.
with udev -- which usually stresses mutex contention enough to explode
(in fact it did a few time when I got the contention/cancel path wrong),
however I have not ran anything else on it.
The below is an MCS variant that allows relatively cheap unqueueing. But
its somewhat tricky and I might have gotten a case wrong, esp. the
double concurrent cancel case got my head hurting (I didn't attempt a
tripple unqueue).
Applies to tip/master but does generate a few (harmless) compile
warnings because I didn't fully clean up the mcs_spinlock vs m_spinlock
thing.
Also, there's a comment in the slowpath that bears consideration.
when need_resched() is set. I overload the locked flag to indicate a
skipped node if negative. I run the patch through the AIM7 high-systime
workload on a 4-socket server and it seemed to run fine.
Please check the following POC patch to see if you have any comment.
that, under heavy contention, we potentially could cause optimistic
spinning to be disabled on CPUs for a while since the nodes can't be
used until they have been released. One advantage of the unqueuing
method would be that nodes are usable after the spinners exit the MCS
queue and go to sleep.
Jason