[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <56B1A7D8.4050205@huawei.com>
Date: Wed, 3 Feb 2016 15:10:16 +0800
From: Ding Tianhong <dingtianhong@...wei.com>
To: Davidlohr Bueso <dave@...olabs.net>,
Peter Zijlstra <peterz@...radead.org>
CC: Waiman Long <waiman.long@....com>, Jason Low <jason.low2@...com>,
"Ingo Molnar" <mingo@...hat.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
"Paul E. McKenney" <paulmck@...ibm.com>,
Thomas Gleixner <tglx@...utronix.de>,
Will Deacon <Will.Deacon@....com>,
"Tim Chen" <tim.c.chen@...ux.intel.com>,
Waiman Long <Waiman.Long@...com>
Subject: Re: [PATCH] locking/mutex: Avoid spinner vs waiter starvation
On 2016/2/3 5:19, Davidlohr Bueso wrote:
> On Mon, 01 Feb 2016, Peter Zijlstra wrote:
>
>> Subject: locking/mutex: Avoid spinner vs waiter starvation
>> From: Peter Zijlstra <peterz@...radead.org>
>> Date: Fri, 22 Jan 2016 12:06:53 +0100
>>
>> Ding Tianhong reported that under his load the optimistic spinners
>> would totally starve a task that ended up on the wait list.
>>
>> Fix this by ensuring the top waiter also partakes in the optimistic
>> spin queue.
>>
>> There are a few subtle differences between the assumed state of
>> regular optimistic spinners and those already on the wait list, which
>> result in the @acquired complication of the acquire path.
>>
>> Most notable are:
>>
>> - waiters are on the wait list and need to be taken off
>> - mutex_optimistic_spin() sets the lock->count to 0 on acquire
>> even though there might be more tasks on the wait list.
>
> Right, the main impact I see with these complications are that the
> window of when a waiter takes the lock via spinning and then acquires
> the wait_lock to remove itself from the list, will allow an unlock
> thread to set the lock as available in the fastpath which could in
> turn allow a third thread the steal the lock. With high contention,
> this window will be come obviously larger as we contend for the
> wait_lock.
>
> CPU-0 CPU-1 CPU-3
> __mutex_lock_common mutex_optimistic_spin
> (->count now 0)
> __mutex_fastpath_unlock
> (->count now 1) __mutex_fastpath_lock
> (stolen)
>
> spin_lock_mutex(&lock->wait_lock, flags);
>
> But we've always been bad when it comes to counter and waiters.
>
Agree, but this patch is going to help the waiter in the wait list to get the lock, your scene probability looks more
too low and I don't think it is a problem.
Thanks
Ding
> Thanks,
> Davidlohr
>
> .
>
Powered by blists - more mailing lists