vote up 1 vote down star
1

Hi

I am looking for a command to check for on-chip L3 cache size on a unix system.

Thanks Bi

flag
what happens if some people vote for belongs on serverfault, and others vote for belongs on superuser? – mgb Aug 5 at 23:41
Majority rule, I believe... – dmckee Aug 5 at 23:42
4  
@mgb: that comment belongs on meta ;) – Jimmy Aug 5 at 23:42
It occured to me as I was voting to move it to superuser. – mgb Aug 7 at 20:09

migrated from stackoverflow.com

4 Answers

vote up 1 vote down

look at '/proc/cpuinfo'

link|flag
Doesnt help - here is the output of the command: processor : 7 vendor : GenuineIntel arch : IA-64 family : Itanium 2 model : 2 revision : 1 archrev : 0 features : branchlong cpu number : 0 cpu regs : 4 cpu MHz : 1500.000000 itc MHz : 1500.000000 BogoMIPS : 2239.75 siblings : 1 – Bi Aug 5 at 23:42
Also procfs is a Linux (not UNIX) thing and FreeBSD for example only has it with the Linux-compat installed. – Johannes Rössel Aug 6 at 0:31
I thought it was a Unix thing, it's been 10 years since I last worked with commercial Unix (I miss Sun). On my Pentium and Core Duo it tells you cache. On an Itanium you probably have to pay extra to find it ;-) – mgb Aug 7 at 20:12
vote up 1 vote down

Take a look at dmidecode, which has an excellent man page.

Look for an entry named "Processor Information", mine reads:

Handle 0x0004, DMI type 4, 35 bytes
Processor Information
    ...
    L1 Cache Handle: 0x0008
    L2 Cache Handle: 0x0009
    L3 Cache Handle: Not Provided
    ...

This tells me to look for the handle 0x0009 (for L2 cache, since I don't have any L3). This reads:

Handle 0x0009, DMI type 7, 19 bytes
Cache Information
    Socket Designation: L2 Cache
    Configuration: Enabled, Socketed, Level 2
    Operational Mode: Write Back
    Location: External
    Installed Size: 2048 KB
    Maximum Size: 2048 KB
    Supported SRAM Types:
    	Burst
    	Pipeline Burst
    	Asynchronous
    Installed SRAM Type: Burst
    Speed: Unknown
    Error Correction Type: Unknown
    System Type: Unknown
    Associativity: Unknown
link|flag
vote up 0 vote down

If all else fails, just use /proc/cpuinfo or any other method to find the model number of your processor, and look that up on google to find the specs.

link|flag
vote up 0 vote down

On recent Linux kernels running on the x86 architecture, you can probably find the information you want at /sys/devices/system/cpu/cpu#/cache (replace the # by the CPU number). For instance, on this computer (which does not have a L3 cache):

$ cat /sys/devices/system/cpu/cpu0/cache/index0/level 
1
$ cat /sys/devices/system/cpu/cpu0/cache/index0/type 
Data
$ cat /sys/devices/system/cpu/cpu0/cache/index0/size 
64K
$ cat /sys/devices/system/cpu/cpu0/cache/index1/level
1
$ cat /sys/devices/system/cpu/cpu0/cache/index1/type 
Instruction
$ cat /sys/devices/system/cpu/cpu0/cache/index1/size 
64K
$ cat /sys/devices/system/cpu/cpu0/cache/index2/level 
2
$ cat /sys/devices/system/cpu/cpu0/cache/index2/type 
Unified
$ cat /sys/devices/system/cpu/cpu0/cache/index2/size 
512K

This corresponds to a L1 data cache of 64K, a L1 instruction cache of 64K, and a L2 instruction+data cache of 512K. Note that this is more detailed than /proc/cpuinfo, which only says cache size : 512 KB. There are several other files in these cache/index# directories with even more detail.

Please read Documentation/ABI/README and Documentation/ABI/testing/sysfs-devices-system-cpu before using these files; in particular, they do not seem to be a stable ABI, and thus might become missing in the future. They come from arch/x86/kernel/cpu/intel_cacheinfo.c, which uses cpuid to directly get the information (meaning that, when present, they should be more reliable than dmidecode).

link|flag

Your Answer

Get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.