Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1314975

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

From Waiman Long <waiman.long@hpe.com>
Newsgroups linux.kernel
Subject Re: [PATCH RFC] locking/mutexes: don't spin on owner when wait list is not NULL.
Date 2016-01-22 14:40 +0100
Message-ID <qTK6t-4Fl-1@gated-at.bofh.it> (permalink)
References <qTjSG-3ll-15@gated-at.bofh.it> <qTwwA-3Hx-59@gated-at.bofh.it> <qTDeG-8sR-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 01/22/2016 01:09 AM, Davidlohr Bueso wrote:
> On Thu, 21 Jan 2016, Waiman Long wrote:
>
>> On 01/21/2016 04:29 AM, Ding Tianhong wrote:
>
>>> I got the vmcore and found that the ifconfig is already in the 
>>> wait_list of the
>>> rtnl_lock for 120 second, but my process could get and release the 
>>> rtnl_lock
>>> normally several times in one second, so it means that my process 
>>> jump the
>>> queue and the ifconfig couldn't get the rtnl all the time, I check 
>>> the mutex lock
>>> slow path and found that the mutex may spin on owner ignore whether 
>>> the  wait list
>>> is empty, it will cause the task in the wait list always be cut in 
>>> line, so add
>>> test for wait list in the mutex_can_spin_on_owner and avoid this 
>>> problem.
>
> So this has been somewhat always known, at least in theory, until now. 
> It's the cost
> of spinning without going through the wait-queue, unlike other locks.
>
>>> [...]
>
>> From: Waiman Long <Waiman.Long@hpe.com>
>> Date: Thu, 21 Jan 2016 17:53:14 -0500
>> Subject: [PATCH] locking/mutex: Enable optimistic spinning of woken 
>> task in wait list
>>
>> Ding Tianhong reported a live-lock situation where a constant stream
>> of incoming optimistic spinners blocked a task in the wait list from
>> getting the mutex.
>>
>> 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.
>
> And one of the reasons why we never bothered 'fixing' things was the 
> additional
> branching out in the slowpath (and lack of real issue, although this 
> one being so
> damn pathological). I fear that your approach is one of those 
> scenarios where the
> code ends up being bloated, albeit most of it is actually duplicated 
> and can be
> refactored *sigh*. So now we'd spin, then sleep, then try spinning 
> then sleep again...
> phew. Not to mention the performance implications, ie loosing the 
> benefits of osq
> over waiter spinning in scenarios that would otherwise have more osq 
> spinners as
> opposed to waiter spinners, or in setups where it is actually best to 
> block instead
> of spinning.

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.

Cheers,
Longman

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH RFC] locking/mutexes: don't spin on owner when wait list is  not NULL. Ding Tianhong <dingtianhong@huawei.com> - 2016-01-21 10:40 +0100
  Re: [PATCH RFC] locking/mutexes: don't spin on owner when wait list  is not NULL. Tim Chen <tim.c.chen@linux.intel.com> - 2016-01-21 22:30 +0100
    Re: [PATCH RFC] locking/mutexes: don't spin on owner when wait list  is not NULL. Davidlohr Bueso <dave@stgolabs.net> - 2016-01-22 03:50 +0100
      Re: [PATCH RFC] locking/mutexes: don't spin on owner when wait list  is not NULL. "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-01-22 04:20 +0100
    Re: [PATCH RFC] locking/mutexes: don't spin on owner when wait list  is not NULL. "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-01-22 03:50 +0100
  Re: [PATCH RFC] locking/mutexes: don't spin on owner when wait list  is not NULL. Waiman Long <waiman.long@hpe.com> - 2016-01-22 00:10 +0100
    Re: [PATCH RFC] locking/mutexes: don't spin on owner when wait list  is not NULL. Davidlohr Bueso <dave@stgolabs.net> - 2016-01-22 07:20 +0100
      Re: [PATCH RFC] locking/mutexes: don't spin on owner when wait list  is not NULL. Waiman Long <waiman.long@hpe.com> - 2016-01-22 14:40 +0100
        Re: [PATCH RFC] locking/mutexes: don't spin on owner when wait list  is not NULL. Davidlohr Bueso <dave@stgolabs.net> - 2016-01-22 17:50 +0100
          [PATCH] locking/mutex: Allow next waiter lockless wakeup Davidlohr Bueso <dave@stgolabs.net> - 2016-01-25 03:30 +0100
            Re: [PATCH] locking/mutex: Allow next waiter lockless wakeup Waiman Long <waiman.long@hpe.com> - 2016-01-26 00:10 +0100
    Re: [PATCH RFC] locking/mutexes: don't spin on owner when wait list  is not NULL. Peter Zijlstra <peterz@infradead.org> - 2016-01-22 10:00 +0100
      Re: [PATCH RFC] locking/mutexes: don't spin on owner when wait list  is not NULL. Jason Low <jason.low2@hp.com> - 2016-01-22 11:30 +0100
        Re: [PATCH RFC] locking/mutexes: don't spin on owner when wait list  is not NULL. Peter Zijlstra <peterz@infradead.org> - 2016-01-22 12:00 +0100
          Re: [PATCH RFC] locking/mutexes: don't spin on owner when wait list  is not NULL. Peter Zijlstra <peterz@infradead.org> - 2016-01-22 12:00 +0100
            Re: [PATCH RFC] locking/mutexes: don't spin on owner when wait list  is not NULL. Peter Zijlstra <peterz@infradead.org> - 2016-01-22 12:10 +0100
              Re: [PATCH RFC] locking/mutexes: don't spin on owner when wait list  is not NULL. Waiman Long <waiman.long@hpe.com> - 2016-01-22 15:10 +0100
                Re: [PATCH RFC] locking/mutexes: don't spin on owner when wait list  is not NULL. Ding Tianhong <dingtianhong@huawei.com> - 2016-01-24 09:10 +0100
      Re: [PATCH RFC] locking/mutexes: don't spin on owner when wait list  is not NULL. Waiman Long <waiman.long@hpe.com> - 2016-01-22 14:50 +0100

csiph-web