【发布时间】:2016-02-19 04:15:12
【问题描述】:
我被难住了,我阅读了 perf 教程,并试图在“perf stat”之外进行一个简单的测试。但是 perf record 要么不起作用,要么 perf annotate 显示没有记录样本。运行性能
例如(我使用 sudo 运行,因为没有它我会得到一堆错误,我将在最后发布):
sudo perf record -e cycles,instructions,cache-misses -a -c 1 ./FooExe
[ perf record: Woken up 4 times to write data ]
[ perf record: Captured and wrote 1.794 MB perf.data (~78393 samples) ]
.
sudo perf report -D -i perf.data |grep RECORD_SAMPLE |wc -l
Failed to open /tmp/perf-23796.map, continuing without symbols
20486
.
sudo perf annotate -d ./FooExe
the perf.data file has no samples! Press any key
所以这就是我得到的。我试图从源代码为我的系统重建性能,但这似乎也没有帮助。
我使用的是 Ubuntu 14.04 内核 3.19.0-49-generic。这是在英特尔 i7 I4510U cpu 上。我确保使用符号编译我的程序,但无论我尝试分析哪个应用程序,我都会得到相同的结果。
-- 如果我在没有 sudo 的情况下运行:
WARNING: Kernel address maps (/proc/{kallsyms,modules}) are restricted,
check /proc/sys/kernel/kptr_restrict.
Samples in kernel functions may not be resolved if a suitable vmlinux
file is not found in the buildid cache or in the vmlinux path.
Samples in kernel modules won't be resolved at all.
If some relocation was applied (e.g. kexec) symbols may be misresolved
even with a suitable vmlinux or kallsyms file.
Cannot read kernel map
Error:
You may not have permission to collect system-wide stats.
Consider tweaking /proc/sys/kernel/perf_event_paranoid:
-1 - Not paranoid at all
0 - Disallow raw tracepoint access for unpriv
1 - Disallow cpu events for unpriv
2 - Disallow kernel profiling for unpriv
【问题讨论】:
-
我稍后可能会发布更大的答案,但您不需要
sudo。perf尝试将在内核模式下花费的 CPU 时间包含在系统调用中。如果您只是试图分析您的代码在用户空间中的作用,则警告消息是无害的。分析仍然有效。perf report是否因为样本数据归根用户所有且不可读而失败?尝试删除所有 root 拥有的文件,然后在不使用 sudo 的情况下重新开始。 -
好的,谢谢。我尝试删除 sudo 拥有的数据并重复测试。当我这样做时,如果我尝试 perf annotate -d ./FooExe 然后 perf 启动会显示一个进度条并立即退出。如果我尝试不使用 -d 选项,它只会显示“perf.data 文件没有样本”
标签: linux performance x86 perf