From 30c571736e3b0f7e68085689796538a8b6232925 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 13 Feb 2003 01:35:56 +0000 Subject: [PATCH] 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. --- sys/kern/subr_witness.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index 3ab4a33b5f5d..8290986e4ff3 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;