All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH-tip v4 00/10] locking/rwsem: Enable reader optimistic spinning
@ 2016-08-18 21:11 ` Waiman Long
  0 siblings, 0 replies; 76+ messages in thread
From: Waiman Long @ 2016-08-18 21:11 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar
  Cc: linux-kernel, x86, linux-alpha, linux-ia64, linux-s390,
	linux-arch, linux-doc, Davidlohr Bueso, Jason Low, Dave Chinner,
	Jonathan Corbet, Scott J Norton, Douglas Hatch, Waiman Long

v3->v4:
 - Rebased to the latest tip tree due to changes to rwsem-xadd.c.
 - Update the OSQ patch to fix race condition.

v2->v3:
 - Used smp_acquire__after_ctrl_dep() to provide acquire barrier.
 - Added the following new patches:
   1) make rwsem_spin_on_owner() return a tristate value.
   2) reactivate reader spinning when there is a large number of
      favorable writer-on-writer spinnings.
   3) move all the rwsem macros in arch-specific rwsem.h files
      into a common asm-generic/rwsem_types.h file.
   4) add a boot parameter to specify the reader spinning threshold.
 - Updated some of the patches as suggested by PeterZ and adjusted
   some of the reader spinning parameters.

v1->v2:
 - Fixed a 0day build error.
 - Added a new patch 1 to make osq_lock() a proper acquire memory
   barrier.
 - Replaced the explicit enabling of reader spinning by an autotuning
   mechanism that disable reader spinning for those rwsems that may
   not benefit from reader spinning.
 - Remove the last xfs patch as it is no longer necessary.

This patchset enables more aggressive optimistic spinning on
both readers and writers waiting on a writer or reader owned
lock. Spinning on writer is done by looking at the on_cpu flag of the
lock owner. Spinning on readers, on the other hand, is count-based as
there is no easy way to figure out if all the readers are running. The
spinner will stop spinning once the count goes to 0. Because of that,
spinning on readers may hurt performance in some cases.

An autotuning mechanism is used to determine if a rwsem can benefit
from reader optimistic spinning. It will maintain reader spinning as
long as no less than 80% of the spins are successful.

Patch 1 updates the osq_lock() function to make it a proper acquire
memory barrier.

Patch 2 reduces the length of the blocking window after a read locking
attempt where writer lock stealing is disabled because of the active
read lock. It can improve rwsem performance for contended lock. It is
independent of the rest of the patchset.

Patch 3 modifies rwsem_spin_on_owner() to return a tri-state value
that can be used in later patch.

Patch 4 puts in place the autotuning mechanism to check if reader
optimistic spinning should be used or not.

Patch 5 moves down the rwsem_down_read_failed() function for later
patches.

Patch 6 moves the macro definitions in various arch-specific rwsem.h
header files into a commont asm-generic/rwsem_types.h file.

Patch 7 changes RWSEM_WAITING_BIAS to simpify reader trylock code.

Patch 8 enables readers to do optimistic spinning.

Patch 9 allows reactivation of reader spinning when a lot of
writer-on-writer spins are successful.

Patch 10 adds a new boot parameter to change the reader spinning
threshold which can be system specific.

Waiman Long (10):
  locking/osq: Make lock/unlock proper acquire/release barrier
  locking/rwsem: Stop active read lock ASAP
  locking/rwsem: Make rwsem_spin_on_owner() return a tri-state value
  locking/rwsem: Enable count-based spinning on reader
  locking/rwsem: move down rwsem_down_read_failed function
  locking/rwsem: Move common rwsem macros to asm-generic/rwsem_types.h
  locking/rwsem: Change RWSEM_WAITING_BIAS for better disambiguation
  locking/rwsem: Enable spinning readers
  locking/rwsem: Enable reactivation of reader spinning
  locking/rwsem: Add a boot parameter to reader spinning threshold

 Documentation/kernel-parameters.txt |    3 +
 arch/alpha/include/asm/rwsem.h      |   11 +-
 arch/ia64/include/asm/rwsem.h       |    9 +-
 arch/s390/include/asm/rwsem.h       |    9 +-
 arch/x86/include/asm/rwsem.h        |   22 +---
 include/asm-generic/rwsem.h         |   20 +--
 include/asm-generic/rwsem_types.h   |   28 ++++
 include/linux/rwsem.h               |   23 +++-
 kernel/locking/osq_lock.c           |   24 ++-
 kernel/locking/rwsem-xadd.c         |  296 ++++++++++++++++++++++++++---------
 10 files changed, 308 insertions(+), 137 deletions(-)
 create mode 100644 include/asm-generic/rwsem_types.h

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

end of thread, other threads:[~2016-10-16  5:57 UTC | newest]

Thread overview: 76+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-18 21:11 [RFC PATCH-tip v4 00/10] locking/rwsem: Enable reader optimistic spinning Waiman Long
2016-08-18 21:11 ` Waiman Long
2016-08-18 21:11 ` [RFC PATCH-tip v4 01/10] locking/osq: Make lock/unlock proper acquire/release barrier Waiman Long
2016-08-18 21:11   ` Waiman Long
2016-10-04 19:06   ` Davidlohr Bueso
2016-10-04 19:06     ` Davidlohr Bueso
2016-10-04 21:28     ` Jason Low
2016-10-04 21:28       ` Jason Low
2016-10-05 12:19     ` Waiman Long
2016-10-05 12:19       ` Waiman Long
2016-10-05 12:19       ` Waiman Long
2016-10-05 15:11       ` Waiman Long
2016-10-05 15:11         ` Waiman Long
2016-10-05 15:11         ` Waiman Long
2016-10-06  5:47         ` Davidlohr Bueso
2016-10-06  5:47           ` Davidlohr Bueso
2016-10-06 19:30           ` Waiman Long
2016-10-06 19:30             ` Waiman Long
2016-10-06 19:30             ` Waiman Long
2016-10-10  5:39             ` [PATCH] locking/osq: Provide proper lock/unlock and relaxed flavors Davidlohr Bueso
2016-10-10  5:39               ` Davidlohr Bueso
2016-10-06 19:31           ` [RFC PATCH-tip v4 01/10] locking/osq: Make lock/unlock proper acquire/release barrier Jason Low
2016-10-06 19:31             ` Jason Low
2016-10-06 19:31             ` Jason Low
2016-08-18 21:11 ` [RFC PATCH-tip v4 02/10] locking/rwsem: Stop active read lock ASAP Waiman Long
2016-08-18 21:11   ` Waiman Long
2016-10-06 18:17   ` Davidlohr Bueso
2016-10-06 18:17     ` Davidlohr Bueso
2016-10-06 21:47     ` Dave Chinner
2016-10-06 21:47       ` Dave Chinner
2016-10-06 22:51       ` Davidlohr Bueso
2016-10-06 22:51         ` Davidlohr Bueso
2016-10-07 21:45       ` Waiman Long
2016-10-07 21:45         ` Waiman Long
2016-10-07 21:45         ` Waiman Long
2016-10-09 15:17       ` Christoph Hellwig
2016-10-09 15:17         ` Christoph Hellwig
2016-10-10  6:07         ` Dave Chinner
2016-10-10  6:07           ` Dave Chinner
2016-10-10  9:34           ` Christoph Hellwig
2016-10-10  9:34             ` Christoph Hellwig
2016-10-11 21:06             ` Dave Chinner
2016-10-11 21:06               ` Dave Chinner
2016-10-16  5:57               ` Christoph Hellwig
2016-10-16  5:57                 ` Christoph Hellwig
2016-08-18 21:11 ` [RFC PATCH-tip v4 03/10] locking/rwsem: Make rwsem_spin_on_owner() return a tri-state value Waiman Long
2016-08-18 21:11   ` Waiman Long
2016-08-18 21:11 ` [RFC PATCH-tip v4 04/10] locking/rwsem: Enable count-based spinning on reader Waiman Long
2016-08-18 21:11   ` Waiman Long
2016-08-18 21:11 ` [RFC PATCH-tip v4 05/10] locking/rwsem: move down rwsem_down_read_failed function Waiman Long
2016-08-18 21:11   ` Waiman Long
2016-08-18 21:11 ` [RFC PATCH-tip v4 06/10] locking/rwsem: Move common rwsem macros to asm-generic/rwsem_types.h Waiman Long
2016-08-18 21:11   ` Waiman Long
2016-08-18 21:11 ` [RFC PATCH-tip v4 07/10] locking/rwsem: Change RWSEM_WAITING_BIAS for better disambiguation Waiman Long
2016-08-18 21:11   ` Waiman Long
2016-08-19  5:57   ` Wanpeng Li
2016-08-19  5:57     ` Wanpeng Li
2016-08-19 16:21     ` Waiman Long
2016-08-19 16:21       ` Waiman Long
2016-08-19 16:21       ` Waiman Long
2016-08-22  2:15       ` Wanpeng Li
2016-08-22  2:15         ` Wanpeng Li
2016-08-18 21:11 ` [RFC PATCH-tip v4 08/10] locking/rwsem: Enable spinning readers Waiman Long
2016-08-18 21:11   ` Waiman Long
2016-08-18 21:11 ` [RFC PATCH-tip v4 09/10] locking/rwsem: Enable reactivation of reader spinning Waiman Long
2016-08-18 21:11   ` Waiman Long
2016-08-18 21:11 ` [RFC PATCH-tip v4 10/10] locking/rwsem: Add a boot parameter to reader spinning threshold Waiman Long
2016-08-18 21:11   ` Waiman Long
2016-08-24  1:46   ` [lkp] [locking/rwsem] INFO: rcu_preempt detected stalls on CPUs/tasks kernel test robot
2016-08-24  1:46     ` kernel test robot
2016-08-24  1:46     ` [lkp] " kernel test robot
2016-08-24  4:00   ` [RFC PATCH-tip v4 10/10] locking/rwsem: Add a boot parameter to reader spinning threshold Davidlohr Bueso
2016-08-24  4:00     ` Davidlohr Bueso
2016-08-24 18:39     ` Waiman Long
2016-08-24 18:39       ` Waiman Long
2016-08-24 18:39       ` Waiman Long

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.