Date: Tue, 6 Jun 2006 23:30:44 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 98707 for review Message-ID: <200606062330.k56NUiSJ042723@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=98707 Change 98707 by jb@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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606062330.k56NUiSJ042723>