linux 怎么看自己cache info
到如下:
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache# pwd
/sys/devices/system/cpu/cpu0/cache
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache# ls -a
. .. index0 index1 index2 index3 power uevent
依次解读一下如下信息:
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index0# cat type
Data
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index0# cat level
1
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index0# cat ways_of_associativity
8
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index0# cat shared_cpu_map
00000000,00000001
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index0# cat size
32K
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index0# cat number_of_sets
64
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index0# cat coherency_line_size
64
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index0# cat uevent
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index0# cat physical_line_partition
1
其实看上面的输出,大概也能猜出来其中含义,index0/type
表明这是一个数据缓存,level
是1,就是L1$date
,8路相连,sets数目是每路64,所以64*64*8=32*1024=32kb
就是这么来的。
在看一个index1
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index1# cat size
32K
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index1# cat ways_of_associativity
8
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index1# cat level
1
L1$I
指令缓存
index2
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index2# cat number_of_sets
1024
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index2# cat level
2
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index2# cat coherency_line_size
64
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index2# cat size
256K
上面自行解读。L2缓存。
重点看一下L3
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index3# cat ways_of_associativity
12
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index3# cat number_of_sets
8192
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index3# cat coherency_line_size
64
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index3# cat level
3
root@zhangji16vm:/sys/devices/system/cpu/cpu0/cache/index3# cat size
6144K
需要注意的是,L3尽管是多核共享的,但是上面提到的任然是单个处理器的参数。因为多核之间会通过Bus-Brige连接,上面的6M表示总共L3缓存大小,几个核累加的大小就是6M。