Bug 3233 - nanosecond timers
Summary: nanosecond timers
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: runtime (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Josh Stone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-20 16:10 UTC by Frank Ch. Eigler
Modified: 2006-09-20 21:23 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.