Unable to use perf on WSL2 Ubuntu 20.04
Windows Version
Microsoft Windows [Version 10.0.22631.2506]
WSL Version
1.2.5.0
Are you using WSL 1 or WSL 2?
- [X] WSL 2
- [ ] WSL 1
Kernel Version
5.15.90.1
Distro Version
Ubuntu 20.04
Other Software
perf
Repro Steps
In terminal, run perf -v
Expected Behavior
Information regarding the version of perf available on my system should be returned.
Actual Behavior
I get the following error:
WARNING: perf not found for kernel 5.15.90.1-microsoft
You may need to install the following packages for this specific kernel:
linux-tools-5.15.90.1-microsoft-standard-WSL2
linux-cloud-tools-5.15.90.1-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
Diagnostic Logs
I installed perf using sudo apt install linux-tools-generic, and can see that it was installed to /usr/lib/linux-tools/5.4.0-166-generic/perf (although it seems to be the wrong version for my kernel).
I've also tried running sudo apt install linux-tools-5.15.90.1-microsoft-standard-WSL2 and sudo apt install linux-tools-standard-WSL2, as directed by the warning mentioned above, but get the following errors:
E: Unable to locate package linux-tools-5.15.90.1-microsoft-standard-WSL2
E: Couldn't find any package by glob 'linux-tools-5.15.90.1-microsoft-standard-WSL2'
and
E: Unable to locate package linux-tools-standard-WSL2
respectively.
It looks like when I run the command perf -v, it tries to run the perf binary in /usr/bin/perf instead of /usr/lib/linux-tools/5.4.0-166-generic/perf. If I cd /usr/lib/linux-tools/5.4.0-166-generic/ and run ./perf -v, then I get the following:
perf version 5.4.252
So it looks like I can use the linux-tools version of perf, but not the /usr/bin version. But the OS by default points to the /usr/bin version even after the linux-tools version is installed. Is this the expected behavior or would this still be regarded as a bug?
Any updates on this? One of the reasons I was so excited that WSL2 came out was finally the ability to use such tooling on Windows. But it seems that it's unsupported?
Update: Adding the specific linux-tools path to PATH seem to do the trick. Shame that this doesn't work out of the box. However unsure if this a WSL2 issue or an Ubuntu packaging issue?
Still an issue
$ perf --version
WARNING: perf not found for kernel 5.15.167.4-microsoft
You may need to install the following packages for this specific kernel:
linux-tools-5.15.167.4-microsoft-standard-WSL2
linux-cloud-tools-5.15.167.4-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
It would be great if the kernel used by WSL2 was following the expectations set for Ubuntu kernel packages. But I guess we would have better luck asking Ubuntu for a linux-tools generic packages that would be used as default when kernel and per kernel linux-tools doesn't match.
struggling with this today just trying to get an apples-to-apples benchmark (wall clock time doesn't cut it since different computers operate at different speeds), could it be possible to fix this or provide a workaround?
There are some instructions on how to do this here: https://gist.github.com/abel0b/b1881e41b9e1c4b16d84e5e083c38a13
However initially when I ran the commands the build was failing because of warning messages and warnings as errors is on by default so I got it to build by doing make -j$(nproc) WERROR=0