错误:perf.data文件没有样本

时间:2017-06-21 11:18:59

标签: linux perf

我目前正在学习使用perf。我有输出硬件事件,但没有输出cpu-cycle或cpu-clock等软件事件。

我用详细选项调用了perf:

$ > perf record -v ./pi-serial-ps
mmap size 528384B
Reference Pi: 3.1415926536
Simulated Pi: 3.1415209778
[ perf record: Woken up 15 times to write data ]
Looking at the vmlinux_path (7 entries long)
Using /proc/kallsyms for symbols
[ perf record: Captured and wrote 3.694 MB perf.data (96497 samples) ]

使用-e cpu-clock调用perf记录会得到相同的输出。 我查看了真实的样本量:

$ > perf report -D -i perf.data | grep RECORD_SAMPLE | wc -l
96497

perf报告TUI提供了一个没有错误的空表。使用详细选项,它输出:

$ > perf report -v perf.data
build id event received for [kernel.kallsyms]: d9ffffc97cd9edb0ddd58462595dd69a8c8b694
build id event received for /lib/modules 2.6.32-642.11.1.el6.Bull.106.x86_64/kernel/net/sunrpc/sunrpc.ko: 31402cf2d9ace7f86d54601334db6931390f8f6c
build id event received for /home/h1/s7330426/_Exercises/X03/x03/pi-serial-ps: bd3a924ac41ff481a4bc5bf034853f03b76193f4
build id event received for /lib64/ld-2.12.so: f3eebd18e66eb139ea4d76cdfa86d643abcf0070
build id event received for /lib64/libc-2.12.so: 24d3ab3db0f38c7515feadf82191651da4117a18

Perf annotate有这个错误:

the perf.data file has no samples

它不会向控制台输出任何内容,即使使用详细选项也不会。

我查了这个问题 perf.data file has no samples 还有这个 http://www.spinics.net/lists/linux-perf-users/msg01437.html 这两个都没有解决我的问题。

我在没有root权限的本地主机上使用Linux版本2.6.32-642.11.1.el6.Bull.106.x86_64。

任何帮助?

我找到了一个测量cpu-clock的解决方法,但我不知道它是否可靠: perf: strange relation between software events

1 个答案:

答案 0 :(得分:-1)

perf stat开始,获取通用原始性能计数器值:

perf stat ./pi-serial-ps

如果某个事件event的原始计数超过数百或数千且目标程序运行的时间超过几毫秒,则可以使用perf record -e event(或perf record -e event:u来分析内核代码)。 perf记录通常自动调谐采样率到几kHz左右(例如,如果你的程序有1亿个周期,则执行记录可以选择每1个周期大约作为样本生成器),原始计数器值太低的事件可能不会生成任何样本。您还可以使用perf记录的-c选项为每个样本设置事件计数,在此示例中,我们要求perf记录在用户空间代码程序中每花费10000个周期后生成样本;将为程序生成零样本,运行8469个周期:

perf record -e cycles:u -c 10000 ./pi-serial-ps