This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: using get_cycles() to get the real elapsed time


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
between CPUs).

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.

Regards,
 -- Tim

=============================
Tim Bird
Architecture Group Chair, CE Linux Forum
Senior Staff Engineer, Sony Electronics
=============================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]