diff options
author | jhb <jhb@FreeBSD.org> | 2005-09-02 20:21:49 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2005-09-02 20:21:49 +0000 |
commit | 033d70b17995b13f51a9c8e064f79ccb9d5de28c (patch) | |
tree | afe85dee2c8932e0506558a02d3f656e0d3d580d | |
parent | 736b03e795aff3a9f15489ccdd58838cbe100297 (diff) | |
download | FreeBSD-src-033d70b17995b13f51a9c8e064f79ccb9d5de28c.zip FreeBSD-src-033d70b17995b13f51a9c8e064f79ccb9d5de28c.tar.gz |
- Add an assertion to panic if one tries to call mtx_trylock() on a spin
mutex.
- Don't panic if a spin lock is held too long inside _mtx_lock_spin() if
panicstr is set (meaning that we are already in a panic). Just keep
spinning forever instead.
-rw-r--r-- | sys/kern/kern_mutex.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index c659fed..a0127e7 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -407,6 +407,9 @@ _mtx_trylock(struct mtx *m, int opts, const char *file, int line) int rval; MPASS(curthread != NULL); + KASSERT(m->mtx_object.lo_class == &lock_class_mtx_sleep, + ("mtx_trylock() of spin mutex %s @ %s:%d", m->mtx_object.lo_name, + file, line)); if (mtx_owned(m) && (m->mtx_object.lo_flags & LO_RECURSABLE) != 0) { m->mtx_recurse++; @@ -594,7 +597,7 @@ _mtx_lock_spin(struct mtx *m, uintptr_t tid, int opts, const char *file, } if (i < 60000000) DELAY(1); - else if (!kdb_active) { + else if (!kdb_active && !panicstr) { printf("spin lock %s held by %p for > 5 seconds\n", m->mtx_object.lo_name, (void *)m->mtx_lock); #ifdef WITNESS |