u/cpu0/cache/index0/ways_of_associativity
$4
(2) 如查看cpu0 的一级缓存中的有多少组(每一份中有多少个cacheline)
$ cat /sys/devices/system/cpu/cpu0/cache/index0/number_of_sets
$128
14.3 查看cache_line的大小
上面以ls1043的cpu一级缓存为例知道了cpu0的一级缓存的大小:32k,其包含128个(sets)组,每组有4(ways),则可以算出每一个way(cache_line)的大小 cache_line = 321024/(1284)=64 bytes。当然我们也可以通过以下命令查出cache_line的大小(单位是字节)
# cat /sys/devices/system/cpu/cpu0/cache/index0/coherency_line_siz
64
14.4 查看cache的分配策略
# cat /sys/devices/system/cpu/cpu0/cache/index0/alloction_policy
ReadWriteAllocate
# cat /sys/devices/system/cpu/cpu0/cache/index1/alloction_policy
ReadAllocate
# cat /sys/devices/system/cpu/cpu0/cache/index2/alloction_policy
ReadWriteAllocate
14.5 查看cache的回写策略
# cat /sys/devices/system/cpu/cpu0/cache/index0/write_policy
WriteBack
# cat /sys/devices/system/cpu/cpu0/cache/index1/write_policy
cat:can't open 'write_policy':No such file or directory
# cat /sys/devices/system/cpu/cpu0/cache/index2/write_policy
WriteBack
14.5 查看cache的shared_cpu_map
# cat /sys/devices/system/cpu/cpu0/cache/index0/shared_cpu_map
1
# cat /sys/devices/system/cpu/cpu0/cache/index1/shared_cpu_map
1
# cat /sys/devices/system/cpu/cpu0/cache/index2/shared_cpu_map
f
# cat /sys/devices/system/cpu/cpu1/cache/index0/shared_cpu_map
2
# cat /sys/devices/system/cpu/cpu1/cache/index1/shared_cpu_map
2
# cat /sys/devices/system/cpu/cpu1/cache/index2/shared_cpu_map
f
# cat /sys/devices/system/cpu/cpu2/cache/index0/shared_cpu_map
4
# cat /sys/devices/system/cpu/cpu2/cache/index1/shared_cpu_map
4
# cat /sys/devices/system/cpu/cpu2/cache/index2/shared_cpu_map
f
# cat /sys/devices/system/cpu/cpu3/cache/index0/shared_cpu_map
8
# cat /sys/devices/system/cpu/cpu3/cache/index1/shared_cpu_map
8
# cat /sys/devices/system/cpu/cpu3/cache/index2/shared_cpu_map
f
14.6 查看cache的shared_cpu_list
# cat /sys/devices/system/cpu/cpu0/cache/index0/shared_cpu_list
0
# cat /sys/devices/system/cpu/cpu0/cache/index1/shared_cpu_list
0
# cat /sys/devices/system/cpu/cpu0/cache/index2/shared_cpu_list
0-3
# cat /sys/devices/system/cpu/cpu1/cache/index0/shared_cpu_list
1
# cat /sys/devices/system/cpu/cpu1/cache/index1/shared_cpu_list
1
# cat /sys/devices/system/cpu/cpu1/cache/index2/shared_cpu_list
0-3
# cat /sys/devices/system/cpu/cpu2/cache/index0/shared_cpu_list
2
# cat /sys/devices/system/cpu/cpu2/cache/index1/shared_cpu_list
2
# cat /sys/devices/system/cpu/cpu2/cache/index2/shared_cpu_list
0-3
# cat /sys/devices/system/cpu/cpu3/cache/index0/shared_cpu_list
3
# cat /sys/devices/system/cpu/cpu3/cache/index1/shared_cpu_list
3
# cat /sys/devices/system/cpu/cpu3/cache/index2/shared_cpu_list
0-3
部分章节摘自:
(1) Linux内存管理:ARM64体系结构与编程之cache(1)
(2) Linux内存管理:ARM64体系结构与编程之cache(2):cache一致性
(3) Cache的基本知识
(4) 《Arm® Architecture Reference Manual Armv8, for Armv8-A architecture profile - The AArch64 System Level Memory Model D4.4 Cache support》
(5) DMA和cache一致性问题