Re: [BUG] wrong bogomips values with kernel 2.6.16

Linus Torvalds
2006-03-22T15:30:26Z

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;
}