Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 Dec 2012 19:33:40 +0000 (UTC)
From:      "George V. Neville-Neil" <gnn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r244093 - in stable/9/sys: cddl/dev/dtrace/amd64 cddl/dev/dtrace/i386 kern
Message-ID:  <201212101933.qBAJXehD095898@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gnn
Date: Mon Dec 10 19:33:39 2012
New Revision: 244093
URL: http://svnweb.freebsd.org/changeset/base/244093

Log:
  MFC: 238537,238552
  Add support for walltimestamp in DTrace.
  
  Submitted by:	Fabian Keil
  Includes correction by: avg

Modified:
  stable/9/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
  stable/9/sys/cddl/dev/dtrace/i386/dtrace_subr.c
  stable/9/sys/kern/kern_tc.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
==============================================================================
--- stable/9/sys/cddl/dev/dtrace/amd64/dtrace_subr.c	Mon Dec 10 17:56:51 2012	(r244092)
+++ stable/9/sys/cddl/dev/dtrace/amd64/dtrace_subr.c	Mon Dec 10 19:33:39 2012	(r244093)
@@ -43,6 +43,8 @@
 extern uintptr_t 	dtrace_in_probe_addr;
 extern int		dtrace_in_probe;
 
+extern void dtrace_getnanotime(struct timespec *tsp);
+
 int dtrace_invop(uintptr_t, uintptr_t *, uintptr_t);
 
 typedef struct dtrace_invop_hdlr {
@@ -456,8 +458,11 @@ dtrace_gethrtime()
 uint64_t
 dtrace_gethrestime(void)
 {
-	printf("%s(%d): XXX\n",__func__,__LINE__);
-	return (0);
+	struct timespec current_time;
+
+	dtrace_getnanotime(&current_time);
+
+	return (current_time.tv_sec * 1000000000ULL + current_time.tv_nsec);
 }
 
 /* Function to handle DTrace traps during probes. See amd64/amd64/trap.c */

Modified: stable/9/sys/cddl/dev/dtrace/i386/dtrace_subr.c
==============================================================================
--- stable/9/sys/cddl/dev/dtrace/i386/dtrace_subr.c	Mon Dec 10 17:56:51 2012	(r244092)
+++ stable/9/sys/cddl/dev/dtrace/i386/dtrace_subr.c	Mon Dec 10 19:33:39 2012	(r244093)
@@ -45,6 +45,8 @@ extern uintptr_t 	kernelbase;
 extern uintptr_t 	dtrace_in_probe_addr;
 extern int		dtrace_in_probe;
 
+extern void dtrace_getnanotime(struct timespec *tsp);
+
 int dtrace_invop(uintptr_t, uintptr_t *, uintptr_t);
 
 typedef struct dtrace_invop_hdlr {
@@ -457,8 +459,11 @@ dtrace_gethrtime()
 uint64_t
 dtrace_gethrestime(void)
 {
-	printf("%s(%d): XXX\n",__func__,__LINE__);
-	return (0);
+	struct timespec current_time;
+
+	dtrace_getnanotime(&current_time);
+
+	return (current_time.tv_sec * 1000000000ULL + current_time.tv_nsec);
 }
 
 /* Function to handle DTrace traps during probes. See i386/i386/trap.c */

Modified: stable/9/sys/kern/kern_tc.c
==============================================================================
--- stable/9/sys/kern/kern_tc.c	Mon Dec 10 17:56:51 2012	(r244092)
+++ stable/9/sys/kern/kern_tc.c	Mon Dec 10 19:33:39 2012	(r244093)
@@ -110,6 +110,8 @@ SYSCTL_INT(_kern_timecounter, OID_AUTO, 
 static void tc_windup(void);
 static void cpu_tick_calibrate(int);
 
+void dtrace_getnanotime(struct timespec *tsp);
+
 static int
 sysctl_kern_boottime(SYSCTL_HANDLER_ARGS)
 {
@@ -303,6 +305,24 @@ getmicrotime(struct timeval *tvp)
 }
 
 /*
+ * This is a clone of getnanotime and used for walltimestamps.
+ * The dtrace_ prefix prevents fbt from creating probes for
+ * it so walltimestamp can be safely used in all fbt probes.
+ */
+void
+dtrace_getnanotime(struct timespec *tsp)
+{
+	struct timehands *th;
+	u_int gen;
+
+	do {
+		th = timehands;
+		gen = th->th_generation;
+		*tsp = th->th_nanotime;
+	} while (gen == 0 || gen != th->th_generation);
+}
+
+/*
  * Initialize a new timecounter and possibly use it.
  */
 void



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