From 700bfa750f98f5df270b0e17058a344069cc1f07 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Fri, 20 Oct 2000 07:52:10 +0000 Subject: [PATCH] - GC some #if 0'd code regarding the non-existant safepri variable. - Don't dink with the witness state of Giant unless we actually own it during mi_switch(). --- sys/kern/kern_synch.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 303133461113..b6b2609cd824 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -44,8 +44,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -58,9 +60,7 @@ #endif #include -#include #include -#include static void sched_setup __P((void *dummy)); SYSINIT(sched_setup, SI_SUB_KICK_SCHEDULER, SI_ORDER_FIRST, sched_setup, NULL) @@ -377,19 +377,6 @@ updatepri(p) static TAILQ_HEAD(slpquehead, proc) slpque[TABLESIZE]; #define LOOKUP(x) (((intptr_t)(x) >> 8) & (TABLESIZE - 1)) -#if 0 -/* - * During autoconfiguration or after a panic, a sleep will simply - * lower the priority briefly to allow interrupts, then return. - * The priority to be used (safepri) is machine-dependent, thus this - * value is initialized and maintained in the machine-dependent layers. - * This priority will typically be 0, or the lowest priority - * that is safe for use on the interrupt stack; it can be made - * higher to block network software interrupts after panics. - */ -int safepri; -#endif - void sleepinit(void) { @@ -899,7 +886,8 @@ mi_switch() p, p->p_pid, p->p_comm, (void *) sched_lock.mtx_lock); mtx_enter(&sched_lock, MTX_SPIN | MTX_RLIKELY); - WITNESS_SAVE(&Giant, Giant); + if (mtx_owned(&Giant)) + WITNESS_SAVE(&Giant, Giant); for (giantreleased = 0; mtx_owned(&Giant); giantreleased++) mtx_exit(&Giant, MTX_DEF | MTX_NOSWITCH); @@ -958,7 +946,8 @@ mi_switch() mtx_exit(&sched_lock, MTX_SPIN); while (giantreleased--) mtx_enter(&Giant, MTX_DEF); - WITNESS_RESTORE(&Giant, Giant); + if (mtx_owned(&Giant)) + WITNESS_RESTORE(&Giant, Giant); splx(x); }