Linux Kernel v7.1 for WSL 2 with Direct X driver and Hyper-V PCI SWIOTBL

My updated builds of Linux Kernel v7.1 for WSL 2 with Direct X driver and Hyper-V PCI SWIOTBL support for x86_64 and arm64 architectures.


Checking the news about the WSL from my friend Hayden WSL 2 is getting faster Windows file system access. I remembered that: first I did not updated my mainline kernel build for WSL since the v6.18, and second I have a new patch to add on top of my mainline kernel build for WSL 2, which is the Hyper-V PCI SWIOTBL support.

 Source code and Build binaries

As usual, you can find the source code and build binaries for x86_64 and arm64 architectures on my GitHub repository: https://github.com/microhobby/linus-tree/releases/tag/wsl2-v7.1

This builds will boot the Linux 7.1.0-microhobby-<arch>-wsl2-v7.1.0 kernel:

alt text

󰙨 Let’s Test

So, as this is the first build with the Hyper-V PCI SWIOTBL support, I want to test it, to check if it works as expected. Unfortunately the wsl --update --pre-release command does not give me the build with the changes needed for the Hyper-V PCI SWIOTBL support, so I need to build the WSL msi installer myself. The instructions on the WSL repo worked well: https://github.com/microsoft/WSL/blob/master/doc/docs/dev-loop.md

After install the msi generated I have the version 2.8.12.39. Running this with my new kernel build and with the virtiofs=true on the .wslconfig file, I had the /sys/bus/vmbus/drivers/hv_pci/swiotlb_base and the /sys/bus/vmbus/drivers/hv_pci/swiotlb_size. Nice, the patch is there and working, at least on the sysfs level.

But and the io speed? I had executed the tests using the flexible I/O tester package, with the following command:

fio --name=write_test --filename=./test --ioengine=libaio --rw=write --bs=1M --size=1G --direct=1

The --filename ensures that the test will be executed on the file system I choose, and the --direct=1 ensures that the test will be executed without any cache, what can cause inaccurate results. I ran it under my /home/<user> and under the /mnt/c/Users/<user> directories, to check the difference between the Linux and Windows file systems.

Also I had executed the same test without the virtiofs=true on the .wslconfig file, to check the difference with and without the Hyper-V PCI SWIOTBL support. The results were:

alt text

 These are raw results from my machines, an Intel i7-12700H and a Qualcomm Snapdragon X Elite X1E78100. I ran it only once on each configuration. This is not a comparison between the two architectures, as they are different machines with different hardware and performance. The goal is to check the difference with and without the Hyper-V PCI SWIOTBL support on each machine.
ConfigurationFile SystemArchWrite Speed
virtiofs=trueLinuxx86_641636MiB/s
virtiofs=trueWindowsx86_64866MiB/s
virtiofs=falseLinuxx86_641571MiB/s
virtiofs=falseWindowsx86_64131MiB/s
virtiofs=trueLinuxarm64937MiB/s
virtiofs=trueWindowsarm64611MiB/s
virtiofs=falseLinuxarm64932MiB/s
virtiofs=falseWindowsarm64142MiB/s

 Conclusion

The latest builds of Linux Kernel v7.1 for WSL 2 with Direct X driver and Hyper-V PCI SWIOTBL support for x86_64 and arm64 architectures are available on my GitHub repository. The Hyper-V PCI SWIOTBL support is working as expected, and it is giving a significant boost on the Windows file system access speed. This is a great news for the WSL 2 users, as it will allow them to have a better experience when working with files on the Windows file system. There is still some gap, but it is a great improvement.

Looking forward to have this officially released on the stable version of the WSL.

Know you are loved ❤️