MFC: Use the new thread no sleeping facility to replace the g_xup, g_xdown,

and dont_sleep_in_callout mutexes.  Also, disallow sleeping in hardware
interrupt handlers.

Approved by:	re (kensmith)
This commit is contained in:
jhb 2005-09-26 19:49:12 +00:00
parent de60f2213a
commit 74ef9d3c8a
3 changed files with 14 additions and 38 deletions

View File

@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/bio.h>
#include <sys/ktr.h>
#include <sys/proc.h>
#include <sys/errno.h>
#include <geom/geom.h>
@ -364,12 +365,6 @@ g_io_schedule_down(struct thread *tp __unused)
struct bio *bp;
off_t excess;
int error;
#ifdef WITNESS
struct mtx mymutex;
bzero(&mymutex, sizeof mymutex);
mtx_init(&mymutex, "g_xdown", NULL, MTX_DEF);
#endif
for(;;) {
g_bioq_lock(&g_bio_run_down);
@ -425,16 +420,12 @@ g_io_schedule_down(struct thread *tp __unused)
default:
break;
}
#ifdef WITNESS
mtx_lock(&mymutex);
#endif
THREAD_NO_SLEEPING();
CTR4(KTR_GEOM, "g_down starting bp %p provider %s off %ld "
"len %ld", bp, bp->bio_to->name, bp->bio_offset,
bp->bio_length);
bp->bio_to->geom->start(bp);
#ifdef WITNESS
mtx_unlock(&mymutex);
#endif
THREAD_SLEEPING_OK();
}
}
@ -462,40 +453,26 @@ void
g_io_schedule_up(struct thread *tp __unused)
{
struct bio *bp;
#ifdef WITNESS
struct mtx mymutex;
bzero(&mymutex, sizeof mymutex);
mtx_init(&mymutex, "g_xup", NULL, MTX_DEF);
#endif
for(;;) {
g_bioq_lock(&g_bio_run_up);
bp = g_bioq_first(&g_bio_run_task);
if (bp != NULL) {
g_bioq_unlock(&g_bio_run_up);
#ifdef WITNESS
mtx_lock(&mymutex);
#endif
THREAD_NO_SLEEPING();
CTR1(KTR_GEOM, "g_up processing task bp %p", bp);
bp->bio_task(bp->bio_task_arg);
#ifdef WITNESS
mtx_unlock(&mymutex);
#endif
THREAD_SLEEPING_OK();
continue;
}
bp = g_bioq_first(&g_bio_run_up);
if (bp != NULL) {
g_bioq_unlock(&g_bio_run_up);
#ifdef WITNESS
mtx_lock(&mymutex);
#endif
THREAD_NO_SLEEPING();
CTR4(KTR_GEOM, "g_up biodone bp %p provider %s off "
"%ld len %ld", bp, bp->bio_to->name,
bp->bio_offset, bp->bio_length);
biodone(bp);
#ifdef WITNESS
mtx_unlock(&mymutex);
#endif
THREAD_SLEEPING_OK();
continue;
}
CTR0(KTR_GEOM, "g_up going to sleep");

View File

@ -521,6 +521,8 @@ ithread_loop(void *arg)
* another pass.
*/
atomic_store_rel_int(&ithd->it_need, 0);
if (!(ithd->it_flags & IT_SOFT))
THREAD_NO_SLEEPING();
restart:
TAILQ_FOREACH(ih, &ithd->it_handlers, ih_next) {
if (ithd->it_flags & IT_SOFT && !ih->ih_need)
@ -546,6 +548,8 @@ restart:
if ((ih->ih_flags & IH_MPSAFE) == 0)
mtx_unlock(&Giant);
}
if (!(ithd->it_flags & IT_SOFT))
THREAD_SLEEPING_OK();
/*
* Interrupt storm handling:

View File

@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <sys/ktr.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/sysctl.h>
static int avg_depth;
@ -71,9 +72,6 @@ int callwheelsize, callwheelbits, callwheelmask;
struct callout_tailq *callwheel;
int softticks; /* Like ticks, but for softclock(). */
struct mtx callout_lock;
#ifdef DIAGNOSTIC
struct mtx dont_sleep_in_callout;
#endif
static struct callout *nextsoftcheck; /* Next callout to be checked. */
@ -159,9 +157,6 @@ kern_timeout_callwheel_init(void)
TAILQ_INIT(&callwheel[i]);
}
mtx_init(&callout_lock, "callout", NULL, MTX_SPIN | MTX_RECURSE);
#ifdef DIAGNOSTIC
mtx_init(&dont_sleep_in_callout, "dont_sleep_in_callout", NULL, MTX_DEF);
#endif
mtx_init(&callout_wait_lock, "callout_wait_lock", NULL, MTX_DEF);
cv_init(&callout_wait, "callout_wait");
}
@ -290,11 +285,11 @@ softclock(void *dummy)
}
#ifdef DIAGNOSTIC
binuptime(&bt1);
mtx_lock(&dont_sleep_in_callout);
#endif
THREAD_NO_SLEEPING();
c_func(c_arg);
THREAD_SLEEPING_OK();
#ifdef DIAGNOSTIC
mtx_unlock(&dont_sleep_in_callout);
binuptime(&bt2);
bintime_sub(&bt2, &bt1);
if (bt2.frac > maxdt) {