Add support for walltimestamp in DTrace.

Submitted by:	Fabian Keil
MFC after:	2 weeks
This commit is contained in:
George V. Neville-Neil 2012-07-16 20:17:19 +00:00
parent 907e4524dc
commit 57d025c338
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=238537
3 changed files with 34 additions and 4 deletions

View file

@ -47,6 +47,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 {
@ -461,8 +463,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 * 1000000000UL + current_time.tv_nsec);
}
/* Function to handle DTrace traps during probes. See amd64/amd64/trap.c */

View file

@ -49,6 +49,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 {
@ -462,8 +464,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 * 1000000000UL + current_time.tv_nsec);
}
/* Function to handle DTrace traps during probes. See i386/i386/trap.c */

View file

@ -122,6 +122,8 @@ SYSCTL_INT(_kern_timecounter, OID_AUTO, stepwarnings, CTLFLAG_RW,
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)
{
@ -959,6 +961,24 @@ getmicrotime(struct timeval *tvp)
#endif /* FFCLOCK */
/*
* 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);
}
/*
* System clock currently providing time to the system. Modifiable via sysctl
* when the FFCLOCK option is defined.