在Podman容器内用Perf分析带调试符号应用时无法显示用户态函数
容器中Perf性能分析无法显示用户态函数问题
我需要对一个编译时带有调试符号的应用进行性能分析,应用的文件信息如下:
$ file ../../bin/linux-x86_64/simulator ../../bin/linux-x86_64/simulator: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=156bbd57d203d72f4226ed4ad0727bcf472f83ef, for GNU/Linux 3.2.0, with debug_info, not stripped
环境信息:应用运行在Podman容器中,容器系统为Debian 11,主机系统为Ubuntu 22.04。我之前成功用Perf做过分析,但现在忘了必要配置。
我的操作步骤:
- 容器外执行:
sudo sysctl kernel.perf_event_paranoid=-1
- 启动容器:
podman run --privileged --entrypoint=bash --network=host --rm -it -v ./st.cmd/:/opt/ad-sim-epics-ioc/iocBoot/iocsimulator/st.cmd -v /home/marco:/home/marco ghcr.io/cnpem/ad-sim-epics-ioc:v1.0.0
- 容器内安装Perf:
apt-get update && apt-get install linux-perf
- 执行性能记录(
st.cmd是指向目标应用的解释器脚本):
perf record -g ./st.cmd
首次执行报错:
/usr/bin/perf: line 13: exec: perf_5.15: not found
参考方案后创建软链接:
ln -s /usr/bin/perf_5.10 /usr/bin/perf_5.15
- 再次执行记录并导出结果:
perf record -g ./st.cmd (执行操作...) ^C [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.128 MB perf.data (2500 samples) ] perf script -F +pid > script.txt
问题:导出的结果中仅显示内核kallsyms,完全看不到用户态函数。我尝试过带/不带--privileged启动容器,也试过perf record --call-graph dwarf和perf record --call-graph fp,均无效。我记得之前仅用perf record -g就能看到用户态函数,请问哪里出错了?
内容的提问来源于stack exchange,提问作者Marco Montevechi Filho
相关产品推荐
相关产品推荐

