DELAY() is a spin loop, we can't use it any more because shutdown
authorMatthew Dillon <dillon@dragonflybsd.org>
Mon, 18 Jul 2005 02:47:36 +0000 (02:47 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Mon, 18 Jul 2005 02:47:36 +0000 (02:47 +0000)
commit3ad8cc2859276b658ed4217583a84d01e5cd1fbe
tree4f2ae858d08f4735fc4ba7f8cc4ed4d0e362fcd0
parentbb298a0e23a617bc84b92276467064c1a5c5882c
DELAY() is a spin loop, we can't use it any more because shutdown
depends on other threads working.  Not only does the syncer and buffer
flusher need to work (else they might get stuck holding a lock on a buffer),
but the scheduler helper threads and device helper threads must also continue
to operate to be able to successfully flush the buffer cache.   In addition,
busy looping while holding the BGL can seriously deadlock SMP machines, so
even if it was (sometimes) possible to get away with using DELAY on UP boxes,
it's simply impossible on an SMP box.

So change the DELAY's to tsleep's in the shutdown code.  The current thread
is also given a very high priority (higher then an interrupt thread,
in fact), to try to ensure it gets through the shutdown procedure even if
the system is fried.  For the moment we do not move the thread to cpu #0.

This puts us in a somewhat awkwar situation when handling panics, but I don't
see that we have much of a choice.

Reported-by: Peter Avalos, David Rhodus, and numerous other people over time.
sys/kern/kern_shutdown.c