perf record捕获不到数据

# sudo perf record -F 999 ./sample 2000

[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.004 MB perf.data ]

# perf report

报错:
The perf.data data has no samples!

经尝试v1.0.15和v2.0.4都是同样的报错

可以加上-e cpu-clock参数,进一步的解释参考下Perf 使用注意事项 | Bianbu | 进迭时空开发者社区

1 个赞

这个perf工具在Bianbu OS上是怎么安装的呢

查看当前的内核版本

cat /proc/version 

比如看到是6.6.63-cloud,则安装

sudo apt install linux-tools-6.6.63-cloud

然后执行perf,如果提示缺少什么依赖,则安装,例如当看到提示

k1% perf
/usr/lib/linux-tools/6.6.63-cloud/perf: error while loading shared libraries: libpfm.so.4: cannot open shared object file: No such file or directory

sudo apt install libpfm4

当不确定要安装的软件包名字,可以尝试search,例如

sudo apt search pfm4

或者在网上搜索下怎么安装。

谢谢!可以了 :smiling_face_with_three_hearts: