1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-25 16:13:17 +00:00

- 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.
This commit is contained in:
John Baldwin 2006-08-15 18:26:12 +00:00
parent 225ee44c8a
commit 0fa2168b19
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=161336

View File

@ -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");
}