diff options
Diffstat (limited to 'sys/kern/kern_synch.c')
-rw-r--r-- | sys/kern/kern_synch.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index bf4b89d..45ad0f0 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -426,16 +426,6 @@ msleep(ident, mtx, priority, wmesg, timo) #endif WITNESS_SLEEP(0, mtx); mtx_enter(&sched_lock, MTX_SPIN); - DROP_GIANT_NOSWITCH(); - - if (mtx != NULL) { - mtx_assert(mtx, MA_OWNED | MA_NOTRECURSED); - WITNESS_SAVE(mtx, mtx); - mtx_exit(mtx, MTX_DEF | MTX_NOSWITCH); - if (priority & PDROP) - mtx = NULL; - } - s = splhigh(); if (cold || panicstr) { /* @@ -444,11 +434,23 @@ msleep(ident, mtx, priority, wmesg, timo) * don't run any other procs or panic below, * in case this is the idle process and already asleep. */ + if (mtx != NULL && priority & PDROP) + mtx_exit(mtx, MTX_DEF | MTX_NOSWITCH); mtx_exit(&sched_lock, MTX_SPIN); splx(s); return (0); } + DROP_GIANT_NOSWITCH(); + + if (mtx != NULL) { + mtx_assert(mtx, MA_OWNED | MA_NOTRECURSED); + WITNESS_SAVE(mtx, mtx); + mtx_exit(mtx, MTX_DEF | MTX_NOSWITCH); + if (priority & PDROP) + mtx = NULL; + } + KASSERT(p != NULL, ("msleep1")); KASSERT(ident != NULL && p->p_stat == SRUN, ("msleep")); /* |