Skip to contentSkip to conversation

Output of L1,L2 and L3 cache sizes to /proc/cpuinfo

PATCH Martin.Knoblauch 5 participants 12 messages May 22, 2001 – May 23, 2001

lore
Share & tools
lore
#0 lore raw
Quoted 9 lines
Quoted 8 lines

Hi,

while trying to enhance a small hardware inventory script, I found that cpuinfo is missing the details of L1, L2 and L3 size, although they may be available at boot time. One could of cource grep them from "dmesg" output, but that may scroll away on long lived systems.

Quoted 4 lines

Any particular reason this needs to be done in the kernel, as opposed to having your script read /dev/cpu/*/cpuid?

-hpa

terse answer: probably the same reason as for most stuff in
/proc/cpuinfo :-)

Seriously, is there any kind of documentation on for the stuff you
mention? I am willing to learn. Isn't the cpuid just a kind of serialnumber? The one that caused the big flame wars when Intel introduced the concept? In any case, on my system(s) there seems to be no device behind those files. On some systems, there is even no "/dev/cpu" directory.

I agree in a way that the changes to processor.h are not neccessary -
unless other parts of the kernel are interested in those values. I probably should change that to make the thing easier to digest.

Martin

#1 lore raw
Quoted 10 lines · Martin.Knoblauch
Quoted 10 lines
Quoted 9 lines

Hi,

while trying to enhance a small hardware inventory script, I found that cpuinfo is missing the details of L1, L2 and L3 size, although they may be available at boot time. One could of cource grep them from "dmesg" output, but that may scroll away on long lived systems.

Quoted 8 lines
Quoted 4 lines

Any particular reason this needs to be done in the kernel, as opposed to having your script read /dev/cpu/*/cpuid?

-hpa

terse answer: probably the same reason as for most stuff in
/proc/cpuinfo :-)

After some checking, I could have made the answer a bit less terse:

- it would require that the kernel is compiled with cpuid [module] support
- not everybody may want enable this, just for getting one or two harmless numbers.
- you would need a utility with root permission to analyze the cpuid info. The
cahce info does not seem to be there in clear ascii.
- this limits my script to root users, or you need the setuid-bit on
the
utility. Not really good for security.
- the cpuid stuff is i386 specific [today]. So are my changes. But implementing
them for other architectures [if there is interest in the info] would
not
require to also implement the cpuid on other architectures. Which may
not make any
sense at all.

So, having the numbers in clear text in the cpuinfo file looks simpler
and safer to me, although reading /dev/cpu/*/cpuinfo maybe more versatile [on i386] - at some cost.

Question: are there any utilities or other uses for the cpuid device
today? Just interested. The kernel seems to work well without it.

Cheers
Martin

#2 lore raw
In reply to Martin.Knoblauch
Quoted 10 lines · Martin.Knoblauch
Quoted 10 lines
Quoted 9 lines

Hi,

while trying to enhance a small hardware inventory script, I found that cpuinfo is missing the details of L1, L2 and L3 size, although they may be available at boot time. One could of cource grep them from "dmesg" output, but that may scroll away on long lived systems.

Quoted 8 lines
Quoted 4 lines

Any particular reason this needs to be done in the kernel, as opposed to having your script read /dev/cpu/*/cpuid?

-hpa

terse answer: probably the same reason as for most stuff in
/proc/cpuinfo :-)

Terse but just plain wrong.

Most stuff in /proc/cpuinfo is either hard (under some set of circumstances) for userspace to obtain, or it is used by the kernel itself anyway.

-hpa

Signature · 3 lines
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt
#3 lore raw
In reply to Martin.Knoblauch
Quoted 7 lines · Martin.Knoblauch

After some checking, I could have made the answer a bit less terse:

- it would require that the kernel is compiled with cpuid [module] support
- not everybody may want enable this, just for getting one or two harmless numbers.

If so, then that's their problem. We're not here to solve the problem of stupid system administrators.

Quoted 3 lines

- you would need a utility with root permission to analyze the cpuid info. The
cahce info does not seem to be there in clear ascii.

Bullsh*t. /dev/cpu/%d/cpuid is supposed to be mode 444 (world readable.)

Quoted 3 lines

- this limits my script to root users, or you need the setuid-bit on
the
utility. Not really good for security.

See above.

Quoted 8 lines

- the cpuid stuff is i386 specific [today]. So are my changes. But implementing
them for other architectures [if there is interest in the info] would
not
require to also implement the cpuid on other architectures. Which may
not make any
sense at all.

Quoted 6 lines

So, having the numbers in clear text in the cpuinfo file looks simpler
and safer to me, although reading /dev/cpu/*/cpuinfo maybe more versatile [on i386] - at some cost.

Question: are there any utilities or other uses for the cpuid device
today? Just interested. The kernel seems to work well without it.

That is usually the case with devices -- the kernel doesn't care, why would it?

-hpa

Signature · 3 lines
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt
#4 lore raw
Quoted 5 lines
Quoted 3 lines

- you would need a utility with root permission to analyze the cpuid info. The
cahce info does not seem to be there in clear ascii.

Bullsh*t. /dev/cpu/%d/cpuid is supposed to be mode 444 (world readable.)

Yep. cpuid is not priviledged. There are almost no cases you would want it to be and no cpu support for that anyway.

You would need to be root to ident some non intel processors like the 486SLC where you need to do io port access to ports 0x22/23 (from memory)

#5 lore raw
In reply to Martin.Knoblauch
Quoted 5 lines · H. Peter Anvin
Quoted 3 lines · Martin.Knoblauch

After some checking, I could have made the answer a bit less terse:

Quoted 8 lines
Quoted 4 lines

- it would require that the kernel is compiled with cpuid [module] support
- not everybody may want enable this, just for getting one or two harmless numbers.

If so, then that's their problem. We're not here to solve the problem of stupid system administrators.

They may not be stupid, just mislead :-( When Intel created the "cpuid"
Feature some way along the P3 line, they gave a stupid reason for it and created a big public uproar. As silly as I think that was (on both sides), the term "cpuid" is tainted. Some people just fear it like hell. Anyway.

Quoted 6 lines
Quoted 3 lines

- you would need a utility with root permission to analyze the cpuid info. The
cahce info does not seem to be there in clear ascii.

Bullsh*t. /dev/cpu/%d/cpuid is supposed to be mode 444 (world readable.)

Thanks you :-) In any case, on my system (Suse 7.1) the files are mode
400.

Martin

#8 lore raw
In reply to Martin.Knoblauch
Quoted 11 lines · Martin Knoblauch
Quoted 4 lines

If so, then that's their problem. We're not here to solve the problem of stupid system administrators.

They may not be stupid, just mislead :-( When Intel created the "cpuid"
Feature some way along the P3 line, they gave a stupid reason for it and created a big public uproar. As silly as I think that was (on both sides), the term "cpuid" is tainted. Some people just fear it like hell. Anyway.

Ummm... CPUID has been around since the P5, and even if you have one with the serial-number feature, Linux disables it.

Quoted 10 lines
Quoted 6 lines
Quoted 3 lines

- you would need a utility with root permission to analyze the cpuid info. The
cahce info does not seem to be there in clear ascii.

Bullsh*t. /dev/cpu/%d/cpuid is supposed to be mode 444 (world readable.)

Thanks you :-) In any case, on my system (Suse 7.1) the files are mode
400.

It's pointless since you can execute CPUID directly in user space. The device is there just to support CPU selection in a multiprocessor system.

-hpa

#9 lore raw
Quoted 20 lines · H. Peter Anvin
Quoted 11 lines · Martin Knoblauch
Quoted 4 lines

If so, then that's their problem. We're not here to solve the problem of stupid system administrators.

They may not be stupid, just mislead :-( When Intel created the "cpuid"
Feature some way along the P3 line, they gave a stupid reason for it and created a big public uproar. As silly as I think that was (on both sides), the term "cpuid" is tainted. Some people just fear it like hell. Anyway.

Ummm... CPUID has been around since the P5, and even if you have one with the serial-number feature, Linux disables it.

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

- you would need a utility with root permission to analyze the cpuid info. The
cahce info does not seem to be there in clear ascii.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Bullsh*t. /dev/cpu/%d/cpuid is supposed to be mode 444 (world readable.)

Thanks you :-) In any case, on my system (Suse 7.1) the files are mode
400.

It's pointless since you can execute CPUID directly in user space. The

Yes. Recently I tried to transform whole cpuid code to a userspace utility. Not easy, not clean... but it worked.

Tomas

P.S.: but I still find the patch useful.

Quoted 1 line

device is there just to support CPU selection in a multiprocessor system.

#10 lore raw
Quoted 2 lines · Tomas Telensky

Yes. Recently I tried to transform whole cpuid code to a userspace utility. Not easy, not clean... but it worked.

See http://www.sourceforge.net/projects/x86info
or ftp://ftp.suse.com/pub/people/davej/x86info/

regards,

Dave.

Signature · 2 lines
| Dave Jones.        http://www.suse.de/~davej
| SuSE Labs
#6 lore raw
In reply to Martin Knoblauch
Quoted 5 lines · Martin Knoblauch

They may not be stupid, just mislead :-( When Intel created the "cpuid"
Feature some way along the P3 line, they gave a stupid reason for it and created a big public uproar. As silly as I think that was (on both sides), the term "cpuid" is tainted. Some people just fear it like hell. Anyway.

I think you are confusing the CPU serial number with CPUID which is not the same. CPUID instruction has been around since late 486en.

The P3 Serial number is still disabled by default in Linux, unless overridden with a boottime switch.

regards,

Davej.

Signature · 2 lines
| Dave Jones.        http://www.suse.de/~davej
| SuSE Labs
#7 lore raw
Quoted 12 lines · Dave Jones
Quoted 5 lines · Martin Knoblauch

They may not be stupid, just mislead :-( When Intel created the "cpuid"
Feature some way along the P3 line, they gave a stupid reason for it and created a big public uproar. As silly as I think that was (on both sides), the term "cpuid" is tainted. Some people just fear it like hell. Anyway.

I think you are confusing the CPU serial number with CPUID which is not the same. CPUID instruction has been around since late 486en.

seems I am being confused. If that happens to me :-) ....

Martin

Signature · 5 lines
------------------------------------------------------------------
Martin Knoblauch         |    email:  [email protected]
TeraPort GmbH            |    Phone:  +49-89-510857-309
C+ITS                    |    Fax:    +49-89-510857-111
http://www.teraport.de   |    Mobile: +49-170-4904759

begin:vcard
n:Knoblauch;Martin
tel;cell:+49-170-4904759 tel;fax:+49-89-510857-111 tel;work:+49-89-510857-309
x-mozilla-html:FALSE
url:http://www.teraport.de
org:TeraPort GmbH;C+ITS
adr:;;Garmischer Straße 4;München;Bayern;D-80339;Germany version:2.1 email;internet:[email protected] title:Senior System Engineer x-mozilla-cpt:;-7008
fn:Martin Knoblauch
end:vcard

#11 lore raw
In reply to Dave Jones
Quoted 9 lines · Dave Jones
Quoted 2 lines · Tomas Telensky

Yes. Recently I tried to transform whole cpuid code to a userspace utility. Not easy, not clean... but it worked.

See http://www.sourceforge.net/projects/x86info
or ftp://ftp.suse.com/pub/people/davej/x86info/

thanks for the pointer. Definitely gives some very interesting
information about ones x86 CPU. At least something to work on. The output for different CPU types is a bit incoherent, making it difficult to parse. That why I [still] think (yes I'm stubborn :-) that having the cache sizes in /proc/cpuinfo in one format is a good idea. The info is there, it is just the output. With the userland tool, you always may have discrepancies between the kernels view and the tools view.

But I agree, it does not *have* to go into the kernel.

Cheers
MArtin

Signature · 5 lines
------------------------------------------------------------------
Martin Knoblauch         |    email:  [email protected]
TeraPort GmbH            |    Phone:  +49-89-510857-309
C+ITS                    |    Fax:    +49-89-510857-111
http://www.teraport.de   |    Mobile: +49-170-4904759

begin:vcard
n:Knoblauch;Martin
tel;cell:+49-170-4904759 tel;fax:+49-89-510857-111 tel;work:+49-89-510857-309
x-mozilla-html:FALSE
url:http://www.teraport.de
org:TeraPort GmbH;C+ITS
adr:;;Garmischer Straße 4;München;Bayern;D-80339;Germany version:2.1 email;internet:[email protected] title:Senior System Engineer x-mozilla-cpt:;-7008
fn:Martin Knoblauch
end:vcard