我在新买的笔记本电脑上使用 linux perf 时遇到问题:我的 perf 列表中没有可用的硬件缓存效果!嗯,这确实是我想要采样的所有重要信息!这是我的性能列表:
List of pre-defined events (to be used in -e):
cpu-cycles OR cycles [Hardware event]
instructions [Hardware event]
cache-references [Hardware event]
cache-misses [Hardware event]
branch-instructions OR branches [Hardware event]
branch-misses [Hardware event]
bus-cycles [Hardware event]
ref-cycles [Hardware event]
cpu-clock [Software event]
task-clock [Software event]
page-faults OR faults [Software event]
context-switches OR cs [Software event]
cpu-migrations OR migrations [Software event]
minor-faults [Software event]
major-faults [Software event]
alignment-faults [Software event]
emulation-faults [Software event]
dummy [Software event]
branch-instructions OR cpu/branch-instructions/ [Kernel PMU event]
branch-misses OR cpu/branch-misses/ [Kernel PMU event]
bus-cycles OR cpu/bus-cycles/ [Kernel PMU event]
cache-misses OR cpu/cache-misses/ [Kernel PMU event]
cache-references OR cpu/cache-references/ [Kernel PMU event]
cpu-cycles OR cpu/cpu-cycles/ [Kernel PMU event]
instructions OR cpu/instructions/ [Kernel PMU event]
power/energy-cores/ [Kernel PMU event]
power/energy-gpu/ [Kernel PMU event]
power/energy-pkg/ [Kernel PMU event]
power/energy-ram/ [Kernel PMU event]
ref-cycles OR cpu/ref-cycles/ [Kernel PMU event]
rNNN [Raw hardware event descriptor]
cpu/t1=v1[,t2=v2,t3 ...]/modifier [Raw hardware event descriptor]
(see 'man perf-list' on how to encode it)
mem:<addr>[:access] [Hardware breakpoint]
[ Tracepoints not available: Permission denied ]
这是我以前看到的性能列表:https://perf.wiki.kernel.org/index.php/Tutorial#Events。
我以前做的事情是:
sudo perf stat -e L1-dcache-loads,L1-dcache-load-misses,LLC-loads,LLC-load-misses -a --append -o perf.txt [some command to run a file]
但这在我的新机器上不起作用。在这种情况下我怎样才能收集到我想要的数据呢?
我使用的是 Ubuntu 14.04,内核 <3.19.0-56>。性能版本 <3.19.8-ckt15>。
更新
我安装了papi-tools
库,并papi_native_avail
给了我
Available native events and hardware information.
PAPI Version : 5.3.0.0
Vendor string and code : GenuineIntel (1)
Model string and code : Intel(R) Core(TM) M-5Y71 CPU @ 1.20GHz (61)
CPU Revision : 4.000000
CPUID Info : Family: 6 Model: 61 Stepping: 4
CPU Max Megahertz : 2900
CPU Min Megahertz : 500
Hdw Threads per core : 1
Cores per Socket : 2
Sockets : 2
NUMA Nodes : 1
CPUs per Node : 4
Total CPUs : 4
Running in a VM : no
Number Hardware Counters : 0
Max Multiplex Counters : 64
答案1
另外值得注意的是,perf list
根据它是否作为root
. (也许有一些配置设置不是root
决定因素;我不确定。)
在我的 Linux Mint 18.1 机器上,运行 4.8.0-34-generic 内核:
$ perf list cache
List of pre-defined events (to be used in -e):
$ sudo perf list cache
List of pre-defined events (to be used in -e):
L1-dcache-load-misses [Hardware cache event]
L1-dcache-loads [Hardware cache event]
L1-dcache-stores [Hardware cache event]
L1-icache-load-misses [Hardware cache event]
LLC-load-misses [Hardware cache event]
LLC-loads [Hardware cache event]
LLC-store-misses [Hardware cache event]
LLC-stores [Hardware cache event]
branch-load-misses [Hardware cache event]
branch-loads [Hardware cache event]
dTLB-load-misses [Hardware cache event]
dTLB-loads [Hardware cache event]
dTLB-store-misses [Hardware cache event]
dTLB-stores [Hardware cache event]
iTLB-load-misses [Hardware cache event]
iTLB-loads [Hardware cache event]
node-load-misses [Hardware cache event]
node-loads [Hardware cache event]
node-store-misses [Hardware cache event]
node-stores [Hardware cache event]
答案2
首先,检查处理器是否有硬件计数器。 Intel Haswell 架构停止在最新的处理器中提供硬件计数器(出于某种原因)。
其次,我会检查您是否可以通过例如查看硬件事件papi
。如果 Ubuntu 提供了足够新的数据库,该命令papi_native_avail
应该列出本机事件。
第三种可能是事件已经发生,但没有旧的支持perf
。是的,Ubuntu 14.04 已经推出两年了,内核/工具可能无法完全支持当前的处理器。
答案3
我最近遇到了这个问题,但我找出了原因并成功解决了它。
起初,sudo perf list
只给了我几行事件。
对于那些需要完整硬件事件perf
且未显示的人perf-list
,您需要安装最新的linux-tools
。
sudo apt-get install linux-tools-4.15.0-106-generic linux-cloud-tools-4.15.0-106-generic linux-tools-generic linux-cloud-tools-generic
然后,运行
sudo perf list > perflist.txt
让我看到 1980 行perflist.txt
。