Date: Mon, 22 Aug 2005 20:30:48 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 82421 for review Message-ID: <200508222030.j7MKUm24063283@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=82421 Change 82421 by jhb@jhb_slimer on 2005/08/22 20:30:35 Merge in some more anti-foot shooting from jhb_lock. Affected files ... .. //depot/projects/smpng/sys/kern/kern_mutex.c#103 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_mutex.c#103 (text+ko) ==== @@ -412,6 +412,9 @@ 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++; @@ -460,6 +463,15 @@ return; } + /* + * If we have already panic'd and this is the thread that called + * panic(), then don't block on any mutexes but silently succeed. + * Otherwise, the kernel will deadlock since the scheduler isn't + * going to run the thread that holds the lock we need. + */ + if (panicstr != NULL && curthread->td_flags & TDF_INPANIC) + return; + if (LOCK_LOG_TEST(&m->mtx_object, opts)) CTR4(KTR_LOCK, "_mtx_lock_sleep: %s contested (lock=%p) at %s:%d", @@ -607,7 +619,7 @@ } 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 @@ -654,6 +666,15 @@ return; } + /* + * If we failed to unlock this lock and we are a thread that has + * called panic(), it may be due to the bypass in _mtx_lock_sleep() + * above. In that case, just return and leave the lock alone to + * avoid changing the state. + */ + if (panicstr != NULL && curthread->td_flags & TDF_INPANIC) + return; + turnstile_lock(&m->mtx_object); ts = turnstile_lookup(&m->mtx_object); if (LOCK_LOG_TEST(&m->mtx_object, opts))
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508222030.j7MKUm24063283>