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

Alberto Vignani (a.vignani@flashnet.it)
Tue, 20 Oct 1998 21:52:04 +0200


On Mon, 19 Oct 1998 Rafael Reilova <rreilova@ececs.uc.edu> wrote:

>On Mon, 19 Oct 1998, Alberto Vignani wrote:
>
>> 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.
>>
>
>Wouldn't it make more sense to print it out in MHz, perhaps something
>like:
>
> p += sprintf(p, "\ncpu MHz\t\t: %lu.%02lu\n\n",
> cpu_hz / 1000000, (cpu_hz % 1000000) / 10000);
>
>

The point is not to have a nice visual display but to pass a value to
user-level programs (dosemu, in my case), so they don't need anymore to
recalculate the value themselves. As such, it is important to have ALL
the digits.

>PS. The Jumbo patch for 2.0.x has been doing this for some time now.
>Although Andre Balsa decided to append the MHz rating to the model string.

Good. We could do the same, it doesn't really matter where the value is
located in /proc/cpuinfo.

We could reach a compromise this way:

diff -ur linux.126pre2/arch/i386/kernel/setup.c /linux/arch/i386/kernel/setup.c
--- linux.126pre2/arch/i386/kernel/setup.c Tue Oct 20 21:25:32 1998
+++ /linux/arch/i386/kernel/setup.c Tue Oct 20 20:22:43 1998
@@ -80,6 +80,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
@@ -638,6 +639,11 @@
p += sprintf(p, "stepping\t: %d\n", c->x86_mask);
else
p += sprintf(p, "stepping\t: unknown\n");
+
+ if (c->x86_capability & X86_FEATURE_TSC) {
+ p += sprintf(p, "cpu MHz\t\t: %lu.%06lu\n",
+ cpu_hz / 1000000, (cpu_hz % 1000000));
+ }

/* Cache size */
if (c->x86_cache_size >= 0)

Alberto

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