summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/kern/subr_witness.c34
-rw-r--r--sys/sys/lock.h35
2 files changed, 35 insertions, 34 deletions
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index 6fa43d6..da114f1 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -116,6 +116,9 @@ __FBSDID("$FreeBSD$");
#define lo_list lo_witness_data.lod_list
#define lo_witness lo_witness_data.lod_witness
+#define LI_RECURSEMASK 0x0000ffff /* Recursion depth of lock instance. */
+#define LI_EXCLUSIVE 0x00010000 /* Exclusive lock instance. */
+
/* Define this to check for blessed mutexes */
#undef BLESSING
@@ -130,8 +133,39 @@ __FBSDID("$FreeBSD$");
#define WITNESS_NCHILDREN 6
+#define LOCK_NCHILDREN 3
+
struct witness_child_list_entry;
+/*
+ * Lock instances. A lock instance is the data associated with a lock while
+ * it is held by witness. For example, a lock instance will hold the
+ * recursion count of a lock. Lock instances are held in lists. Spin locks
+ * are held in a per-cpu list while sleep locks are held in per-thread list.
+ */
+struct lock_instance {
+ struct lock_object *li_lock;
+ const char *li_file;
+ int li_line;
+ u_int li_flags; /* Recursion count and LI_* flags. */
+};
+
+/*
+ * A simple list type used to build the list of locks held by a thread
+ * or CPU. We can't simply embed the list in struct lock_object since a
+ * lock may be held by more than one thread if it is a shared lock. Locks
+ * are added to the head of the list, so we fill up each list entry from
+ * "the back" logically. To ease some of the arithmetic, we actually fill
+ * in each list entry the normal way (children[0] then children[1], etc.) but
+ * when we traverse the list we read children[count-1] as the first entry
+ * down to children[0] as the final entry.
+ */
+struct lock_list_entry {
+ struct lock_list_entry *ll_next;
+ struct lock_instance ll_children[LOCK_NCHILDREN];
+ u_int ll_count;
+};
+
struct witness {
const char *w_name;
struct lock_class *w_class;
diff --git a/sys/sys/lock.h b/sys/sys/lock.h
index 0b07159..2e94120 100644
--- a/sys/sys/lock.h
+++ b/sys/sys/lock.h
@@ -35,6 +35,7 @@
#include <sys/queue.h>
#include <sys/_lock.h>
+struct lock_list_entry;
struct thread;
/*
@@ -91,9 +92,6 @@ struct lock_class {
#define LOCK_CLASS(lock) (lock_classes[LO_CLASSINDEX((lock))])
#define LOCK_CLASS_MAX (LO_CLASSMASK >> LO_CLASSSHIFT)
-#define LI_RECURSEMASK 0x0000ffff /* Recursion depth of lock instance. */
-#define LI_EXCLUSIVE 0x00010000 /* Exclusive lock instance. */
-
/*
* Option flags passed to lock operations that witness also needs to know
* about or that are generic across all locks.
@@ -115,37 +113,6 @@ struct lock_class {
#ifdef _KERNEL
/*
- * Lock instances. A lock instance is the data associated with a lock while
- * it is held by witness. For example, a lock instance will hold the
- * recursion count of a lock. Lock instances are held in lists. Spin locks
- * are held in a per-cpu list while sleep locks are held in per-thread list.
- */
-struct lock_instance {
- struct lock_object *li_lock;
- const char *li_file; /* File and line of last acquire. */
- int li_line;
- u_int li_flags; /* Recursion count and LI_* flags. */
-};
-
-/*
- * A simple list type used to build the list of locks held by a thread
- * or CPU. We can't simply embed the list in struct lock_object since a
- * lock may be held by more than one thread if it is a shared lock. Locks
- * are added to the head of the list, so we fill up each list entry from
- * "the back" logically. To ease some of the arithmetic, we actually fill
- * in each list entry the normal way (childer[0] then children[1], etc.) but
- * when we traverse the list we read children[count-1] as the first entry
- * down to children[0] as the final entry.
- */
-#define LOCK_NCHILDREN 3
-
-struct lock_list_entry {
- struct lock_list_entry *ll_next;
- struct lock_instance ll_children[LOCK_NCHILDREN];
- u_int ll_count;
-};
-
-/*
* If any of WITNESS, INVARIANTS, or KTR_LOCK KTR tracing has been enabled,
* then turn on LOCK_DEBUG. When this option is on, extra debugging
* facilities such as tracking the file and line number of lock operations
OpenPOWER on IntegriCloud