Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Dec 2019 16:34:04 +0000 (UTC)
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r355448 - head/sys/kern
Message-ID:  <201912061634.xB6GY4gf042266@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bz
Date: Fri Dec  6 16:34:04 2019
New Revision: 355448
URL: https://svnweb.freebsd.org/changeset/base/355448

Log:
  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

Modified:
  head/sys/kern/subr_epoch.c

Modified: head/sys/kern/subr_epoch.c
==============================================================================
--- head/sys/kern/subr_epoch.c	Fri Dec  6 16:20:22 2019	(r355447)
+++ head/sys/kern/subr_epoch.c	Fri Dec  6 16:34:04 2019	(r355448)
@@ -169,6 +169,10 @@ RB_GENERATE_STATIC(stacktree, stackentry, se_node, sta
 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, ep
 	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, epo
 {
 
 	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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201912061634.xB6GY4gf042266>