This is a MAJOR rewrite of usched_bsd4 and related support logic, plus
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 18 Dec 2008 21:37:37 +0000 (13:37 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 18 Dec 2008 21:37:37 +0000 (13:37 -0800)
commitb9eb1c1952f8cb476b9b6192b607a945deb05cf8
treec62c4ba899e9662204664bea406026b111583844
parent20479584e1624aae60acc01070a685a1ae5ae392
This is a MAJOR rewrite of usched_bsd4 and related support logic, plus
additional improvements to the LWKT scheduler.

* The LWKT scheduler used to run a user thread not needing the MP lock
  if it was unable to run a kernel thread that did need it, due to some
  other cpu holding the lock.  This created a massive priority inversion

  LWKT no longer does this.  It will happily run other MPSAFE kernel
  threads but as long as kernel threads exist which need the MP lock
  LWKT will no longer switch to a user mode thread.

  Add a new sysctl lwkt.chain_mplock which defaults to 0 (off).  If set
  to 1 LWKT will attempt to use IPIs to notify conflicting cpus when the
  MP lock is available and will also allow user mode threads to run if
  kernel threads are present needing the MP lock (but unable to get it).
  NOTE: Current turning on this feature results in reduced performance,
  though not as bad as pre-patch.

* The main control logic USCHED_BSD4 was almost completely rewritten,
  greatly improving interactivity in the face of cpu bound programs
  such as compiles.

  USCHED_BSD4 no longer needs to use the scheduler helper when the
  system is under load.  The scheduler helper is only used to allow
  one cpu to kick another idle cpu when additional processes are
  present.

  USCHED_BSD4 now takes great advantage of the scheduler's cpu-local
  design and uses a bidding algorithm for processes trying to return
  to user mode to determine which one is the best.  Winners simply
  deschedule losers, and since the loser is clearly not running when
  the winner does this the descheduling operation is ultra simple to
  accomplish.
sys/kern/lwkt_thread.c
sys/kern/usched_bsd4.c
sys/platform/pc32/i386/mplock.s
sys/platform/pc32/i386/trap.c
sys/platform/vkernel/i386/mplock.s
sys/platform/vkernel/i386/trap.c
sys/sys/thread.h