kernel - Carefully refactor contended tokens and spinlocks
commitcc705b823a33a247956d2a54a4e929a0ca2936d9
authorMatthew Dillon <dillon@apollo.backplane.com>
Mon, 23 Apr 2018 01:56:14 +0000 (22 18:56 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Mon, 23 Apr 2018 02:31:28 +0000 (22 19:31 -0700)
treeb85d78dc458dd27c8a7e8803abff5ac7111246a7
parentf373576fba9db397f08b54bd704a8f42b73b1684
kernel - Carefully refactor contended tokens and spinlocks

* Carefully put the exponential backoff back in for spinlocks, and
  implement for tokens.  Only applicable to exclusive locks, capped
  via sysctl (mjg).  Tested on dual-socket xeon.

* Exclusive priority for shared locks reduces the shared/exclusive
  starvation that can occur when exclusive locks use exponential
  backoff.

* Exponential backoff significantly improves performance for
  heavily contended exclusive locks by allowing some degree of burst
  operation.

* Implement TSC windowing for shared locks (and a little for
  exclusive locks too).  This prevents heavily contended exclusive
  locks from completely starving shared locks by using windowing
  to disable the exclusive-priority mechanic for shared locks.

  This allows a few contending shared locks to compete on equal
  ground with exclusive locks.

Suggested-by: mjg
sys/kern/kern_spinlock.c
sys/kern/lwkt_token.c