Linux-2.6 TSC accuracy

From: Udo A. Steinberg
Date: Fri Jan 23 2004 - 17:19:31 EST



Hi,

I'm experiencing strange TSC effects on my laptop running 2.6.1. I expect the
following program to output something roughly equivalent to the CPU frequency.
It works fine on my desktop machine (outputting 807 MHz under 2.6.1), however
on my laptop it varies between 45 and 55 MHz (should be ~1000 MHz). The machine
uses both ACPI and smi-speedstep. .config attached.

#include <stdio.h>
#include <unistd.h>

unsigned long long int rdtsc()
{
unsigned long long int val;
asm volatile ("rdtsc" : "=A"(val));
return val;
}

int main (void)
{
unsigned long long int start, stop;

start = rdtsc();
sleep (10);
stop = rdtsc();

printf ("%llu MHz\n", (stop - start) / 10000000);

return 0;
}

CPU information:

processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 8
model name : Pentium III (Coppermine)
stepping : 10
cpu MHz : 996.091
cache size : 256 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 mmx fxsr sse
bogomips : 1970.17

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
1000000

Attachment: .config
Description: Binary data

Attachment: pgp00000.pgp
Description: PGP signature