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

Posted

技术标签:

【中文标题】错误:perf.data 文件没有样本【英文标题】:error: perf.data file has no samples 【发布时间】:2017-06-21 11:18:58 【问题描述】:

我目前正在学习使用 perf。我有硬件事件的输出,但没有 cpu-cycles 或 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

性能报告 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

【问题讨论】:

perf 版本 2.6.32-642.13.1.el6.x86_64.debug 我也可以使用 perf 版本 3.8.2,但这会导致内存访问错误。 您是否尝试从内核源代码构建 perf 并使用它? 我正在处理一个已经安装 perf 但我没有 root 权限的集群 【参考方案1】:

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

perf stat ./pi-serial-ps

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

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

【讨论】:

以上是关于错误:perf.data 文件没有样本的主要内容,如果未能解决你的问题,请参考以下文章

perf.data 到文本或 csv

perf 分析进程

perf 脚本输出的含义是啥?

simpleperf 火焰图

火焰图生成

perf生成火焰图使用简记