cpuid命令显示的信息有问题

Problem with the information displayed by the cpuid command

在linux上使用cpuid command显示的llc缓存信息为:

  --- cache 3 ---
      cache type                           = unified cache (3)
      cache level                          = 0x3 (3)
      self-initializing cache level        = true
      fully associative cache              = false
      extra threads sharing this cache     = 0x1f (31)
      extra processor cores on this die    = 0xf (15)
      system coherency line size           = 0x3f (63)
      physical line partitions             = 0x0 (0)
      ways of associativity                = 0x13 (19)
      ways of associativity                = 0x6 (6)
      WBINVD/INVD behavior on lower caches = false
      inclusive to lower caches            = true
      complex cache indexing               = true
      number of sets - 1 (s)               = 24575

为什么有两个ways of associativity?它在 /sys/devices/system/cpu/cpu0/cache/index3/number_of_sets 文件中显示 20? 20是LLC的关联度吗? ways of associativity = 0x6 (6) 在这里显示什么?如何区分每个分片有多少个缓存集?谢谢。

我正在使用服务器。版本为:Linux version 4.15.0-122-generic (buildd@lcy01-amd64-010) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12)) #124~16.04.1-Ubuntu SMP.

cpu的信息是

Architecture: x86_64
 CPU operating mode: 32-bit, 64-bit
 Byte Order: Little Endian
 CPU(s): 48
 On-line CPU(s) list: 0-47
 Number of threads per core: 2
 Number of audits per seat: 12
 Socket(s): 2
 NUMA nodes: 2
 Vendor ID: GenuineIntel
 CPU series: 6
 Model: 79
 Model name: Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz
 Step: 1
 CPU MHz: 2500.119
 CPU max MHz: 2900.0000
 CPU min MHz: 1200.0000
 BogoMIPS: 4401.87
 Virtualization: VT-x
 L1d cache: 32K
 L1i cache: 32K
 L2 cache: 256K
 L3 cache: 30720K
 NUMA node0 CPU(s): 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42 ,44,46
 NUMA node1 CPU(s): 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43 ,45,47

使用 Linux 给你的其他号码:

size = bytes_per_line * sets * associativity
30720 KiB = 64 * 24576 * associativity
30720 KiB = 1536 KiB * associativity
30720 KiB / 1536 KiB = associativity
20 = associativity

使用 https://ark.intel.com/content/www/us/en/ark/products/91767/intel-xeon-processor-e5-2650-v4-30m-cache-2-20-ghz.html and https://en.wikichip.org/wiki/intel/microarchitectures/broadwell_(client) 中的信息进行检查;这些来源表明,12 个内核中的每个内核都有 2.5 MiB 的(20 路关联)L3 缓存,通过一种环形总线连接(为芯片提供总共 30 MiB 的 L3 缓存)。

将其用作“双重检查现实”,我假设显示的两种“关联性方式”值都是错误的;并且第一个(“关联性方式= 19”)可能正在显示“关联性 - 1”(类似于他们懒得将 1 添加到“集合数 - 1”的方式)而没有这么说(没有说“方式”结合性 - 1 = 19")。我不知道第二个“关联性方式 = 6”从何而来(该芯片对共享 TLB 使用“6 向关联”,所以它可能显示在错误的位置)。

请注意,您有 2 个芯片(在 2 个插槽中),以上所有都是“每个芯片”(它是两个独立的 30 MiB 组的 L3 缓存)。

cpuid 版本 20150606 直到并包括 20170122 有一个错误,即在解码 CPUID 叶 0x4 缓存信息时缓存路数打印两次。第二次使用寄存器 EDX 中的值,它实际上编码了不同的信息片段(参见 manual)。该值在您的处理器上以二进制表示为 110。

cpuid 20200120 之前的版本错误地显示了“关联方式”而不是“关联方式 - 1”。一些 CPUID 信息被编码为实际数字减一,因为编码相同范围的正整数需要少一位。

cpuid 版本 20200211 开始,该工具的作者改变了主意,决定让该工具自动加一比显示原始值更好。因此,在这些版本中,您的处理器将获得以下输出:

ways of associativity                = 0x14 (20)
.
.
.
number of sets (s)                   = 24576

您可以在 tool's website 上跟踪对 cpuid 工具的更改。顺便说一句,旧版本有很多错误。

在某些情况下,处理器本身提供的CPUID信息是不正确的。通常当不同官方来源之间存在不一致时,至少有一个是错误的。您的处理器的 CPUID 信息是正确的。