panic: Optionally, trace secondary panics

To diagnose and fix secondary panics, it is useful to have a stack trace.
When panic tracing is enabled, optionally trace secondary panics as well.

The option is configured with the tunable/sysctl debug.trace_all_panics.

(The original concern that inspired only tracing the primary panic was
likely that the secondary trace may scroll the original panic message or trace
off the screen.  This is less of a concern for serial consoles with logging.
Not everything has a serial console, though, so the behavior is optional.)

Discussed with:	jhb
Sponsored by:	Dell EMC Isilon
This commit is contained in:
Conrad Meyer 2018-04-24 18:54:20 +00:00
parent 18959b695d
commit ad1fc31570

View File

@ -124,12 +124,16 @@ SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic,
#ifdef KDB_TRACE
static int trace_on_panic = 1;
static bool trace_all_panics = true;
#else
static int trace_on_panic = 0;
static bool trace_all_panics = false;
#endif
SYSCTL_INT(_debug, OID_AUTO, trace_on_panic,
CTLFLAG_RWTUN | CTLFLAG_SECURE,
&trace_on_panic, 0, "Print stack trace on kernel panic");
SYSCTL_BOOL(_debug, OID_AUTO, trace_all_panics, CTLFLAG_RWTUN,
&trace_all_panics, 0, "Print stack traces on secondary kernel panics");
#endif /* KDB */
static int sync_on_panic = 0;
@ -829,7 +833,7 @@ vpanic(const char *fmt, va_list ap)
#endif
printf("time = %jd\n", (intmax_t )time_second);
#ifdef KDB
if (newpanic && trace_on_panic)
if ((newpanic || trace_all_panics) && trace_on_panic)
kdb_backtrace();
if (debugger_on_panic)
kdb_enter(KDB_WHY_PANIC, "panic");