summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2003-03-11 20:54:37 +0000
committerjhb <jhb@FreeBSD.org>2003-03-11 20:54:37 +0000
commitf7f4727b44d784e309e121cae1fc97f2e41fd84d (patch)
treeedd1847e24c44165ad5573edcf7973baef93b5cc /sys/kern
parented498389de69f1534f3dfa22783e1ade2e834ea4 (diff)
downloadFreeBSD-src-f7f4727b44d784e309e121cae1fc97f2e41fd84d.zip
FreeBSD-src-f7f4727b44d784e309e121cae1fc97f2e41fd84d.tar.gz
Do the lock order check skip for the LOP_TRYLOCK case after the check for
recursing on a lock instead of before. This fixes a bug where WITNESS could get a little confused if you did an sx_tryslock() on a sx lock that you already had an slock on. WITNESS would still function correctly but it could result in weirdness in the output of 'show locks'. This also makes it possible for mtx_trylock() to recurse on a lock.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/subr_witness.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index 0453c93..47642b9 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -556,14 +556,6 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line)
lock_list = PCPU_PTR(spinlocks);
/*
- * 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;
-
- /*
* Is this the first lock acquired? If so, then no order checking
* is needed.
*/
@@ -609,6 +601,14 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line)
}
/*
+ * 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;
+
+ /*
* Check for duplicate locks of the same type. Note that we only
* have to check for this on the last lock we just acquired. Any
* other cases will be caught as lock order violations.
OpenPOWER on IntegriCloud