CPU cache query tool in Linux

Source: Internet
Author: User

CPU cache query tool in Linux

In Linux, you can use the following tool to query the CPU cache:

Method 1:

$ Lscpu

L1d cache: 32 K <span style = "white-space: pre"> </span> (level-1 data cache) L1i cache: 32 K <span style = "white-space: pre "> </span> <span style =" font-family: Arial, Helvetica, sans-serif; "> (level-1 Instruction cache) </span> L2 cache: 256 K <span style = "white-space: pre"> </span> (second-level cache) L3 cache: 8192 K <span style = "white-space: pre "> </span> (level 3 cache)

Method 2:

$ cat /sys/devices/system/cpu/cpu0/cache/index0/size32K
$ cat /sys/devices/system/cpu/cpu0/cache/index0/level 1
$ cat /sys/devices/system/cpu/cpu0/cache/index1/size32K
$ cat /sys/devices/system/cpu/cpu0/cache/index1/level 1
$ cat /sys/devices/system/cpu/cpu0/cache/index2/size256K
$ cat /sys/devices/system/cpu/cpu0/cache/index2/level 2
$ Cat/sys/devices/system/cpu/cpu0/cache/index3/size8192K
$ cat /sys/devices/system/cpu/cpu0/cache/index3/level3 
Method 3:
$ sudo dmidecode -t cache
However, there is a way out from the above results. The displayed L1 cache is 1024 kB, And the L2 cache is kB. The 8-core cache is not consistent with the implementation.

The program may be faulty. We do not recommend using dmidecode.

# dmidecode 2.12SMBIOS 2.7 present.Handle 0x003B, DMI type 7, 19 bytesCache InformationSocket Designation: CPU Internal L1Configuration: Enabled, Not Socketed, Level 1Operational Mode: Write BackLocation: InternalInstalled Size: 256 kBMaximum Size: 256 kBHandle 0x003C, DMI type 7, 19 bytesCache InformationSocket Designation: CPU Internal L2Configuration: Enabled, Not Socketed, Level 2Operational Mode: Write BackLocation: InternalInstalled Size: 1024 kBMaximum Size: 1024 kBHandle 0x003D, DMI type 7, 19 bytesCache InformationSocket Designation: CPU Internal L3Configuration: Enabled, Not Socketed, Level 3Operational Mode: Write BackLocation: InternalInstalled Size: 8192 kBMaximum Size: 8192 kB
Method 4:

$ Cat/proc/cpuinfo

cache size: 8192 KB

This only shows the size of the L3 cache, which is not accurate.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.