Re: RDTSC (was Re: FreeBSD & Linux)

Keith Owens (kaos@ocs.com.au)
Tue, 10 Nov 1998 10:12:15 +1200


On Mon, 9 Nov 1998 09:45:52 +0000 (GMT),
Tigran Aivazian <tigran@sco.COM> wrote:
>You wrote:
>> ps: anyone have a better inline asm for rdtsc?
>
>Sure thing! (I stole it from somewhere - can't remember):
>
>#define get_profiler_timestamp() \

"Stolen" from IKD patches. Better version is

+#define get_profiler_timestamp() \
+ ( { \
+ register u64 __res; \
+ if (boot_cpu_data.x86_capability & 0x10) { \
+ __asm__ __volatile__( \
+ "rdtsc" : "=A"(__res) \
+ ); \
+ } \
+ else { \
+ /* no rdtsc, use jiffies instead */ \
+ __res = jiffies; \
+ } \
+ __res; \
+ } )

Just in case you run on a machine without rdtsc.

-
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/