kernel - Fix ps/thread-exit and other related ps races
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 17 Nov 2011 17:04:53 +0000 (09:04 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 17 Nov 2011 17:17:02 +0000 (09:17 -0800)
commiteb2adbf513fa1db03b9e8e7b61fcaf511babd367
tree702e140bc34f6d48276428cb07c81870451c95a5
parent084009e28b58577006b6b58af0e8dc60ef7413bc
kernel - Fix ps/thread-exit and other related ps races

* Adjust sysctl_kern_proc()'s kernel thread scanning code to use a marker
  instead of depending on td remaining on its proper list.  Otherwise
  blocking conditions can rip td out from under us or move it to another
  cpu, potentially resulting in a crash or livelock.  Index the scan
  backwards to avoid live-locking continuous adds to the list.

* Fix a potential race is the zombie removal code vs a ps, p->p_token was
  being released too early.

* Adjust lwkt_exit() to wait for the thread's hold count to drop to zero
  so lwkt_hold() works as advertised.
sys/ddb/db_ps.c
sys/kern/kern_exit.c
sys/kern/kern_proc.c
sys/kern/lwkt_thread.c
sys/sys/thread.h