summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-05-17 22:44:56 +0000
committerjhb <jhb@FreeBSD.org>2001-05-17 22:44:56 +0000
commit028d04532e1664ccba231aec864e44a664c7ae18 (patch)
treefb01bf7ef42ae823aea2bb990d0b5080dc1aa4dd /sys
parent7d561540988609998b733af982b2caaa753867c2 (diff)
downloadFreeBSD-src-028d04532e1664ccba231aec864e44a664c7ae18.zip
FreeBSD-src-028d04532e1664ccba231aec864e44a664c7ae18.tar.gz
- Don't panic on a try lock operation for a sleep lock if we hold a spin
lock. Since we won't actually block on a try lock operation, it's not a problem. Add a comment explaining why it is safe to skip lock order checking with try locks. - Remove the ithread list lock spin lock from the order list.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/subr_witness.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index de354c1..9ac882e 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -207,7 +207,6 @@ static struct witness_order_list_entry order_lists[] = {
{ "ng_node", &lock_class_mtx_spin },
{ "ng_worklist", &lock_class_mtx_spin },
{ "ithread table lock", &lock_class_mtx_spin },
- { "ithread list lock", &lock_class_mtx_spin },
{ "sched lock", &lock_class_mtx_spin },
{ "clk", &lock_class_mtx_spin },
{ "callout", &lock_class_mtx_spin },
@@ -485,7 +484,7 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line)
mtx_lock_spin(&w_mtx);
lock_list = PCPU_PTR(spinlocks);
if (class->lc_flags & LC_SLEEPLOCK) {
- if (*lock_list != NULL) {
+ if (*lock_list != NULL && (flags & LOP_TRYLOCK) == 0) {
mtx_unlock_spin(&w_mtx);
panic("blockable sleep lock (%s) %s @ %s:%d",
class->lc_name, lock->lo_name, file, line);
@@ -494,6 +493,11 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line)
}
mtx_unlock_spin(&w_mtx);
+ /*
+ * Try locks do not block if they fail to acquire the lock, thus
+ * there is no danger of deadlocks or of switching while holding a
+ * spin lock if we acquire a lock via a try operation.
+ */
if (flags & LOP_TRYLOCK)
goto out;
OpenPOWER on IntegriCloud