linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] locking/mutex: Enable optimistic spinning of lock waiter
@ 2016-02-12 17:32 Waiman Long
  2016-02-12 17:32 ` [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Waiman Long
                   ` (4 more replies)
  0 siblings, 5 replies; 28+ messages in thread
From: Waiman Long @ 2016-02-12 17:32 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Peter Zijlstra, linux-kernel, Linus Torvalds, Ding Tianhong,
	Jason Low, Davidlohr Bueso, Paul E. McKenney, Thomas Gleixner,
	Will Deacon, Tim Chen, Waiman Long

v1->v2:
 - Set task state to running before doing optimistic spinning.
 - Add 2 more patches to handle possible missed wakeups and wasteful
   spinning in try_to_wake_up() function.

This patchset is a variant of PeterZ's "locking/mutex: Avoid spinner
vs waiter starvation" patch. The major difference is that the
waiter-spinner won't enter into the OSQ used by the spinners. Instead,
it will spin directly on the lock in parallel with the queue head
of the OSQ. So there will be a bit more cacheline contention on the
lock cacheline, but that shouldn't cause noticeable impact on system
performance.

This patchset tries to address 2 issues with Peter's patch:

 1) Ding Tianhong still find that hanging task could happen in some cases.
 2) Jason Low found that there was performance regression for some AIM7
    workloads.

By making the waiter-spinner to spin directly on the mutex, it will
increase the chance for the waiter-spinner to get the lock instead
of waiting in the OSQ for its turn.

Patch 1 modifies the mutex_optimistic_spin() function to enable it
to be called by a waiter-spinner that doesn't need to go into the OSQ.

Patch 2 modifies the mutex locking slowpath to make the waiter call
mutex_optimistic_spin() to do spinning after being waken up.

Patch 3 reverses the sequence of setting task state and changing
mutex count to -1 to prevent the possibility of missed wakeup.

Patch 4 modifies the wakeup code to abandon the wakeup operation
while spinning on the on_cpu flag if the task has changed back to a
non-sleeping state.

My own test on a 4-socket E7-4820 v3 system showed a regression of
about 4% in the high_systime workload with Peter's patch which this
new patch effectively eliminates.

Testing on an 8-socket Westmere-EX server, however, has performance
change from -9% to than +140% on the fserver workload of AIM7
depending on how the system was set up.

Waiman Long (4):
  locking/mutex: Add waiter parameter to mutex_optimistic_spin()
  locking/mutex: Enable optimistic spinning of woken task in wait queue
  locking/mutex: Avoid missed wakeup of mutex waiter
  sched/fair: Abort wakeup when task is no longer in a sleeping state

 kernel/locking/mutex.c |  119 ++++++++++++++++++++++++++++++++++--------------
 kernel/sched/core.c    |    9 +++-
 2 files changed, 92 insertions(+), 36 deletions(-)

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2016-03-22  9:59 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-12 17:32 [PATCH v2 0/4] locking/mutex: Enable optimistic spinning of lock waiter Waiman Long
2016-02-12 17:32 ` [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Waiman Long
2016-02-12 20:23   ` Peter Zijlstra
2016-02-12 22:14     ` Davidlohr Bueso
2016-02-13 12:10       ` Peter Zijlstra
2016-02-13 18:14         ` Davidlohr Bueso
2016-02-16  2:15       ` Jason Low
2016-02-16  2:22         ` Jason Low
2016-02-16  8:53           ` Peter Zijlstra
2016-02-17  1:40             ` Waiman Long
2016-02-15 22:06     ` Waiman Long
2016-02-12 20:40   ` Peter Zijlstra
2016-02-15 23:55     ` Waiman Long
2016-02-16  3:00       ` Jason Low
2016-02-16  3:30         ` Waiman Long
2016-02-12 22:02   ` Davidlohr Bueso
2016-02-12 22:09     ` Davidlohr Bueso
2016-02-16  0:03     ` Waiman Long
2016-02-12 17:32 ` [PATCH v2 2/4] locking/mutex: Enable optimistic spinning of woken task in wait queue Waiman Long
2016-02-12 17:32 ` [PATCH v2 3/4] locking/mutex: Avoid missed wakeup of mutex waiter Waiman Long
2016-02-12 17:32 ` [PATCH v2 4/4] sched/fair: Abort wakeup when task is no longer in a sleeping state Waiman Long
2016-02-12 20:18   ` Peter Zijlstra
2016-02-12 21:22     ` Waiman Long
2016-02-13 12:09       ` Peter Zijlstra
2016-02-16  8:51 ` [PATCH v2 0/4] locking/mutex: Enable optimistic spinning of lock waiter Peter Zijlstra
2016-02-17  1:39   ` Waiman Long
2016-03-22  3:19   ` Waiman Long
2016-03-22  9:59     ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).