kernel - Fix TDF_EXITING bug, instrument potential live loops
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 24 Jul 2016 01:59:33 +0000 (18:59 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 24 Jul 2016 03:59:37 +0000 (20:59 -0700)
commit0e151d4aecf43cc4b8623e60435f997c9f6e2bb7
tree2ac10b8af5702c1a774b5a11fcb8506365bc632b
parentdfe9beaa09e77d03dbf40c3286ddbe69ff8beff2
kernel - Fix TDF_EXITING bug, instrument potential live loops

* Fix a TDF_EXITING bug.  lwkt_switch_return() is called to fixup
  the 'previous' thread, meaning turning off TDF_RUNNING and handling
  TDF_EXITING.

  However, if TDF_EXITING is not set, the old thread can be used or
  acted upon / exited on by some other cpu the instant we clear
  TDF_RUNNING.  In this situation it is possible that the other cpu
  will set TDF_EXITING in the small window of opportunity just before
  we check ourselves, leading to serious thread management corruption.

* The new pmap_inval*() code runs on Xinvltlb instead of as a IPIQ
  and can easily create significant latency between the two tests,
  whereas the old code ran as an IPIQ and could not due to the critical
  section.
sys/kern/lwkt_thread.c