[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1471579876.4991.51.camel@j-VirtualBox>
Date: Thu, 18 Aug 2016 21:11:16 -0700
From: Jason Low <jason.low2@....com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: jason.low2@....com, Linus Torvalds <torvalds@...ux-foundation.org>,
Ding Tianhong <dingtianhong@...wei.com>,
Thomas Gleixner <tglx@...utronix.de>,
Will Deacon <Will.Deacon@....com>,
Ingo Molnar <mingo@...hat.com>, imre.deak@...el.com,
linux-kernel@...r.kernel.org, Waiman Long <Waiman.Long@....com>,
Davidlohr Bueso <dave@...olabs.net>,
Tim Chen <tim.c.chen@...ux.intel.com>, terry.rudd@....com,
"Paul E. McKenney" <paulmck@...ibm.com>, jason.low2@...com
Subject: Re: [PATCH v4] locking/mutex: Prevent lock starvation when spinning
is disabled
On Thu, 2016-08-18 at 17:39 -0700, Jason Low wrote:
> Imre reported an issue where threads are getting starved when trying
> to acquire a mutex. Threads acquiring a mutex can get arbitrarily delayed
> sleeping on a mutex because other threads can continually steal the lock
> in the fastpath and/or through optimistic spinning.
>
> Waiman has developed patches that allow waiters to return to optimistic
> spinning, thus reducing the probability that starvation occurs. However,
> Imre still sees this starvation problem in the workloads when optimistic
> spinning is disabled.
>
> This patch adds an additional boolean to the mutex that gets used in
> the CONFIG_SMP && !CONFIG_MUTEX_SPIN_ON_OWNER cases. The flag signifies
> whether or not other threads need to yield to a waiter and gets set
> when a waiter spends too much time waiting for the mutex. The threshold
> is currently set to 16 wakeups, and once the wakeup threshold is exceeded,
> other threads must yield to the top waiter. The flag gets cleared
> immediately after the top waiter acquires the mutex.
>
> This prevents waiters from getting starved without sacrificing much
> much performance, as lock stealing is still allowed and only
> temporarily disabled when it is detected that a waiter has been waiting
> for too long.
Changes from v3 (in peterz locking/core) -> v4:
1. Fixed patch title. It should be "Prevent lock starvation when spinning is
disabled" instead of "when spinning is enabled".
2. Call clear_yield_to_waiter() when a top waiter exits in the 'err' case.
3. Only clear yield_to_waiter if the thread is the top waiter and not if it
is a non-top waiter that received a signal.
Powered by blists - more mailing lists