Linux View CPU cache (cache) information

Source: Internet
Author: User

One, Linux under View CPU cache series, each level size

grep Cache

The example results are as follows:

Second, see how the cache is associated

View the appropriate folder in the/sys/devices/system/cpu/

If you see how many groups are in the first-level cache of cpu0,

Cat /sys/devices/system/cpu/cpu0/cache/index0/number_of_sets
$64

such as viewing the number of rows in a group in the first-level cache of Cpu0

$Cat /sys/devices/system/cpu/cpu0/cache/index0/ways_of_associativity
$8

Third, check the size of the Cache_line

Above with my computer's CPU-level cache as an example to know the size of the CPU0 cache: 32k, which contains 64 (sets) groups, each group has 8 (ways), you can calculate the size of each of the means (cache_line) Cache_line = 32*1024/(64 *8) =64 bytes. Of course, we can also use the following command to find out the size of Cache_line

Cat /sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size

Or

Cat /proc/cpuinfo

processor:0
Vendor_id:genuineintel
CPU family:6
model:60
Model Name:intel (R) Core (TM) i7-4770k CP U @ 3.50GHz
Stepping:3
CPU mhz:3497.664
Cache size:8192 KB
Physical id:0
Siblings:8
Core ID: 0
CPU Cores:4
apicid:0
Initial apicid:0
Fpu:yes
Fpu_exception:yes
cpuid level:13
Wp:yes
Flags:fpu vme de PSE TSC MSR PAE MCE cx8 APIC Sep MTRR PGE MCA cmov Pat PSE36 clflush DTS ACPI MMX FXSR SSE SSE2 SS HT TM PBE Syscall NX PDPE1GB rdtscp lm constant_tsc Arch_perfmon pebs BTS rep_good xtopology tsc_reliable nonstop_tsc aper Fmperf PNI pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 FMA cx16 xtpr pdcm sse4_1 sse4_2 movbe popcnt AES Xsave AVX L Ahf_lm ABM Ida Arat Tpr_shadow vnmi flexpriority ept vpid
bogomips:6995.32
Clflush size:64
cache_alignment:64
Address sizes:39 bits physical, bits virtual

Knowing the cache information for the CPU will help you when writing an efficient program.

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.