wrong bogomips values with kernel 2.6.16
Hi everybody!
System: AOpen i915GMm-HFS motherboard, kernel 2.6.16
CPU: Intel(R) Pentium(R) M processor 1.86GHz stepping 08
During startup a BogoMips value of 3730.21 is calculated. That should be the correct value for the cpu running at full speed. But:
"cat /proc/cpuinfo" on the idle system displays the correct cpu speed, but a wrong bogomips value:
cpu MHz : 800.000
bogomips : 3730.21
"cat /proc/cpuinfo" on the busy system displays the correct cpu speed too, but again a wrong bogomips value:
cpu MHz : 1867.000
bogomips : 8705.38
The relevant snippets from .config:
CONFIG_X86_PC=yCONFIG_MPENTIUMM=y
CONFIG_CPU_FREQ=yCONFIG_CPU_FREQ_TABLE=yCONFIG_CPU_FREQ_DEBUG=yCONFIG_CPU_FREQ_STAT=yCONFIG_CPU_FREQ_STAT_DETAILS=yCONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=yCONFIG_CPU_FREQ_GOV_PERFORMANCE=yCONFIG_CPU_FREQ_GOV_POWERSAVE=yCONFIG_CPU_FREQ_GOV_USERSPACE=yCONFIG_CPU_FREQ_GOV_ONDEMAND=yCONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
CONFIG_X86_ACPI_CPUFREQ=yCONFIG_X86_SPEEDSTEP_CENTRINO=yCONFIG_X86_SPEEDSTEP_CENTRINO_ACPI=y
cu,
knut
Quoted 6 lines · Knut Petersen
System: AOpen i915GMm-HFS motherboard, kernel 2.6.16
CPU: Intel(R) Pentium(R) M processor 1.86GHz stepping 08During startup a BogoMips value of 3730.21 is calculated. That should be the correct value for the cpu running at full speed.
That sounds correct. On x86, BogoMips these days is just a measure of how fast the timestamp counter goes (multiplied by two for totally bogus reasons), and a Pentium-M should have a fixed-frequency TSC that ticks at the highest possible frequency of the CPU, regardless of what the real frequency is.
So your BogoMips of 3730 sounds correct.
Quoted 7 lines
But:
"cat
/proc/cpuinfo" on the idle system displays the correct cpu speed, but a wrong bogomips value:cpu MHz : 800.000 bogomips : 3730.21
No, this is the _right_ bogomips value. Since the TSC is fixed-frequency, bogomips doesn't change with CPU frequency.
Quoted 5 lines
"cat
/proc/cpuinfo" on the busy system displays the correct cpu speed too, but again a wrong bogomips value:cpu MHz : 1867.000 bogomips : 8705.38
Yeah, looks like cpufreq has (totally incorrectly) scaled up the bogomips value.
The scaling up should actually happen if the TSC runs at core speed _or_ if bogomips is calculated using the old "decl + jne" loop. So I guess somebody "fixed" a bug that was a bug on such systems, and broke systems with a proper fixed-frequency TSC.
DaveJ, does this ring any bells?
Linus
Quoted 4 lines · Linus Torvalds
That sounds correct. On x86, BogoMips these days is just a measure of how fast the timestamp counter goes (multiplied by two for totally bogus reasons), and a Pentium-M should have a fixed-frequency TSC that ticks at the highest possible frequency of the CPU, regardless of what the real frequency is.
Pentium 4 and Xeon model 3 and above increment the time stamp counter at a constant rate independent of the current cpu frequency.
All Pentium M, Xeon up to model 2 and the P6 family increment with every internal processor cycle.
This behaviour is documented in chapter 18.8 of IA-32 Intel® Architecture Software Developer’s Manual, Volume 3B: System Programming Guide, Part 2, Order Number: 253669-018, January 2006.
Because of your false assumption of a fixed-frequency TSC, your conclusions are false too. Scaling of the bogomips values should really happen, but the start value is wrong. For 800 MHz there should be a bogomips value of about 1598, for 1867 MHz a value of about 3730.
You asked for a full /proc/cpuinfo, here it is ...
processor : 0vendor_id : GenuineIntel
cpu family : 6
model : 13
model name : Intel(R) Pentium(R) M processor 1.86GHz
stepping : 8
cpu MHz : 800.000
cache size : 2048 KBfdiv_bug : nohlt_bug : nof00f_bug : nocoma_bug : no
fpu : yesfpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss tmpbe nx est tm2 bogomips : 3730.27
cu,
Knut
Quoted 3 lines · Knut Petersen
All Pentium M, Xeon up to model 2 and the P6 family increment with every internal processor cycle.
Just to humor me. Try the bogomips loop in user space with something like the appended (make sure the frequency is fixed to the lowest frequency).
Linus
---
#include <stdio.h>
#include <sys/time.h>
#define read_tsc(r) asm volatile("rdtsc":"=A" (r))
int main(int argc, char **argv)
{
struct timeval a;
unsigned long start, end;
unsigned long mhz, low;
gettimeofday(&a, NULL);
read_tsc(start);
for (;;) {
unsigned long usec;
struct timeval b;
gettimeofday(&b, NULL);
usec = (b.tv_sec - a.tv_sec)*1000000;
usec += b.tv_usec - a.tv_usec;
if (usec >= 1000000)
break;
}
read_tsc(end);
end -= start;
mhz = end / 1000000;
low = end % 1000000;
printf("TSC: %lu.%06lu MHz\n", mhz, low);
return 0;
}Quoted 13 lines · Linus Torvalds
Quoted 4 lines · Knut Petersen
All Pentium M, Xeon up to model 2 and the P6 family increment with every internal processor cycle.
Just to humor me. Try the bogomips loop in user space with something like the appended (make sure the frequency is fixed to the lowest frequency).
Linus
No problem ...
linux:~ # cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies 1867000 1600000 1333000 1067000 800000
linux:~ # echo 800000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed;cat /proc/cpuinfo;./test
processor : 0vendor_id : GenuineIntel
cpu family : 6
model : 13
model name : Intel(R) Pentium(R) M processor 1.86GHz
stepping : 8
cpu MHz : 800.000
cache size : 2048 KBfdiv_bug : nohlt_bug : nof00f_bug : nocoma_bug : no
fpu : yesfpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss tmpbe nx est tm2
bogomips : 3730.27
TSC: 798.307872 MHz
linux:~ # echo 1067000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed;cat /proc/cpuinfo;./test
processor : 0vendor_id : GenuineIntel
cpu family : 6
model : 13
model name : Intel(R) Pentium(R) M processor 1.86GHz
stepping : 8
cpu MHz : 1067.000
cache size : 2048 KBfdiv_bug : nohlt_bug : nof00f_bug : nocoma_bug : no
fpu : yesfpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss tmpbe nx est tm2
bogomips : 4975.25
TSC: 1064.407897 MHz
linux:~ # echo 1333000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed;cat /proc/cpuinfo;./test
processor : 0vendor_id : GenuineIntel
cpu family : 6
model : 13
model name : Intel(R) Pentium(R) M processor 1.86GHz
stepping : 8
cpu MHz : 1333.000
cache size : 2048 KBfdiv_bug : nohlt_bug : nof00f_bug : nocoma_bug : no
fpu : yesfpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss tmpbe nx est tm2
bogomips : 6215.57
TSC: 1330.511688 MHz
linux:~ # echo 1600000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed;cat /proc/cpuinfo;./test
processor : 0vendor_id : GenuineIntel
cpu family : 6
model : 13
model name : Intel(R) Pentium(R) M processor 1.86GHz
stepping : 8
cpu MHz : 1600.000
cache size : 2048 KBfdiv_bug : nohlt_bug : nof00f_bug : nocoma_bug : no
fpu : yesfpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss tmpbe nx est tm2
bogomips : 7460.55
TSC: 1596.612533 MHz
linux:~ # echo 1867000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed;cat /proc/cpuinfo;./test
processor : 0vendor_id : GenuineIntel
cpu family : 6
model : 13
model name : Intel(R) Pentium(R) M processor 1.86GHz
stepping : 8
cpu MHz : 1867.000
cache size : 2048 KBfdiv_bug : nohlt_bug : nof00f_bug : nocoma_bug : no
fpu : yesfpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss tmpbe nx est tm2
bogomips : 8705.53
TSC: 1862.715048 MHz
I tried kernel _2.6.15_ too - it´s even more broken:
linux:~ # cat /proc/cpuinfo;./test
processor : 0vendor_id : GenuineIntel
cpu family : 6
model : 13
model name : Intel(R) Pentium(R) M processor 1.86GHz
stepping : 8
cpu MHz : 4347.853
cache size : 2048 KBfdiv_bug : nohlt_bug : nof00f_bug : nocoma_bug : no
fpu : yesfpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss tmpbe nx est tm2
bogomips : 8702.35
TSC: 1863.086854 MHz
Isn´t that nice? I´m able to overclock my 1.86 MHz cpu to stable 4.35 MHz with just a passive heatsink ;-)))
cu,
Knut