svn commit: r187664 - head/sys/kern

Robert Watson rwatson at FreeBSD.org
Sat Jan 24 02:22:51 PST 2009


Author: rwatson
Date: Sat Jan 24 10:22:49 2009
New Revision: 187664
URL: http://svn.freebsd.org/changeset/base/187664

Log:
  Add explicit static DTrace tracing to the callout mechanism, capturing
  pointers to the callout handler just before and just after the callout
  it invoked.  I attempted to do this in a manner congruent to tracing in
  Solaris's callout mechanism, but couldn't quite use the same names due
  to convention and syntax differences.
  
  Example DTrace script to generate a distribution graph of callout
  execution times:
  
  callout_execute:::callout_start
  {
          self->cstart = timestamp;
  }
  
  callout_execute:::callout_end
  {
  
          @length = quantize(timestamp - self->cstart);
  }
  
  Reviewed by:	jb
  MFC after:	3 days

Modified:
  head/sys/kern/kern_timeout.c

Modified: head/sys/kern/kern_timeout.c
==============================================================================
--- head/sys/kern/kern_timeout.c	Sat Jan 24 05:32:11 2009	(r187663)
+++ head/sys/kern/kern_timeout.c	Sat Jan 24 10:22:49 2009	(r187664)
@@ -37,6 +37,8 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include "opt_kdtrace.h"
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/bus.h>
@@ -49,10 +51,19 @@ __FBSDID("$FreeBSD$");
 #include <sys/malloc.h>
 #include <sys/mutex.h>
 #include <sys/proc.h>
+#include <sys/sdt.h>
 #include <sys/sleepqueue.h>
 #include <sys/sysctl.h>
 #include <sys/smp.h>
 
+SDT_PROVIDER_DEFINE(callout_execute);
+SDT_PROBE_DEFINE(callout_execute, kernel, , callout_start);
+SDT_PROBE_ARGTYPE(callout_execute, kernel, , callout_start, 0,
+    "struct callout *");
+SDT_PROBE_DEFINE(callout_execute, kernel, , callout_end); 
+SDT_PROBE_ARGTYPE(callout_execute, kernel, , callout_end, 0,
+    "struct callout *");
+
 static int avg_depth;
 SYSCTL_INT(_debug, OID_AUTO, to_avg_depth, CTLFLAG_RD, &avg_depth, 0,
     "Average number of items examined per softclock call. Units = 1/1000");
@@ -395,7 +406,11 @@ softclock(void *arg)
 				binuptime(&bt1);
 #endif
 				THREAD_NO_SLEEPING();
+				SDT_PROBE(callout_execute, kernel, ,
+				    callout_start, c, 0, 0, 0, 0);
 				c_func(c_arg);
+				SDT_PROBE(callout_execute, kernel, ,
+				    callout_end, c, 0, 0, 0, 0);
 				THREAD_SLEEPING_OK();
 #ifdef DIAGNOSTIC
 				binuptime(&bt2);


More information about the svn-src-head mailing list