From: Ben Noordhuis Date: Sat, 30 Dec 2023 17:32:28 +0000 (+0100) Subject: [PATCH] linux: don't use io_uring on pre-5.10.186 kernels (#4093) X-Git-Tag: archive/raspbian/1.46.0-3+rpi1^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=92f586bad4fdd5778f5fcd7efd24cbe45c456c69;p=libuv1.git [PATCH] linux: don't use io_uring on pre-5.10.186 kernels (#4093) Bug: https://github.com/libuv/libuv/issues/4089 Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libuv1/+bug/2046442 Origin: upstream, https://github.com/libuv/libuv/commit/50b53cbd0db8d4e7be06939a0976ff520e791d31 Applied-Upstream: v1.47.0 Fixes: https://github.com/libuv/libuv/issues/4089 thread busy-loops. Gbp-Pq: Name lp2046442-linux-don-t-use-io_uring-on-pre-5.10.186-kernels-409.patch --- diff --git a/src/unix/linux.c b/src/unix/linux.c index 48b9c2c..91eb460 100644 --- a/src/unix/linux.c +++ b/src/unix/linux.c @@ -431,8 +431,14 @@ static int uv__use_io_uring(void) { use = atomic_load_explicit(&use_io_uring, memory_order_relaxed); if (use == 0) { + /* Older kernels have a bug where the sqpoll thread uses 100% CPU. */ + use = uv__kernel_version() >= /* 5.10.186 */ 0x050ABA ? 1 : -1; + + /* But users can still enable it if they so desire. */ val = getenv("UV_USE_IO_URING"); - use = val == NULL || atoi(val) ? 1 : -1; + if (val != NULL) + use = atoi(val) ? 1 : -1; + atomic_store_explicit(&use_io_uring, use, memory_order_relaxed); }