This is the mail archive of the
mailing list for the systemtap project.
Re: using get_cycles() to get the real elapsed time
- From: Tim Bird <tim dot bird at am dot sony dot com>
- To: Roland McGrath <roland at redhat dot com>
- Cc: fche at redhat dot com, Li Guanglei <guanglei at cn dot ibm dot com>, systemtap at sourceware dot org
- Date: Mon, 07 Aug 2006 12:11:02 -0700
- Subject: Re: using get_cycles() to get the real elapsed time
- References: <20060806205111.AAF9218007E@magilla.sf.frob.com>
Roland McGrath wrote:
> sched_clock is used by the scheduler and POSIX CPU clocks/timers, which
> have the same requirements of being accurate and cheap. It returns ns.
> It can be called from interrupt level. Its implementation is already
> hardware-specific and is get_cycles with appropriate adjustments or
> something else with nice properties for the particular hardware.
> I think this is in all likelihood the best interface to use, if the
> hrtimer stuff is not.
Here's my 2 cents...
sched_clock was recommended to me for use in KFT early in the
2.6 series by Andi Kleen. It is used by both KFT and printk times,
and has worked out very well for me. To be honest, however, neither
printk times or KFT strives for absolute perfection in the timings.
A little slop here or there is no big deal. (Especially variability
Some platforms don't support sched_clock() very well, giving
only jiffy resolution. But when I run across such circumstances I
can usually ask one of the semiconductor vendors to fix it (or just
fix it myself.)
Overall, sched_clock() is way better than get_cycles(), and usually
not very much more expensive.
Architecture Group Chair, CE Linux Forum
Senior Staff Engineer, Sony Electronics