summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_witness.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2003-02-13 01:35:56 +0000
committerpeter <peter@FreeBSD.org>2003-02-13 01:35:56 +0000
commit30c571736e3b0f7e68085689796538a8b6232925 (patch)
treeaedc0c6ee3b0dbab7adc98a9709a8b4674b2f273 /sys/kern/subr_witness.c
parente6756cd99a64dd24a10b01d1ae921d3afaa528a0 (diff)
downloadFreeBSD-src-30c571736e3b0f7e68085689796538a8b6232925.zip
FreeBSD-src-30c571736e3b0f7e68085689796538a8b6232925.tar.gz
Add a 'debug.witness_trace' sysctl (and tunable) when DDB is present.
This causes LOR and could-sleep messages to come with a stack trace.
Diffstat (limited to 'sys/kern/subr_witness.c')
-rw-r--r--sys/kern/subr_witness.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index 3ab4a33..8290986 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -170,6 +170,16 @@ int witness_ddb = 0;
#endif
TUNABLE_INT("debug.witness_ddb", &witness_ddb);
SYSCTL_INT(_debug, OID_AUTO, witness_ddb, CTLFLAG_RW, &witness_ddb, 0, "");
+
+/*
+ * When DDB is enabled and witness_trace is set to 1, it will cause the system
+ * to print a stack trace:
+ * - a lock heirarchy violation occurs
+ * - locks are held when going to sleep.
+ */
+int witness_trace = 1;
+TUNABLE_INT("debug.witness_trace", &witness_trace);
+SYSCTL_INT(_debug, OID_AUTO, witness_trace, CTLFLAG_RW, &witness_trace, 0, "");
#endif /* DDB */
#ifdef WITNESS_SKIPSPIN
@@ -717,8 +727,12 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line)
out:
#ifdef DDB
- if (witness_ddb && go_into_ddb)
- Debugger(__func__);
+ if (go_into_ddb) {
+ if (witness_trace)
+ backtrace();
+ if (witness_ddb)
+ Debugger(__func__);
+ }
#endif /* DDB */
w->w_file = file;
w->w_line = line;
OpenPOWER on IntegriCloud