【发布时间】:2015-08-21 07:13:05
【问题描述】:
根据 AMD 15h 的BKDG(第 588 页),可以禁用 通过设置 MSRC001_1022 的一些位来实现硬件预取器
MSRC001_1022 Data Cache Configuration (DC_CFG)
Bits --> Description
63:16 --> Reserved.
15 --> DisPfHwForSw. Read-write. Reset: 0. 1=Disable hardware prefetches for software prefetches.
14 --> Reserved.
13 --> DisHwPf. Read-write. Reset: 0. 1=Disable the DC hardware prefetcher.
12:10 --> Reserved.
9:5 --> Reserved.
4 --> DisSpecTlbRld. Read-write. Reset: 0. 1=Disable speculative TLB reloads.
3:0 --> Reserved.
为了禁用所有预取配置,我必须将 0xA008 写入 那个MSR。我为所有 32 个核心使用
[root <at> tiger exe]# wrmsr -a 0xc0011022 0xA008
[root <at> tiger exe]# rdmsr -a -x -0 0xc0011022
000000000000a008
...
但是,当我与命令一起运行 perf 时,预取统计信息 非零!
[root <at> tiger exe]# perf stat -e
L1-dcache-loads:uk,L1-dcache-prefetches:uk,L1-dcache-prefetch-misses:uk ./bzip2_base.amd64-m64-gcc44-nn
spec_init
Tested 64MB buffer: OK!
Performance counter stats for './bzip2_base.amd64-m64-gcc44-nn':
55,341,597,193 L1-dcache-loads:uk
1,047,662,614 L1-dcache-prefetches:uk
0 L1-dcache-prefetch-misses:uk
35.921618464 seconds time elapsed
我希望在 L1-dcache-prefetches 前面看到 0。不是吗?
如何调试计数器以了解它们是如何映射到 MSR 的?
【问题讨论】:
-
使用
-v或-vvvoptions of perf record 调试计数器,其中一些会打印出perf_event_open调用中使用的所有参数。它们可能仍然是合成的,因此请检查perf_events的内核部分(您的内核版本是什么?) - 它们位于arch/x86/events/amd/core.c:L1D OP_PREFETCH RESULT_ACCESS =0x0267, /* Data Prefetcher :attempts */和 l1-dcache 负载为 `0x0040, /* 数据缓存访问 */`
标签: linux performance perf amd-processor