PERFORCE change 98706 for review

John Birrell jb at FreeBSD.org
Wed Jun 7 00:27:25 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=98706

Change 98706 by jb at jb_freebsd2 on 2006/06/06 23:26:23

	Add DTrace's wallclock high resolution time function and remove the
	uptime one which belongs in the machine dependent code.
	
	The diff for this change makes the change look more complicated
	than it really is. It's one function removed and one added. No others
	are changed.

Affected files ...

.. //depot/projects/dtrace/src/sys/kern/kern_tc.c#3 edit

Differences ...

==== //depot/projects/dtrace/src/sys/kern/kern_tc.c#3 (text+ko) ====

@@ -289,47 +289,38 @@
 	} while (gen == 0 || gen != th->th_generation);
 }
 
-void
-getmicrotime(struct timeval *tvp)
+#ifdef KDTRACE
+uint64_t
+dtrace_gethrestime()
 {
 	struct timehands *th;
 	u_int gen;
+	uint64_t hrt;
 
-	ngetmicrotime++;
 	do {
 		th = timehands;
 		gen = th->th_generation;
-		*tvp = th->th_microtime;
+		hrt = ((uint64_t) th->th_nanotime.tv_sec * 1000000000) +
+		    th->th_nanotime.tv_nsec;
 	} while (gen == 0 || gen != th->th_generation);
+
+	return (hrt);
 }
+#endif
 
-/*
- * 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()
+void
+getmicrotime(struct timeval *tvp)
 {
 	struct timehands *th;
 	u_int gen;
-	uint64_t hrt;
 
+	ngetmicrotime++;
 	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);
+		*tvp = th->th_microtime;
 	} while (gen == 0 || gen != th->th_generation);
-
-	return (hrt);
 }
-#endif
 
 /*
  * Initialize a new timecounter and possibly use it.


More information about the p4-projects mailing list