6

I am trying to use the perf tool of Linux on my WSL2 using Windows10 machine. I have done every step of the accepted answer here:Is there any method to run perf under WSL?

When I ran "make" comment, I got a warning:

Warning: Kernel ABI header at 'tools/include/uapi/linux/stat.h' differs from latest version at 'include/uapi/linux/stat.h'

But the perf executable was still created. However when I try to use perf like this:

sudo perf record -g myexe myargs

I received this error:

WARNING: perf not found for kernel 5.10.16.3-microsoft

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

Then I tried to run this:

sudo apt install linux-tools-5.10.16.3-microsoft-standard-WSL2

However that did not work either, I got this:

Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package linux-tools-5.10.16.3-microsoft-standard-WSL2 E: Couldn't find any package by glob 'linux-tools-5.10.16.3-microsoft-standard-WSL2'

What should I do now?

codertryer
  • 359
  • 3
  • 12
  • Are you sure you have WSL2? Apparently it can be non-obvious whether a WSL install is actually WSL2 or WSL1: [Does WSL 2 really support 32 bit program?](https://stackoverflow.com/q/61300194) – Peter Cordes Dec 01 '21 at 03:34
  • @PeterCordes hello! yes i am pretty sure, because it says version is 2 when I run the command "wsl --list --verbose". – codertryer Dec 01 '21 at 09:47
  • On Debian 11 ("Bullseye") under WSL2, the `perf_5.10` command installed by the "linux-perf-5.10" package as a dependency of the "linux-perf" package seems to work. – Ian Abbott Dec 02 '21 at 13:55
  • perf looks at CPU hardware counters which will all return 0 in a VM. – stark Dec 02 '21 at 20:03
  • @stark but i specifically researched to learn that perf works on WSL2 – codertryer Dec 03 '21 at 13:00
  • Have you succeeded with perf under WSL2? – Alexey Subbota Apr 16 '22 at 05:35
  • 1
    Seems the only way is to build perf yourself. Not so hard per the instructions here: https://stackoverflow.com/questions/60237123/is-there-any-method-to-run-perf-under-wsl – Ofek Shilon May 14 '22 at 12:14

0 Answers0