Re: [ck] Re: [announce] [patch] Voluntary Kernel Preemption Patch

Ingo Molnar
2004-07-11T20:17:00Z

* Ingo Molnar <mingo@elte.hu> wrote:

> it was reporting more accurate latencies, except that there were
> strange spikes of latencies. It turned out that for whatever reason,
> userspace RDTSC is not always reliable on my box (!).
>
> I've attached two fixes against latencytest - one makes rdtsc
> timestamps more reliable, the other one fixes an SMP bug in the kernel
> module (it would lock up under SMP otherwise.).

> static inline unsigned long long int rdtsc(void)
> {
> - unsigned long long int x;
> - __asm__ volatile ("rdtsc" : "=A" (x));
> - return x;
> + unsigned long long int x, y;
> + for (;;) {
> + __asm__ volatile ("rdtsc" : "=A" (x));
> + __asm__ volatile ("rdtsc" : "=A" (y));
> + if (y - x < 1000)
> + return y;
> + }
> }

the same fix should be done to latencytest0.42 too.

Ingo