kernel - Fix degenerate condition in dfly_setrunqueue_locked()
authorMatthew Dillon <dillon@apollo.backplane.com>
Wed, 13 Jan 2016 06:19:25 +0000 (22:19 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Wed, 13 Jan 2016 06:19:25 +0000 (22:19 -0800)
commitf95769d250511419731d255c79b3be89a878753d
tree80dbe69d68b1f834d44b13755fe106d6f30558a8
parent6343f0789103562ffe49d13cbefff1a9008365ce
kernel - Fix degenerate condition in dfly_setrunqueue_locked()

* dfly_setrunqueue_locked() was unconditionally adding the lp to the end
  of the round-robin queue for the specified priority due to a degenerate
  '... || !TAILQ_EMPTY()' test.

  Remove the degenerate test, allowing a thread to be entered onto the
  head of the queue if its rrcount is reasonable.  Theoretically this should
  allow interactivity at the same queue priority even in a heavily-batched
  environment.

* Do not reset rrcount when adding to the head of the queue even if
  the queue is otherwise empty.  This allows the round-robin state to be
  retained across short delays (for example, nanosleeps) which are not as
  interactive as the system might otherwise believe, resulting in a more fair
  apportionment of cpu between batchy threads that use different delays but
  wind up at the same priority.

* Also adjust dfly_resetpriority() to reset lwp_rrcount to 0 when moving
  a thread to a higher priority queue.

* These changes should probably be re-tested against the postgres test
  suite to determine if any regressions were introduced.  It could very
  well be that the original action of always adding to the end of the queue
  might actually be the best action to take.

Reported-by: Adrian Drzewiecki <z@drze.net>
sys/kern/usched_dfly.c