没有看到文件/sys/devices/system/cpu/cpu*/cache/index*/coherency_line_size
时间: 2024-01-08 17:21:25 浏览: 26
根据提供的引用内容,您可能没有看到文件`/sys/devices/system/cpu/cpu*/cache/index*/coherency_line_size`是因为该文件可能不存在或者您没有足够的权限来访问该文件。请确保您具有足够的权限,并且正确地查找文件路径。
以下是一种方法来查找`coherency_line_size`文件的路径:
1. 打开终端并输入以下命令:
```shell
ls /sys/devices/system/cpu/cpu*/cache/index*/coherency_line_size
```
2. 如果命令返回文件路径,则表示文件存在,并且您可以使用该路径来访问文件。
3. 如果命令没有返回任何结果,则表示文件可能不存在或者您没有足够的权限来访问该文件。
请注意,文件路径中的`*`通配符表示匹配任意字符,`cpu*`表示匹配以`cpu`开头的任意字符。
相关问题
linux内核中armv7初始化L2 cache的代码在哪里,是哪些
在 Linux 内核中,ARMv7 初始化 L2 cache 的代码主要位于 `arch/arm/mm/cache-v7.S` 文件中。
具体来说,以下是该文件中初始化 L2 cache 的代码:
```assembly
#ifdef CONFIG_PL310_ERRATA_769419
/* Workaround erratum 769419 in the PL310 cache controller */
mrc p15, 1, r0, c9, c0, 2 @ read Auxiliary Control Register
orr r0, r0, #(1 << 6) @ set bit 6 (enable implicit clean/inv)
mcr p15, 1, r0, c9, c0, 2 @ write Auxiliary Control Register
#endif
/*
* Configure L2 cache controller.
*/
mrc p15, 1, r0, c9, c0, 2 @ read Auxiliary Control Register
bic r0, r0, #(0x3 << 6) @ clear bits [7:6] (inner cache policy)
orr r0, r0, #(0x2 << 6) @ write-thru, allocate on write
@ for inner cache
bic r0, r0, #(0x3 << 4) @ clear bits [5:4] (outer cache policy)
orr r0, r0, #(0x2 << 4) @ write-thru, allocate on write
@ for outer cache
mcr p15, 1, r0, c9, c0, 2 @ write Auxiliary Control Register
mov r0, #0
mcr p15, 2, r0, c9, c0, 1 @ disable L2 prefetch
mcr p15, 2, r0, c9, c0, 0 @ disable L2 cache
mrc p15, 1, r0, c0, c0, 1 @ Read CLIDR
bic r1, r0, #0x7000000 @ r1 = LoC (Line of Coherency)
mov r2, #0
1: add r3, r1, r2 @ r3 = Waypointers
mcr p15, 2, r3, c0, c0, 0 @ Write Waypointer
add r2, r2, #4
cmp r2, #0x100 @ 4 * 64
blt 1b
mov r0, #0x200000
mcr p15, 2, r0, c0, c0, 2 @ Write L2 Control Register (enable L2 cache)
```
这段代码中,首先根据配置选项和处理器的 errata 对 L2 cache 进行一些设置(如清除某些位、设置写策略等),然后禁用 L2 的预取和缓存,接着通过读取 CLIDR 寄存器确定 L2 缓存的大小和关联性,最后启用 L2 cache。
perf 测量l2命中率
perf是一个性能分析工具,可以用于测量程序的各种性能指标,包括L2命中率。L2命中率是指CPU的二级缓存(L2 Cache)中的数据被成功命中的比例。
要使用perf测量L2命中率,可以按照以下步骤进行操作:
1. 安装perf工具:首先需要确保系统中已经安装了perf工具。在Linux系统中,可以使用包管理器进行安装,例如在Ubuntu上可以使用以下命令进行安装:
```
sudo apt-get install linux-tools-common linux-tools-generic
```
2. 启用L2命中率统计:在进行性能分析之前,需要确保L2命中率统计功能已经启用。可以通过修改/sys/devices/cpu/cpuX/cache/indexX/目录下的文件来启用L2命中率统计,其中cpuX表示CPU核心编号,indexX表示缓存层级编号。具体的文件名可能因系统而异,一般为以下之一:
- coherency_line_size:缓存行大小
- number_of_sets:缓存组数
- ways_of_associativity:关联度
- size:缓存大小
可以使用以下命令查看当前系统中的缓存信息:
```
ls /sys/devices/cpu/cpuX/cache/
```
3. 运行perf命令进行测量:使用perf命令进行性能测量,可以使用以下命令来测量L2命中率:
```
perf stat -e L2_RQSTS:ALL_DEMAND_REFERENCES,L2_RQSTS:ALL_PF_REFERENCES -p <pid>
```
其中,-e参数用于指定要统计的事件,L2_RQSTS:ALL_DEMAND_REFERENCES表示所有的读取请求,L2_RQSTS:ALL_PF_REFERENCES表示所有的预取请求。-p参数用于指定要监测的进程ID。
运行perf命令后,会输出一些统计信息,其中包括L2命中率的统计结果。