From a9b107045fb0592f813ffd9f5fef3e2cbfd2ac89 Mon Sep 17 00:00:00 2001 From: Joran Dirk Greef Date: Sat, 3 Oct 2020 14:34:42 +0200 Subject: [PATCH] Use load acquire semantics when reading the SQPOLL wakeup flag Ensures that the wakeup flag is read after the tail pointer has been written. It's important to use memory load acquire semantics for the flags read, otherwise the application and the kernel might not agree on the consistency of the wakeup flag, leading to I/O starvation. Refs: https://github.com/axboe/liburing/commit/6768ddcc562adb6ea141cf508bccecb6be8ce666 Refs: https://github.com/axboe/liburing/issues/219 --- lib/std/os/linux/io_uring.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/os/linux/io_uring.zig b/lib/std/os/linux/io_uring.zig index 8dc59eb82a..b3519c674f 100644 --- a/lib/std/os/linux/io_uring.zig +++ b/lib/std/os/linux/io_uring.zig @@ -247,7 +247,7 @@ pub const IO_Uring = struct { pub fn sq_ring_needs_enter(self: *IO_Uring, submitted: u32, flags: *u32) bool { assert(flags.* == 0); if ((self.flags & linux.IORING_SETUP_SQPOLL) == 0 and submitted > 0) return true; - if ((@atomicLoad(u32, self.sq.flags, .Unordered) & linux.IORING_SQ_NEED_WAKEUP) != 0) { + if ((@atomicLoad(u32, self.sq.flags, .Acquire) & linux.IORING_SQ_NEED_WAKEUP) != 0) { flags.* |= linux.IORING_ENTER_SQ_WAKEUP; return true; }