kernel - Cleanup token code, add simple exclusive priority (2)
authorMatthew Dillon <dillon@apollo.backplane.com>
Sat, 21 Oct 2017 22:02:05 +0000 (15:02 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sat, 21 Oct 2017 22:09:31 +0000 (15:09 -0700)
commit5042f74dda34ca4cca002c8a21288262a96ad756
tree0ef9279804ffff6e0cf3985a0c08dc62324d32be
parentb72db1d3321d7a80f4da3f727765bcc200f30278
kernel - Cleanup token code, add simple exclusive priority (2)

* The priority mechanism revealed an issue with lwkt_switch()'s
  fall-back code in dealing with contended tokens.  The code was
  refusing to schedule a lower-priority thread on a cpu requesting an
  exclusive lock as another on that same cpu requesting a shared lock.

  This creates a problem for the exclusive priority feature.  More
  pointedly, it also creates a fairness problem in the mixed lock
  type use case generally.

* Change the mechanism to allow any thread polling on tokens to be
  scheduled.  The scheduler will still iterate in priority order.
  This imposes a little extra overhead with regards to userspace
  returns as a thread might be scheduled that then tries to return
  to userland without being the designated user thread.

* This also fixes another bug that cropped up recently where a
  32-way threaded program would sometimes not quickly schedule to
  all 32 cpus, sometimes leaving one or two cpus idle for a few
  seconds.
sys/kern/lwkt_thread.c