PERFORCE change 98625 for review
John Birrell
jb at FreeBSD.org
Tue Jun 6 04:29:18 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=98625
Change 98625 by jb at jb_freebsd2 on 2006/06/06 03:08:18
Add a function to get DTrace high resolution time independent of any
other functions that can have DTrace probes enabled on them.
DTrace high resolution time is equivalent to FreeBSD's nanouptime.
Affected files ...
.. //depot/projects/dtrace/src/sys/contrib/opensolaris/uts/common/sys/dtrace.h#18 edit
.. //depot/projects/dtrace/src/sys/kern/kern_tc.c#2 edit
.. //depot/projects/dtrace/src/sys/sys/time.h#4 edit
Differences ...
==== //depot/projects/dtrace/src/sys/contrib/opensolaris/uts/common/sys/dtrace.h#18 (text) ====
@@ -2231,7 +2231,9 @@
extern void (*dtrace_debugger_fini)(void);
extern dtrace_cacheid_t dtrace_predcache_id;
+#if defined(sun)
extern hrtime_t dtrace_gethrtime(void);
+#endif
extern void dtrace_sync(void);
extern void dtrace_toxic_ranges(void (*)(uintptr_t, uintptr_t));
extern void dtrace_xcall(processorid_t, dtrace_xcall_t, void *);
==== //depot/projects/dtrace/src/sys/kern/kern_tc.c#2 (text+ko) ====
@@ -10,6 +10,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/sys/kern/kern_tc.c,v 1.175 2006/03/15 20:22:32 phk Exp $");
+#include "opt_kdtrace.h"
#include "opt_ntp.h"
#include <sys/param.h>
@@ -303,6 +304,34 @@
}
/*
+ * DTrace needs a high resolution time function which can
+ * be called from a probe context and guaranteed not to have
+ * instrumented with probes itself. It avoids instrumenting
+ * functions with the 'dtrace_' prefix.
+ *
+ * The 'high resolution' time is actually nanoseconds uptime.
+ */
+#ifdef KDTRACE
+uint64_t
+dtrace_gethrtime()
+{
+ struct timehands *th;
+ u_int gen;
+ uint64_t hrt;
+
+ do {
+ th = timehands;
+ gen = th->th_generation;
+
+ hrt = th->th_offset.sec * (uint64_t)1000000000 +
+ (((uint64_t)1000000000 * (uint32_t)(th->th_offset.frac >> 32)) >> 32);
+ } while (gen == 0 || gen != th->th_generation);
+
+ return (hrt);
+}
+#endif
+
+/*
* Initialize a new timecounter and possibly use it.
*/
void
==== //depot/projects/dtrace/src/sys/sys/time.h#4 (text+ko) ====
@@ -304,6 +304,7 @@
void timevaladd(struct timeval *t1, const struct timeval *t2);
void timevalsub(struct timeval *t1, const struct timeval *t2);
int tvtohz(struct timeval *tv);
+uint64_t dtrace_gethrtime(void);
#else /* !_KERNEL */
#include <time.h>
More information about the p4-projects
mailing list