LoginSignup
3
1

More than 1 year has passed since last update.

WSLでio_uringを使う 2021/04

Posted at

はじめに

WSLでデフォルトで使われるカーネルはio_uringが無効になっています。
すこし調べると本家からフォークしたこちらのリポジトリでbzImageが配布されていてio_uringが使えるのですが、少しヘビーな使う方をするとうまく動きません。https://github.com/hatoo/io_uring_test のプログラムがうまく動きません。

今回は普通にhttps://github.com/microsoft/WSL2-Linux-Kernel のコンフィグをいじって自分でカーネルをビルドしたらうまく行ったのでそのやり方を共有します。

手順

作業はWSL上で行います

1. microsoft/WSL2-Linux-Kernelリリースページからソースコードをダウンロードする。

クローンしたコードだとうまくいきませんでした

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

2. 解凍する

$ tar -zxvf https://github.com/microsoft/WSL2-Linux-Kernel/archive/refs/tags/linux-msft-wsl-5.10.16.3.tar.gz
$ cd linux-msft-wsl-5.10.16.3

3. コンフィグを編集してio_uringを有効にする

Microsoft/config-wslを編集してCONFIG_IO_URINGのところをCONFIG_IO_URING=yにする。

4. Make

make -j16 KCONFIG_CONFIG=Microsoft/config-wsl

5. bzImageをWindowsの適当なところに置く

例えば

cp arch/x86_64/boot/bzImage /mnt/c/Users/$(ユーザー名)/Linux/bzImage

6. .wslconfigを編集する

C:\Users\$(ユーザー名)\.wslconfigを編集して

こんな感じにする

[wsl2]
kernel = C:\\Users\\$(ユーザー名)\\Linux\\bzImage

7 WSLの再起動

Windowsのシェルで

> wsl --shutdown

ulimit -l

io_uringを使っているとmax locked memoryの値が足りなくてエラーになることがあります。
WSLだと普通のやり方ではulimitの値が変えられないようなのでその場合はhttps://github.com/microsoft/WSL/issues/1576#issuecomment-643804974 を参考にすると良いです。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1