kernel - Reduce stalls, refactor lwkt_switch() core.
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 10 Jul 2016 21:13:30 +0000 (14:13 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 10 Jul 2016 21:23:06 +0000 (14:23 -0700)
commit5411d8f15e92c1aaa25076860bab3d3caabab347
tree84cc97464d9f3fa125ef6c1c789fb04b3577a68a
parent636b1f094f50dbc9211368af5dfcf07388e135ff
kernel - Reduce stalls, refactor lwkt_switch() core.

* These changes primarily effect programs which have a lot of token
  contention (aka concurrent write VM faults) and exiting programs which
  have very large RSSs (e.g. multiple gigabytes).

* Release proc->p_token around potentially long vmspace destruction ops.
  This avoids stalls in programs like 'ps' and functions like
  fork/exec/wait/exit.

* Refactor lwkt_switch().  This may also fix a bug where we improperly
  called splz_check() after releasing the current thread's tokens.  An
  interrupt or IPI could then sneak in and corrupt a recursive token.

  Remove the infinite loop cycling.  When token contention is present this
  caused scheduler ticks to dock the wrong thread (the current thread instead
  of the target thread).  Heavy token contention could cause higher priority
  processes to stall for very long periods of time.

  Instead, once the spin limit is exhausted we switch through the idle
  thread which places us in a better context from which to continue.

* Adjust the dragonfly process scheduler to detect contention when the
  current thread is the idle thread, and then attribute the tick to the
  correct thread (or at least a more-correct thread).
sys/kern/kern_exit.c
sys/kern/lwkt_thread.c
sys/kern/usched_dfly.c