Is There Any Method to Run Perf Under Wsl

Is there any method to run perf under WSL?


WARNING: perf not found for kernel 4.19.84-microsoft

Because WSL2 uses custom Linux kernel. Its source code can be found here
microsoft/WSL2-Linux-Kernel. We have to compile perf tools from it.

Procedure

  • Install required build packages. If you are using Ubuntu in WSL2 this is the
    required command:
sudo apt install build-essential flex bison libssl-dev libelf-dev
  • Clone the WSL2 Linux kernel repository:
git clone --depth=1 https://github.com/microsoft/WSL2-Linux-Kernel.git
  • Go to perf folder and compile it:
cd WSL2-Linux-Kernel/tools/perf
make

perf executable file will be in that folder.

Cannot run .exe when under /home but can when under /mnt/c

Create /etc/wsl.conf and define the following inside it:

[automount]
enabled = true
options = "metadata,uid=1000,gid=1000,umask=0022,fmask=11,case=off"
mountFsTab = false
crossDistro = true

[network]
generateHosts = true
generateResolvConf = true

[filesystem]
umask = 0022

[interop]
enabled = true
appendWindowsPath = true

The interop section explicitly enabling it to true might resolve the issue. Be sure to also keep in mind if you run WSL2 and also use the systemd hack, your Windows interop will break and no exe files will be able to be executed.



Related Topics



Leave a reply



Submit