get_cyles()

Zwane Mwaikambo zwane at arm.linux.org.uk
Fri Jun 3 05:42:44 EST 2005


On Thu, 2 Jun 2005, Shirley Ma wrote:

> Doesn't ppc64 supports get_cycles() correctly?
> I used below function to get_cycles(), it seems not right.
> 
> t1 = get_cycles();
> t2 = get_cycles();
> 
> t2-t1 is huge.
> 
> static inline cycles_t get_cycles(void)
> {
>         cycles_t ret;
> 
>         __asm__ __volatile__("mftb %0" : "=r" (ret) : );
>         return ret;
> }

Conjecture: Timebase is 33MHz (so it's slow compared to processor 
instruction retiring), there is a very small gap between t2 and t1 
sampling time delta wise and it may go backwards(?). What are the actual 
numbers?

	Zwane



More information about the Linuxppc64-dev mailing list