summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2005-09-15 19:07:14 +0000
committerjhb <jhb@FreeBSD.org>2005-09-15 19:07:14 +0000
commit00aec4049358a50ebf9722344e26dac31cb64c76 (patch)
tree212adcb46a6b5b1a226c1ccb36f3f42b16d2b7f9 /sys/kern
parent0550cbdbeb0ddd2d62eca570ff73d07163db0212 (diff)
downloadFreeBSD-src-00aec4049358a50ebf9722344e26dac31cb64c76.zip
FreeBSD-src-00aec4049358a50ebf9722344e26dac31cb64c76.tar.gz
- Enforce an implicit lock order that Giant cannot be locked while holding
any other non-sleepable lock. In plain English: Giant comes before all other mutexes. - Add some extra description to the lock order reversal printf's to indicate when a reversal is triggered by a hard-coded implicit rule. Requested by: truckman (2) MFC after: 1 week
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/subr_witness.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index e94b017..7f038f9 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -960,6 +960,13 @@ witness_checkorder(struct lock_object *lock, int flags, const char *file,
(lock1->li_lock->lo_flags & LO_SLEEPABLE) == 0))
goto reversal;
/*
+ * If we are locking Giant and this is a non-sleepable
+ * lock, then treat it as a reversal.
+ */
+ if ((lock1->li_lock->lo_flags & LO_SLEEPABLE) == 0 &&
+ lock == &Giant.mtx_object)
+ goto reversal;
+ /*
* Check the lock order hierarchy for a reveresal.
*/
if (!isitmydescendant(w, w1))
@@ -993,7 +1000,16 @@ witness_checkorder(struct lock_object *lock, int flags, const char *file,
/*
* Ok, yell about it.
*/
- printf("lock order reversal\n");
+ if (((lock->lo_flags & LO_SLEEPABLE) != 0 &&
+ (lock1->li_lock->lo_flags & LO_SLEEPABLE) == 0))
+ printf(
+ "lock order reversal: (sleepable after non-sleepable)\n");
+ else if ((lock1->li_lock->lo_flags & LO_SLEEPABLE) == 0
+ && lock == &Giant.mtx_object)
+ printf(
+ "lock order reversal: (Giant after non-sleepable)\n");
+ else
+ printf("lock order reversal:\n");
/*
* Try to locate an earlier lock with
* witness w in our list.
OpenPOWER on IntegriCloud