Skip to content

Instantly share code, notes, and snippets.

@chadbrewbaker
Last active September 20, 2021 11:55
Show Gist options
  • Save chadbrewbaker/16d09aaca0818e6d403b969c3fb79b60 to your computer and use it in GitHub Desktop.
Save chadbrewbaker/16d09aaca0818e6d403b969c3fb79b60 to your computer and use it in GitHub Desktop.
Win 11 WSL Prodfiler notes.

My notes using Prodfiler on a Windows 11 pro preview build.

# Open a Powershell terminal as administrator
wsl --update
wsl --shutdown
wsl
# Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.10.43.3-microsoft-standard-WSL2 x86_64)
cd ~/
# "docker: Error response from daemon: Conflict. The container name "/prodfiler" is already in use by container" 
# I had to clean out an old beta of the prodfiler container in the Windows Docker Desktop GUI


# Status: Downloaded newer image for optimyze/pf-host-agent:release-1.0.0
# time="2021-09-18T17:58:02.445009300Z" level=info msg="Starting Prodfiler Host Agent (revision head-2e653d86, build timestamp
# 1630420891)" time="2021-09-18T17:58:02.447291800Z" level=error msg="Failed to probe tracepoint: failed to get id for tracepoint:
# failed to read # # tracepoint ID for sys_enter_mmap: open /sys/kernel/debug/tracing/events/syscalls/sys_enter_mmap/id:
# no such file or directory"

# Need to expose the tracepoint to the container.
sudo mount -t debugfs none /sys/kernel/debug

# Login Succeeded
# time="2021-09-18T18:11:54.245863800Z" level=info msg="Starting Prodfiler Host Agent (revision head-2e653d86, build timestamp # 1630420891)"
# time="2021-09-18T18:11:54.246546100Z" level=error msg="Failed to probe tracepoint: failed to get id for tracepoint: failed to read # tracepoint ID for sys_enter_mmap: open /sys/kernel/debug/tracing/events/syscalls/sys_enter_mmap/id: no such file or directory"

The /sys/kernel/tracing directory seems to be empty. I pinged Tyler Hicks and forked the WSL2 kernel to build my own with eBPF settgings turned on.

wget https://github.com/microsoft/WSL2-Linux-Kernel/archive/refs/tags/linux-msft-wsl-5.10.43.3.tar.gz
tar -xvf linux-msft-wsl-5.10.43.3.tar.gz
cd WSL2-Linux-Kernel-linux-msft-wsl-5.10.43.3/

You need to download the source, the kernel configuration file is available as /proc/config.gz on Ubuntu 20.02 for WSL2's offical kernel release.

bcc toools kernel configuration settings are the most widely used settings for minimal eBPF support.

First issue seems to be the file Microsoft/config-wsl has not turned on this header.

# CONFIG_IKHEADERS is not set
  • Experiment 1: Enable this flag and see if this works
make KCONFIG_CONFIG=Microsoft/config-wsl
#Might want to do make -j to build in parallel. I was conservative because linking RAM is constrained on my laptop.

Edit your .wslconfig file to load the rebuilt kernel.

# Check to make sure we loaded the rebuilt kernel
zgrep CONFIG_IKHEADERS /proc/config.gz
# CONFIG_IKHEADERS=y

Success!

Login Succeeded
time="2021-09-18T20:47:42.141173900Z" level=info msg="Starting Prodfiler Host Agent (revision head-2e653d86, build timestamp 1630420891)"
time="2021-09-18T20:47:42.284930500Z" level=info msg="Automatically determining environment and machine ID ..."
LINES OMITTED
time="2021-09-18T20:47:42.942347400Z" level=error msg="Unable to get host metadata: unable to open /proc/sys/net/core/bpf_jit_enable: open /proc/sys/net/core/bpf_jit_enable: no such file or directory"
time="2021-09-18T20:47:44.194475000Z" level=info msg="Start CPU metrics"
time="2021-09-18T20:47:44.194792800Z" level=info msg="Start I/O metrics"
time="2021-09-18T20:47:44.614713600Z" level=info msg="Found fsbase offset: 2664 (via x86_fsbase_write_task)"
time="2021-09-18T20:47:44.615687200Z" level=info msg="Environment variable KUBERNETES_SERVICE_HOST not set"
time="2021-09-18T20:47:44.615926600Z" level=info msg="eBPF tracer loaded"
time="2021-09-18T20:47:47.624878100Z" level=info msg="Attached tracer program"
time="2021-09-18T20:47:47.626156300Z" level=info msg="Attached sched monitor"
@mtb0x1
Copy link

mtb0x1 commented Sep 19, 2021

@chadbrewbaker I think the section about loading the new kernel need to be detailed, something like

# Copy the new kernel into a folder outside of /
cp vmlinux /mnt/c/Users/<User>/<Folder>
exit
# modifiy the file .wslconfig as follow : (location : C:\Users\<User>\.wslconfig )
[wsl2]
...
kernel=C:\\Users\\<User>\\<Folder>\\vmlinux
#make sure all instances are shutdow
wsl --shutdown Debian
#load wsl with the new kernel
wsl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment