diff options
| author | Bjoern A. Zeeb <bz@FreeBSD.org> | 2019-12-06 16:34:04 +0000 |
|---|---|---|
| committer | Bjoern A. Zeeb <bz@FreeBSD.org> | 2019-12-06 16:34:04 +0000 |
| commit | 173c062a569b8e27f71dbc272c8ebe772a84c252 (patch) | |
| tree | 0b6491b2dfb9723bd9bfcf4200180f85e786346c /sys | |
| parent | 0a833dff03a3ec8ca724682ef5d73464d2477b2e (diff) | |
Improve EPOCH_TRACE
Two changes to EPOCH_TRACE:
(1) add a sysctl to surpress the backtrace from epoch_trace_report().
Sometimes the log line for the recursion is enough and the
backtrace massively spams the console.
(2) In order to be able to go without the backtrace do not only
print where the previous occurance happened, but also where
the current one happens. That way we have file:line information
for both and can look at them without the need for getting line
numbers from backtrace and a debugging tool.
Reviewed by: glebius
Sponsored by: Netflix (originally)
Differential Revision: https://reviews.freebsd.org/D22641
Notes
svn path=/head/; revision=355448
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/kern/subr_epoch.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sys/kern/subr_epoch.c b/sys/kern/subr_epoch.c index 0b3d634901be..be2242144c20 100644 --- a/sys/kern/subr_epoch.c +++ b/sys/kern/subr_epoch.c @@ -169,6 +169,10 @@ RB_GENERATE_STATIC(stacktree, stackentry, se_node, stackentry_compare); static struct mtx epoch_stacks_lock; MTX_SYSINIT(epochstacks, &epoch_stacks_lock, "epoch_stacks", MTX_DEF); +static bool epoch_trace_stack_print = true; +SYSCTL_BOOL(_kern_epoch, OID_AUTO, trace_stack_print, CTLFLAG_RWTUN, + &epoch_trace_stack_print, 0, "Print stack traces on epoch reports"); + static void epoch_trace_report(const char *fmt, ...) __printflike(1, 2); static inline void epoch_trace_report(const char *fmt, ...) @@ -197,7 +201,8 @@ epoch_trace_report(const char *fmt, ...) va_start(ap, fmt); (void)vprintf(fmt, ap); va_end(ap); - stack_print_ddb(&se.se_stack); + if (epoch_trace_stack_print) + stack_print_ddb(&se.se_stack); } static inline void @@ -209,8 +214,9 @@ epoch_trace_enter(struct thread *td, epoch_t epoch, epoch_tracker_t et, SLIST_FOREACH(iet, &td->td_epochs, et_tlink) if (iet->et_epoch == epoch) epoch_trace_report("Recursively entering epoch %s " - "previously entered at %s:%d\n", - epoch->e_name, iet->et_file, iet->et_line); + "at %s:%d, previously entered at %s:%d\n", + epoch->e_name, file, line, + iet->et_file, iet->et_line); et->et_epoch = epoch; et->et_file = file; et->et_line = line; @@ -223,9 +229,10 @@ epoch_trace_exit(struct thread *td, epoch_t epoch, epoch_tracker_t et, { if (SLIST_FIRST(&td->td_epochs) != et) { - epoch_trace_report("Exiting epoch %s in a not nested order. " - "Most recently entered %s at %s:%d\n", + epoch_trace_report("Exiting epoch %s in a not nested order " + "at %s:%d. Most recently entered %s at %s:%d\n", epoch->e_name, + file, line, SLIST_FIRST(&td->td_epochs)->et_epoch->e_name, SLIST_FIRST(&td->td_epochs)->et_file, SLIST_FIRST(&td->td_epochs)->et_line); |
