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 01:59:33 +0000 (18:59 -0700)
commit3a06728ed5a79bd111cf4a25581d00dfcdf01e54
tree7bb1b6a47cf291965a2c9f6a409945bf689fd1da
parentca88a24a2812a54364b719fab5019802ec6836fc
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