diff options
author | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2015-05-07 18:30:28 +0000 |
---|---|---|
committer | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2015-05-07 18:30:28 +0000 |
commit | ad11144277fedbf5bfcb876ca96adcf560f6e5b1 (patch) | |
tree | 12c50c51cca376196b3655e1b935e64b22fff64b /sys | |
parent | e33646025c1a3273377550a7c1c72102ebe8dc2e (diff) |
msleep(9) must prevent kernel from attempting a context switch
during autoconf and after panics.
Tweak and OK guenther, OK miod
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_synch.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index d5efc750c48..e438f0dac99 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_synch.c,v 1.119 2015/03/14 03:38:50 jsg Exp $ */ +/* $OpenBSD: kern_synch.c,v 1.120 2015/05/07 18:30:27 mikeb Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /* @@ -141,7 +141,7 @@ tsleep(const volatile void *ident, int priority, const char *wmesg, int timo) } /* - * Same as tsleep, but if we have a mutex provided, then once we've + * Same as tsleep, but if we have a mutex provided, then once we've * entered the sleep queue we drop the mutex. After sleeping we re-lock. */ int @@ -154,12 +154,30 @@ msleep(const volatile void *ident, struct mutex *mtx, int priority, KASSERT((priority & ~(PRIMASK | PCATCH | PNORELOCK)) == 0); KASSERT(mtx != NULL); + if (cold || panicstr) { + /* + * After a panic, or during autoconfiguration, + * just give interrupts a chance, then just return; + * don't run any other procs or panic below, + * in case this is the idle process and already asleep. + */ + spl = MUTEX_OLDIPL(mtx); + MUTEX_OLDIPL(mtx) = safepri; + mtx_leave(mtx); + if ((priority & PNORELOCK) == 0) { + mtx_enter(mtx); + MUTEX_OLDIPL(mtx) = spl; + } else + splx(spl); + return (0); + } + sleep_setup(&sls, ident, priority, wmesg); sleep_setup_timeout(&sls, timo); sleep_setup_signal(&sls, priority); /* XXX - We need to make sure that the mutex doesn't - * unblock splsched. This can be made a bit more + * unblock splsched. This can be made a bit more * correct when the sched_lock is a mutex. */ spl = MUTEX_OLDIPL(mtx); |