Small patch for 2.1.126: TSC counter in /proc/cpuinfo

Alberto Vignani (vignani@mail.tin.it)
Mon, 19 Oct 1998 01:50:18 +0200


Hi.

Now that we have (in 2.1.126) microsecond resolution in gettimeofday and
kernel-level TSC calibration, it would be useful for other programs
(e.g. dosemu) to know the CPU frequency without having to lose time
recalculating it in user mode.
So I propose this simple patch to replace the really unuseful bogomips
value with the TSC calculated frequency. However, should some program
use the bogomips value from /proc/cpuinfo (why?), the TSC could be just
added to the end instead of replacing bogomips.

Alberto

diff -urN linux126/arch/i386/kernel/setup.c linux/arch/i386/kernel/setup.c
--- linux126/arch/i386/kernel/setup.c Mon Oct 19 01:38:08 1998
+++ linux/arch/i386/kernel/setup.c Mon Oct 19 01:35:53 1998
@@ -81,6 +81,7 @@

extern int root_mountflags;
extern int _etext, _edata, _end;
+extern unsigned long cpu_hz;

/*
* This is set up by the setup-routine at boot-time
@@ -668,9 +669,14 @@
for ( i = 0 ; i < 32 ; i++ )
if ( c->x86_capability & (1 << i) )
p += sprintf(p, " %s", x86_cap_flags[i]);
- p += sprintf(p, "\nbogomips\t: %lu.%02lu\n\n",
+ if (c->x86_capability & X86_FEATURE_TSC) {
+ p += sprintf(p, "\ncpu_hz\t\t: %lu\n\n", cpu_hz);
+ }
+ else {
+ p += sprintf(p, "\nbogomips\t: %lu.%02lu\n\n",
(c->loops_per_sec+2500)/500000,
((c->loops_per_sec+2500)/5000) % 100);
+ }
}
return p - buffer;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/