How to run perf
on WSL2
This is heavily based on the comment of MondayCha.
Tested with
wsl2 Linux Kernel | Distribution | is_working? |
---|---|---|
5.15.90.1-microsoft-standard-WSL2 x86_64 |
Ubuntu-22.04 | [x] |
5.15.90.1-microsoft-standard-WSL2 x86_64 |
Ubuntu-20.04 | [x] |
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
wsl --update
wsl --install -d Ubuntu-22.04
sudo apt update
sudo apt upgrade
sudo apt install flex bison
sudo apt install libdwarf-dev libelf-dev libnuma-dev libunwind-dev \
libnewt-dev libdwarf++0 libelf++0 libdw-dev libbfb0-dev \
systemtap-sdt-dev libssl-dev libperl-dev python-dev-is-python3 \
binutils-dev libiberty-dev libzstd-dev libcap-dev libbabeltrace-dev \
make
git clone https://github.com/microsoft/WSL2-Linux-Kernel --depth 1
cd WSL2-Linux-Kernel/tools/perf
make
sudo cp perf /usr/local/bin
More Info
-
activate WSL and virtual machine functions
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
-
update WSL
wsl --update wsl --install -d Ubuntu-22.04
-
install linux distribution (
wsl --list --online
shows all available distributions)wsl --install -d Ubuntu-22.04
-
Update and Upgrade
update
rereads all package sources, whileupgrade
brings the installed packages up to the latest available in the package sources.sudo apt update sudo apt upgrade
-
Installing packages to build
perf
sudo apt install flex bison sudo apt install libdwarf-dev libelf-dev libnuma-dev libunwind-dev \ libnewt-dev libdwarf++0 libelf++0 libdw-dev libbfb0-dev \ systemtap-sdt-dev libssl-dev libperl-dev python-dev-is-python3 \ binutils-dev libiberty-dev libzstd-dev libcap-dev libbabeltrace-dev \ make
-
clone WSL2-Linux-Kernel sources
git clone https://github.com/microsoft/WSL2-Linux-Kernel --depth 1
-
set current directory to
WSL2-Linux-Kernel/tools/perf
cd WSL2-Linux-Kernel/tools/perf
-
build perf from sources
make
-
copy sources to
/usr/local/bin
sudo cp perf /usr/local/bin