PERFORCE change 98707 for review
John Birrell
jb at FreeBSD.org
Wed Jun 7 00:25:01 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=98707
Change 98707 by jb at jb_freebsd2 on 2006/06/06 23:29:58
Add a function for DTrace to get the uptime in it's high
resolution format (nanoseconds) without calling any other
functions (which would violate the probe context call
rules).
Note that this only works on Pentium processors and above
where the TSC is being used. It doesn't address any issues
with TSC differences between processors. So there is more
work required here.
rdtsc() is an inline function so it doesn't violate the
probe context rules.
Affected files ...
.. //depot/projects/dtrace/src/sys/i386/i386/tsc.c#2 edit
Differences ...
==== //depot/projects/dtrace/src/sys/i386/i386/tsc.c#2 (text+ko) ====
@@ -28,6 +28,7 @@
__FBSDID("$FreeBSD: src/sys/i386/i386/tsc.c,v 1.205 2006/02/11 09:33:06 phk Exp $");
#include "opt_clock.h"
+#include "opt_kdtrace.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -153,3 +154,18 @@
{
return (rdtsc());
}
+
+/*
+ * 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.
+ */
+#ifdef KDTRACE
+uint64_t
+dtrace_gethrtime()
+{
+ return (rdtsc() * (uint64_t) 1000000000 / tsc_freq);
+}
+#endif
More information about the p4-projects
mailing list