Re: [RFC] [Patch 7/8] statistics infrastructure - exploitation prerequisite

From: Peter Chubb
Date: Tue May 16 2006 - 21:24:16 EST

Anrd> Am Wednesday 17 May 2006 00:36 schrieb Martin Peschke:
> Any other hints on how to replace my sched_clock() calls are welcome.
> (I want to measure elapsed times in units that are understandable to
> users without hardware manuals and calculator, such as milliseconds.)

Anrd> There are a number of APIs that allow you to get the time:

Anrd> - do_gettimeofday
Anrd> potentially slow, reliable TOD clock, microsecond resolution

Slow, not necessarily safe to call in IRQ context.

Anrd> - ktime_get_ts
Anrd> monotonic clock, nanosecond resolution

Actual resolution varies by platform, it may be as low as jiffy.

Anrd> - getnstimeofday
Anrd> reliable, nanosecond TOD clock

(which is only currently implemented with ns resolution on IA64 and
Sparc64, AFAIK)

Anrd> - xtime
Anrd> jiffie accurate TOD clock, with fast reads

Too coarse a resolution.

Anrd> - get_cycles
Anrd> highest supported resolution and accuracy, highly
Anrd> HW-specific behaviour, may overflow.

Not very usable on SMP if you want to measure across migration; may be
variable rate.

Dr Peter Chubb peterc AT ERTOS within National ICT Australia
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at