From 57e331db0e221ff2a1acd44663eef6d3324ecefe Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Fri, 7 Jun 2024 23:47:34 +0000 Subject: [PATCH] block: drop the ASYNC flag from io_uring entries The ASYNC flag forces requests to go to worker threads. Worker threads are expensive. Let the kernel decide what to do. With this change, I no longer see an excessive amount of io_uring worker threads. Quote from the manual for io_uring_sqe_set_flags(3): ``` IOSQE_ASYNC Normal operation for io_uring is to try and issue an sqe as non-blocking first, and if that fails, execute it in an async manner. To support more efficient overlapped operation of requests that the application knows/assumes will always (or most of the time) block, the application can ask for an sqe to be issued async from the start. Note that this flag immediately causes the SQE to be offloaded to an async helper thread with no initial non-blocking attempt. This may be less efficient and should not be used liberally or without understanding the performance and efficiency tradeoffs. ``` Signed-off-by: Wei Liu --- block/src/raw_async.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/block/src/raw_async.rs b/block/src/raw_async.rs index 395d768a5..55b7355a6 100644 --- a/block/src/raw_async.rs +++ b/block/src/raw_async.rs @@ -6,7 +6,7 @@ use std::fs::File; use std::io::{Error, Seek, SeekFrom}; use std::os::unix::io::{AsRawFd, RawFd}; -use io_uring::{opcode, squeue, types, IoUring}; +use io_uring::{opcode, types, IoUring}; use vmm_sys_util::eventfd::EventFd; use crate::async_io::{ @@ -91,7 +91,6 @@ impl AsyncIo for RawFileAsync { &opcode::Readv::new(types::Fd(self.fd), iovecs.as_ptr(), iovecs.len() as u32) .offset(offset.try_into().unwrap()) .build() - .flags(squeue::Flags::ASYNC) .user_data(user_data), ) .map_err(|_| AsyncIoError::ReadVectored(Error::other("Submission queue is full")))? @@ -120,7 +119,6 @@ impl AsyncIo for RawFileAsync { &opcode::Writev::new(types::Fd(self.fd), iovecs.as_ptr(), iovecs.len() as u32) .offset(offset.try_into().unwrap()) .build() - .flags(squeue::Flags::ASYNC) .user_data(user_data), ) .map_err(|_| AsyncIoError::WriteVectored(Error::other("Submission queue is full")))? @@ -143,7 +141,6 @@ impl AsyncIo for RawFileAsync { sq.push( &opcode::Fsync::new(types::Fd(self.fd)) .build() - .flags(squeue::Flags::ASYNC) .user_data(user_data), ) .map_err(|_| AsyncIoError::Fsync(Error::other("Submission queue is full")))?