Re: [patch] __volatile__ needed in get_cycles()?

Richard Henderson (rth@twiddle.net)
Mon, 29 Mar 1999 07:55:59 -0800


On Mon, Mar 29, 1999 at 01:56:40PM +0200, Andrea Arcangeli wrote:
> About the volatile thing the reason I thought it's not needed is that we
> care that rdtsc is run always at the same offset of code. We care only
> about the _delta_ between the two rdtsc. So basically I seen not using
> __volatile__ as a feature. Comments?

asm("rdtsc %0" : "=A"(start));
something;
asm("rdtsc %0" : "=A"(stop));

Since neither `start' nor `stop' is dependant on `something',
the compiler is justified in scheduling this as

asm("rdtsc %0" : "=A"(start));
asm("rdtsc %0" : "=A"(stop));
something;

or

something;
asm("rdtsc %0" : "=A"(start));
asm("rdtsc %0" : "=A"(stop));

which isn't quite what you wanted.

Adding the volatile makes the asm act as a scheduling barrier.

r~

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/