summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2002-05-20 17:49:46 +0000
committerjhb <jhb@FreeBSD.org>2002-05-20 17:49:46 +0000
commit4423d1f90a42798bc7f81936eefbcae74bcb0a63 (patch)
tree8fca41fe6c89ba512ef23eefe5f8070bddaa3515
parentbb678d578d02468619b3bd655774c745c266e1ca (diff)
downloadFreeBSD-src-4423d1f90a42798bc7f81936eefbcae74bcb0a63.zip
FreeBSD-src-4423d1f90a42798bc7f81936eefbcae74bcb0a63.tar.gz
- Allow witness_sleep() to be called when witness hasn't been initialized
yet. We just return without performing any checks. - Don't explicitly enter and exit critical sections when walking lock lists. We don't need a critical section to walk the list of sleep locks for a thread. We check to see if a spin lock list is empty before we walk it. If the list is empty we don't need to walk it. If it isn't then we already hold at least one spin lock and are already in a critical section and thus don't need our own explicit critical section.
-rw-r--r--sys/kern/subr_witness.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index fcc9b53..099828d 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -882,14 +882,9 @@ witness_sleep(int check_only, struct lock_object *lock, const char *file,
struct thread *td;
int i, n;
- if (witness_dead || panicstr != NULL)
+ if (witness_cold || witness_dead || panicstr != NULL)
return (0);
- KASSERT(!witness_cold, ("%s: witness_cold", __func__));
n = 0;
- /*
- * Preemption bad because we need PCPU_PTR(spinlocks) to not change.
- */
- critical_enter();
td = curthread;
lock_list = &td->td_sleeplocks;
again:
@@ -916,7 +911,11 @@ again:
lock1->li_lock->lo_name, lock1->li_file,
lock1->li_line);
}
- if (lock_list == &td->td_sleeplocks) {
+ if (lock_list == &td->td_sleeplocks && PCPU_GET(spinlocks) != NULL) {
+ /*
+ * Since we already hold a spinlock preemption is
+ * already blocked.
+ */
lock_list = PCPU_PTR(spinlocks);
goto again;
}
@@ -924,7 +923,6 @@ again:
if (witness_ddb && n)
Debugger(__func__);
#endif /* DDB */
- critical_exit();
return (n);
}
@@ -1346,15 +1344,9 @@ witness_list(struct thread *td)
* out from under us. It is probably best to just not try to handle
* threads on other CPU's for now.
*/
- if (td == curthread) {
- /*
- * Preemption bad because we need PCPU_PTR(spinlocks) to not
- * change.
- */
- critical_enter();
+ if (td == curthread && PCPU_GET(spinlocks) != NULL)
nheld += witness_list_locks(PCPU_PTR(spinlocks));
- critical_exit();
- }
+
return (nheld);
}
OpenPOWER on IntegriCloud