git: kernel - Carefully refactor contended tokens and spinlocks

Matthew Dillon dillon at
Sun Apr 22 19:31:33 PDT 2018

commit cc705b823a33a247956d2a54a4e929a0ca2936d9
Author: Matthew Dillon <dillon at>
Date:   Sun Apr 22 18:56:14 2018 -0700

    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
    * Exponential backoff significantly improves performance for
      heavily contended exclusive locks by allowing some degree of burst
    * 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

Summary of changes:
 sys/kern/kern_spinlock.c | 122 +++++++++++++++++++++++++----------------------
 sys/kern/lwkt_token.c    |  70 +++++++++++++++++++--------
 2 files changed, 117 insertions(+), 75 deletions(-)

DragonFly BSD source repository

More information about the Commits mailing list