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


Groups > linux.kernel > #1465980

Re: [PATCH v4] locking/mutex: Prevent lock starvation when spinning is disabled

From Jason Low <jason.low2@hpe.com>
Newsgroups linux.kernel
Subject Re: [PATCH v4] locking/mutex: Prevent lock starvation when spinning is disabled
Date 2016-08-19 06:30 +0200
Message-ID <s7JBn-QG-1@gated-at.bofh.it> (permalink)
References <s7HpU-7RC-31@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

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


Thread

[PATCH v4] locking/mutex: Prevent lock starvation when spinning is  disabled Jason Low <jason.low2@hpe.com> - 2016-08-19 04:10 +0200
  Re: [PATCH v4] locking/mutex: Prevent lock starvation when spinning  is disabled Jason Low <jason.low2@hpe.com> - 2016-08-19 06:30 +0200
    Re: [PATCH v4] locking/mutex: Prevent lock starvation when spinning  is disabled Peter Zijlstra <peterz@infradead.org> - 2016-08-19 14:20 +0200
  Re: [PATCH v4] locking/mutex: Prevent lock starvation when spinning  is disabled Peter Zijlstra <peterz@infradead.org> - 2016-08-19 21:40 +0200
    Re: [PATCH v4] locking/mutex: Prevent lock starvation when spinning  is disabled Linus Torvalds <torvalds@linux-foundation.org> - 2016-08-19 21:50 +0200
      Re: [PATCH v4] locking/mutex: Prevent lock starvation when spinning  is disabled Peter Zijlstra <peterz@infradead.org> - 2016-08-23 14:50 +0200

csiph-web