[PATCH] linux: don't use io_uring on pre-5.10.186 kernels (#4093)
authorBen Noordhuis <info@bnoordhuis.nl>
Sat, 30 Dec 2023 17:32:28 +0000 (18:32 +0100)
committerDominique Dumont <dod@debian.org>
Sat, 30 Dec 2023 17:32:28 +0000 (18:32 +0100)
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

src/unix/linux.c

index 48b9c2c43e104079d3ccb5d830d1d79f891fb1a3..91eb4600faf4af5dafda8df2de11422f1120e3f6 100644 (file)
@@ -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);
   }