Bug 3233

Summary: nanosecond timers
Product: systemtap Reporter: Frank Ch. Eigler <fche>
Component: runtimeAssignee: Josh Stone <jistone>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

Description Frank Ch. Eigler 2006-09-20 16:10:51 UTC
systemtap has been requested to implement a gettimeofday_ns
call.  To do this with the current code, src/runtime/time.c
would need to change.  

It may be sufficient to change _stp_time_init to preserve
cpufreq_get() (a kilohertz number ?) rather than dividing it
to store only a megahertz figure, and to rename _stp_gettimeofday_us
to _stp_gettimeofday_ns.  The tapset callers would of course have to
adapt too.
Comment 1 Josh Stone 2006-09-20 21:23:30 UTC
Committed.

I did the kHz change, but that actually takes the units the wrong direction. 
Before, we did cycles/MHz = cycles/(cycles/usec) = usec.  With kHz, you have
cycles/kHz = cycles/(cycles/msec) = msec.  Thus, a 1E6 adjustment is needed,
best before the division.

    cycles * (1E6 nsec/msec) / (cycles/msec) = nsec

So, I was using MHz because it conveniently led to microseconds.  To
conveniently divide to nanoseconds we would need to use GHz, but with integers
that is too imprecise.  So now we're keeping kHz, and we can deal with an extra
multiply.