Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Dec 2007 02:50:13 GMT
From:      John Birrell <jb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 131405 for review
Message-ID:  <200712220250.lBM2oD0Y096628@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=131405

Change 131405 by jb@jb_freebsd1 on 2007/12/22 02:49:22

	Add the dtrace_gethrtime functions to get the number of nanoseconds
	since boot on the current CPU.

Affected files ...

.. //depot/projects/dtrace/src/sys/amd64/amd64/tsc.c#5 edit
.. //depot/projects/dtrace/src/sys/i386/i386/tsc.c#11 edit

Differences ...

==== //depot/projects/dtrace/src/sys/amd64/amd64/tsc.c#5 (text+ko) ====

@@ -28,6 +28,7 @@
 __FBSDID("$FreeBSD: src/sys/amd64/amd64/tsc.c,v 1.208 2007/06/04 18:25:01 dwmalone Exp $");
 
 #include "opt_clock.h"
+#include "opt_kdtrace.h"
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -44,6 +45,10 @@
 #include <machine/md_var.h>
 #include <machine/specialreg.h>
 
+#ifdef KDTRACE_HOOKS
+#include <sys/dtrace_bsd.h>
+#endif
+
 #include "cpufreq_if.h"
 
 uint64_t	tsc_freq;
@@ -220,3 +225,18 @@
 {
 	return (rdtsc());
 }
+
+#ifdef KDTRACE_HOOKS
+/*
+ * DTrace needs a high resolution time function which can
+ * be called from a probe context and guaranteed not to have
+ * instrumented with probes itself.
+ *
+ * Returns nanoseconds since boot.
+ */
+uint64_t
+dtrace_gethrtime()
+{
+	return (rdtsc() * (uint64_t) 1000000000 / tsc_freq);
+}
+#endif

==== //depot/projects/dtrace/src/sys/i386/i386/tsc.c#11 (text+ko) ====

@@ -28,6 +28,7 @@
 __FBSDID("$FreeBSD: src/sys/i386/i386/tsc.c,v 1.208 2007/06/04 18:25:06 dwmalone Exp $");
 
 #include "opt_clock.h"
+#include "opt_kdtrace.h"
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -44,6 +45,10 @@
 #include <machine/md_var.h>
 #include <machine/specialreg.h>
 
+#ifdef KDTRACE_HOOKS
+#include <sys/dtrace_bsd.h>
+#endif
+
 #include "cpufreq_if.h"
 
 uint64_t	tsc_freq;
@@ -244,3 +249,18 @@
 {
 	return (rdtsc());
 }
+
+#ifdef KDTRACE_HOOKS
+/*
+ * DTrace needs a high resolution time function which can
+ * be called from a probe context and guaranteed not to have
+ * instrumented with probes itself.
+ *
+ * Returns nanoseconds since boot.
+ */
+uint64_t
+dtrace_gethrtime()
+{
+	return (rdtsc() * (uint64_t) 1000000000 / tsc_freq);
+}
+#endif



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