如何在 WSL2 上使用 Linux perf 工具?如何获得正确内核的性能?

cod*_*yer 8 linux windows linux-kernel perf windows-subsystem-for-linux

我正在尝试在使用 Windows10 机器的 WSL2 上使用 Linux 的 perf 工具。我已经在这里完成了已接受答案的每一步:Is there any method to run perf under WSL?

当我运行“make”评论时,我收到警告:

警告:“tools/include/uapi/linux/stat.h”处的内核 ABI 标头与“include/uapi/linux/stat.h”处的最新版本不同

但仍创建了 perf 可执行文件。但是,当我尝试像这样使用 perf 时:

sudo perf record -g myexe myargs
Run Code Online (Sandbox Code Playgroud)

我收到这个错误:

警告:未找到内核 5.10.16.3-microsoft 的性能

您可能需要为此特定内核安装以下软件包: linux-tools-5.10.16.3-microsoft-standard-WSL2 linux-cloud-tools-5.10.16.3-microsoft-standard-WSL2

然后我尝试运行这个:

sudo apt install linux-tools-5.10.16.3-microsoft-standard-WSL2
Run Code Online (Sandbox Code Playgroud)

但这也不起作用,我得到了这个:

正在读取软件包列表...已完成构建依赖关系树正在读取状态信息...已完成 E: 无法找到软件包 linux-tools-5.10.16.3-microsoft-standard-WSL2 E: 无法通过 glob 'linux-tools 找到任何软件包-5.10.16.3-微软标准-WSL2'

我现在应该怎么做?