summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2006-08-15 18:26:12 +0000
committerjhb <jhb@FreeBSD.org>2006-08-15 18:26:12 +0000
commite092be01212a8a69fe2f62be7d44c909fe7002bb (patch)
tree2aed8afaa214668ab6515dab7466a380f872d1eb /sys
parent85e4bd1f986b3a3ebaf26e5dc22325bd2ed2f955 (diff)
downloadFreeBSD-src-e092be01212a8a69fe2f62be7d44c909fe7002bb.zip
FreeBSD-src-e092be01212a8a69fe2f62be7d44c909fe7002bb.tar.gz
- When spinning on a spin lock, if the debugger is active or we are in a
panic, go ahead and do the longer DELAY(1) spin wait. - If we panic due to spinning too long, print out a few more details including the pointer to the mutex in question and the tid of the owning thread.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_mutex.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index 6c66537..4d9afb6 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -604,6 +604,7 @@ void
_mtx_lock_spin(struct mtx *m, uintptr_t tid, int opts, const char *file,
int line)
{
+ struct thread *td;
int i = 0;
if (LOCK_LOG_TEST(&m->mtx_object, opts))
@@ -618,14 +619,19 @@ _mtx_lock_spin(struct mtx *m, uintptr_t tid, int opts, const char *file,
cpu_spinwait();
continue;
}
- if (i < 60000000)
+ if (i < 60000000 || kdb_active || panicstr != NULL)
DELAY(1);
- 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);
+ else {
+ td = mtx_owner(m);
+
+ /* If the mutex is unlocked, try again. */
+ if (td == NULL)
+ continue;
+ printf(
+ "spin lock %p (%s) held by %p (tid %d) too long\n",
+ m, m->mtx_object.lo_name, td, td->td_tid);
#ifdef WITNESS
- witness_display_spinlock(&m->mtx_object,
- mtx_owner(m));
+ witness_display_spinlock(&m->mtx_object, td);
#endif
panic("spin lock held too long");
}
OpenPOWER on IntegriCloud