如何在 WSL2 中启用 PMU?

如何在 WSL2 中启用 PMU?

我在 Windows11 中使用 WSL2 作为我的 Linux 主机。
现在我想perf在这个 WSL2 中运行,但我未能做到这一点,并出现以下错误。

# uname -a
Linux testhost 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

# dmesg | grep -i perf
[    0.039284] Performance Events: unsupported p6 CPU model 154 no PMU driver, software events only.
[    0.204569]     Performance counters on

我已经在 Windows 中的 USRNAME/.wslconfig 中添加了以下行。

hardwarePerformanceCounters=true

并在 Powershell 中以管理身份运行以下命令

PS C:\Users\aa> wsl --update
Checking updates
Updating WSL2 subsystem to version: 2.0.14.
PS C:\Users\aa> dism /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Deploying service and management tool.
Version: 10.0.22621.1

Image version: 10.0.22621.1848

Done started one or more functions
[==========================100.0%==========================]
Done

但WSL2 Linux未能获得PMU硬件。

我不确定是否可以在这里发布 WSL2 相关问题,如果不能,抱歉。

相关内容