【问题标题】:different CPU cache size reported by /sys/device/ and dmidecode/sys/device/ 和 dmidecode 报告的不同 CPU 缓存大小
【发布时间】:2013-12-18 07:00:04
【问题描述】:

我正在尝试获取系统中不同缓存级别的大小。

我尝试了两种技术。

a) 使用来自 /sys/device 的信息。这是输出。

$ cat /sys/devices/system/cpu/cpu0/cache/index1/size
32K
$ cat /sys/devices/system/cpu/cpu0/cache/index2/size
256K
$ cat /sys/devices/system/cpu/cpu0/cache/index3/size
8192K

b) 使用来自 dmidecode 的信息

$ sudo dmidecode -t cache
Cache Information
    Socket Designation: CPU Internal L1
    Configuration: Enabled, Not Socketed, Level 1
    Operational Mode: Write Through
    Location: Internal
    Installed Size: 256 KB
    Maximum Size: 256 KB
        < .... >
Cache Information
    Socket Designation: CPU Internal L2
    Configuration: Enabled, Not Socketed, Level 2
    Operational Mode: Write Through
    Location: Internal
    Installed Size: 1024 KB
    Maximum Size: 1024 KB
        < .... >
Cache Information
    Socket Designation: CPU Internal L3
    Configuration: Enabled, Not Socketed, Level 3
    Operational Mode: Write Back
    Location: Internal
    Installed Size: 8192 KB
    Maximum Size: 8192 KB
        < .... >

L2 和 L3 缓存报告的大小不同。关于 a) 为什么会出现这种差异的任何想法? b) 哪种方法给出了正确的值?

其他相关信息:

$uname -a
Linux 3.0.0-14-generic #23somerville3-Ubuntu SMP Mon Dec 12 09:20:18 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

cat /proc/cpuinfo 
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 58
model name  : Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
stepping    : 9
cpu MHz     : 2400.000
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 rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 x2apic popcnt aes xsave avx f16c rdrand lahf_lm ida arat epb xsaveopt pln pts dts tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms
bogomips    : 6784.23
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:
< ... >

【问题讨论】:

    标签: linux caching


    【解决方案1】:

    一些事情:

    1. 你有一个四核 CPU
    2. /sys/devices/system/cpu/cpu&lt;n&gt;/cache 中的 index&lt;n&gt; 名称与 L1/L2/L3 等不对应。有一个 .../index&lt;n&gt;/level 文件会告诉您缓存的级别。
    3. 您的 L1 缓存分为两个缓存(可能是 index0index1),一个用于数据,另一个用于指令(请参阅 .../index&lt;n&gt;/type),每个内核。 4 核 * 2 半 * 32K 与 dmidecode 报告的 256K 匹配。
    4. L2 高速缓存按内核拆分。 4 核 * 256K(来自index2)= 1024K,与dmidecodes L2 编号匹配。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-02
      • 2017-12-18
      • 1970-01-01
      相关资源
      最近更新 更多