Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Jun 2006 23:26:38 GMT
From:      John Birrell <jb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 98706 for review
Message-ID:  <200606062326.k56NQc2l042481@repoman.freebsd.org>

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

Change 98706 by jb@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.



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