kernel - Fix stalls during major token contention
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 10 Jul 2016 05:24:06 +0000 (22:24 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 10 Jul 2016 05:24:06 +0000 (22:24 -0700)
commit844cfcd65d13ec68f98e077f96bd9307f4a5b969
tree1e65da0d69b1574be26f766625e3e2f4d0e5f8ae
parent7866a0e77eb936d96fdfd97077353384b65c6504
kernel - Fix stalls during major token contention

* When a set of processes is seriously contending on a token, unrelated
  lower-priority processes scheduled to the same cpu may stall randomly for
  several seconds at a time.  Such contention is rare, but can still occur
  at choke-points (such as multiple threads write-faulting on the same VM
  object) and result in a degenerate condition.

  This occurs because the scheduler has become fixated on the contending
  thread due to its priority.  Because the 'current thread' might not be the
  one that is contending, the scheduler clock does not account for the
  contending thread.

* Add a contention heuristic to the scheduler for now which releases the
  contending thread on the current cpu (allowing the userland scheduler to
  choose another thread to schedule).

* At the moment I have not tried to code the scheduler clock to account for
  the contending thread.  Theoretically doing so would reduce its dynamic
  priority so the scheduler does not fixate on it, but it is a bit of a
  round-about way to solve the problem whereas coding it in lwkt_switch()
  gives us nearly instant detection.
sys/kern/lwkt_thread.c