[问题描述]: perf test测试项PE file support:FAIL [root@iZbp13qjxld7i2hqvemwgiZ yum.repos.d]# perf test -v 68 68: PE file support : --- start --- test child forked, pid 19981 FAILED tests/pe-file-parsing.c:40 Failed to read build_id test child finished with -1 ---- end ---- PE file support: FAILED! [环境信息]: 机器类型:ECS [perf version] [root@iZbp13qjxld7i2hqvemwgiZ ~]# perf --version perf version 5.10.134-16.2_rc1.an23.aarch64 [内核信息]: [root@iZbp13qjxld7i2hqvemwgiZ yum.repos.d]# uname -r 5.10.134-16.2_rc1.an23.aarch64 [操作系统信息]: [root@iZbp13qjxld7i2hqvemwgiZ yum.repos.d]# cat /etc/os-release NAME="Anolis OS" VERSION="23" ID="anolis" VERSION_ID="23" PLATFORM_ID="platform:an23" PRETTY_NAME="Anolis OS 23" ANSI_COLOR="0;31" HOME_URL="https://openanolis.cn/" BUG_REPORT_URL="https://bugzilla.openanolis.cn/" [问题发生概率]: 必现 [复现步骤]: 1、安装执行版本的perf版本 2、执行对应编号的case,此处的68是当前perf版本的PE file support测试项 perf test -v 68
016.1 是OK的 [root@iZbp109lataf58vl8qfvsrZ ~]# perf --version perf version 5.10.134-16.1.an8.x86_64 [root@iZbp109lataf58vl8qfvsrZ ~]# perf test -v 68 68: PE file support : --- start --- test child forked, pid 42260 test child finished with 0 ---- end ---- PE file support: Ok
[root@iZbp13qjxld7i2hqvemwgiZ shell]# perf test -vvv 68 68: PE file support : --- start --- test child forked, pid 799625 filename__read_build_id: cannot read /usr/libexec/perf-core/tests/pe-file.exe bfd file. FAILED tests/pe-file-parsing.c:40 Failed to read build_id test child finished with -1 ---- end ---- PE file support: FAILED! [root@iZbp13qjxld7i2hqvemwgiZ shell]# perf -v perf version 5.10.134-16.1.an23.aarch64 同一台机器上,将perf降级到16.1以后,依然会有同样的问题。 看日志,应该是libbfd库有什么问题。
[perf version] [root@anolis ~]# perf --version perf version 5.10.134-16.2_rc1.an23.loongarch64 [内核信息]: [root@anolis ~]# uname -a Linux anolis 5.10.134-16.2_rc1.an23.loongarch64 #1 SMP Tue Jan 2 09:58:44 CST 2024 loongarch64 loongarch64 loongarch64 GNU/Linux [操作系统信息]: [root@anolis ~]# cat /etc/os-release NAME="Anolis OS" VERSION="23" ID="anolis" VERSION_ID="23" PLATFORM_ID="platform:an23" PRETTY_NAME="Anolis OS 23" ANSI_COLOR="0;31" HOME_URL="https://openanolis.cn/" BUG_REPORT_URL="https://bugzilla.openanolis.cn/" [问题]:必现 [root@anolis ~]# perf test -v 68 68: PE file support : --- start --- test child forked, pid 9446 FAILED tests/pe-file-parsing.c:40 Failed to read build_id test child finished with -1 ---- end ---- PE file support: FAILED!
原因定位: 在这台机器上的环境无法解析内核源码文件tools/perf/tests/pe-file.exe的文件格式信息。 在倚天物理机和测试ECS环境中clone同一份内核源码,分别获取pe-file.exe文件信息: 在倚天物理机上(alinux3环境): $objdump -x tools/perf/tests/pe-file.exe | head -6 tools/perf/tests/pe-file.exe: 文件格式 pei-x86-64 tools/perf/tests/pe-file.exe 体系结构:i386:x86-64,标志 0x0000013a: EXEC_P, HAS_DEBUG, HAS_SYMS, HAS_LOCALS, D_PAGED 起始地址 0x00000000004014f0 在ECS测试机上(anolis23环境): [root@iZbp13qjxld7i2hqvemwgiZ perf]# objdump -x tests/pe-file.exe objdump: tests/pe-file.exe: file format not recognized
当前环境的binutils版本: [root@iZbp13qjxld7i2hqvemwgiZ perf]# rpm -qa | grep binutils binutils-gold-2.40-3.an23.aarch64 binutils-2.40-3.an23.aarch64 binutils-devel-2.40-3.an23.aarch64 用源码编译perf, 测试失败: [root@iZbp13qjxld7i2hqvemwgiZ perf]# ./perf test -v 68 68: PE file support : --- start --- test child forked, pid 1652066 filename:./tests/pe-file.exe FAILED tests/pe-file-parsing.c:40 Failed to read build_id test child finished with -1 ---- end ---- PE file support: FAILED! 降级binutils版本: [root@iZbp13qjxld7i2hqvemwgiZ perf]# rpm -qa | grep binutils binutils-gold-2.39-1.an23.aarch64 binutils-2.39-1.an23.aarch64 binutils-devel-2.39-1.an23.aarch64 重新编译perf,测试成功: [root@iZbp13qjxld7i2hqvemwgiZ perf]# ./perf test -v 68 68: PE file support : --- start --- test child forked, pid 1640114 filename:./tests/pe-file.exe test child finished with 0 ---- end ---- PE file support: Ok 初步结论:binutils版本过高导致objdump/nm等无法解析pe-file.exe文件格式。而降级成2.39-1后可以测试成功。
该perf test测试项会执行bfd_check_format函数去检查perf源码中的pe-file.exe文件格式, 在2.40-3 的binutils版本中,bfd_check_format函数返回失败,导致测试failed。 在2.39-1 的binutils版本中,bfd_check_format函数返回成功。 需要check binutils软件包。
Nightly 中已更新 2.41 版本,请尝试 2.41 是否能够满足要求