public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [BUG] wrong bogomips  values with kernel 2.6.16
@ 2006-03-21 13:10 Knut Petersen
  2006-03-21 18:10 ` Linus Torvalds
  0 siblings, 1 reply; 5+ messages in thread
From: Knut Petersen @ 2006-03-21 13:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrew Morton, Linus Torvalds

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=y
CONFIG_MPENTIUMM=y

CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_TABLE=y
CONFIG_CPU_FREQ_DEBUG=y
CONFIG_CPU_FREQ_STAT=y
CONFIG_CPU_FREQ_STAT_DETAILS=y
CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=y
CONFIG_CPU_FREQ_GOV_USERSPACE=y
CONFIG_CPU_FREQ_GOV_ONDEMAND=y
CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y

CONFIG_X86_ACPI_CPUFREQ=y
CONFIG_X86_SPEEDSTEP_CENTRINO=y
CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI=y

cu,
 knut


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] wrong bogomips  values with kernel 2.6.16
  2006-03-21 13:10 [BUG] wrong bogomips values with kernel 2.6.16 Knut Petersen
@ 2006-03-21 18:10 ` Linus Torvalds
  2006-03-22  5:19   ` Knut Petersen
  0 siblings, 1 reply; 5+ messages in thread
From: Linus Torvalds @ 2006-03-21 18:10 UTC (permalink / raw)
  To: Knut Petersen, Dave Jones; +Cc: Linux Kernel Mailing List, Andrew Morton



On Tue, 21 Mar 2006, Knut Petersen wrote:
> 
> 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.

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.

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

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] wrong bogomips  values with kernel 2.6.16
  2006-03-21 18:10 ` Linus Torvalds
@ 2006-03-22  5:19   ` Knut Petersen
  2006-03-22 15:30     ` Linus Torvalds
  0 siblings, 1 reply; 5+ messages in thread
From: Knut Petersen @ 2006-03-22  5:19 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Dave Jones, Linux Kernel Mailing List, Andrew Morton

Linus Torvalds schrieb:

>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 : 0
vendor_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 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 apic sep mtrr pge mca cmov 
pat clflush dts acpi mmx fxsr sse sse2 ss tmpbe nx est tm2
bogomips : 3730.27

cu,
Knut


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] wrong bogomips  values with kernel 2.6.16
  2006-03-22  5:19   ` Knut Petersen
@ 2006-03-22 15:30     ` Linus Torvalds
  2006-03-22 17:35       ` Knut Petersen
  0 siblings, 1 reply; 5+ messages in thread
From: Linus Torvalds @ 2006-03-22 15:30 UTC (permalink / raw)
  To: Knut Petersen; +Cc: Dave Jones, Linux Kernel Mailing List, Andrew Morton



On Wed, 22 Mar 2006, Knut Petersen wrote:
> 
> 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;
}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] wrong bogomips  values with kernel 2.6.16
  2006-03-22 15:30     ` Linus Torvalds
@ 2006-03-22 17:35       ` Knut Petersen
  0 siblings, 0 replies; 5+ messages in thread
From: Knut Petersen @ 2006-03-22 17:35 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Dave Jones, Linux Kernel Mailing List, Andrew Morton

Linus Torvalds wrote:

>On Wed, 22 Mar 2006, Knut Petersen wrote:
>  
>
>>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       : 0
vendor_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 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 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       : 0
vendor_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 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 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       : 0
vendor_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 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 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       : 0
vendor_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 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 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       : 0
vendor_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 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 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       : 0
vendor_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 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 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-03-22 17:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-21 13:10 [BUG] wrong bogomips values with kernel 2.6.16 Knut Petersen
2006-03-21 18:10 ` Linus Torvalds
2006-03-22  5:19   ` Knut Petersen
2006-03-22 15:30     ` Linus Torvalds
2006-03-22 17:35       ` Knut Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox