使用 WSL2 在 Ubuntu 20.04 LTS 上安装 Linux Perf 工具

Tho*_*ell 8 package-management apt kernel windows-subsystem-for-linux

我正在尝试在我的 Windows 计算机上使用 WSL 2 设置 Ubuntu 20.04 LTS,以便能够跨 Linux 和 Windows 版本运行性能实验,作为其中的一部分,我打算安装该工具perf

为了做到这一点,我读到了需要的软件包linux-tools-common和内容。linux-tools-generic我使用安装了这些apt install,它确实导致了perf安装。但是,如果我尝试运行该工具,则会出现以下提示:

$ perf --version
WARNING: perf not found for kernel 5.4.72-microsoft

  You may need to install the following packages for this specific kernel:
    linux-tools-5.4.72-microsoft-standard-WSL2
    linux-cloud-tools-5.4.72-microsoft-standard-WSL2

  You may also want to install one of the following packages to keep up to date:
    linux-tools-standard-WSL2
    linux-cloud-tools-standard-WSL2
Run Code Online (Sandbox Code Playgroud)

但是,这些包都不存在于 apt 存储库中,并且我找不到对此类包的任何引用。

有没有人在 WSL2 上设置过 Linuxperf或者可以为我提供有关如何最好地解决此问题的建议?

Kir*_*hxh 2

WSL2 目前不支持 Perf,因为它有一个不支持硬件计数器的自定义内核。您可以手动安装 perf,但它不会给您预期的结果。 https://github.com/microsoft/WSL/issues/4678
https://github.com/microsoft/WSL/issues/329
https://github.com/microsoft/WSL/issues/3225