diff --git a/compio-driver/src/lib.rs b/compio-driver/src/lib.rs index f6f83761..3f82ef22 100644 --- a/compio-driver/src/lib.rs +++ b/compio-driver/src/lib.rs @@ -547,8 +547,10 @@ pub struct ProactorBuilder { sqpoll_idle: Option, sqpoll_cpu: Option, cqsize: Option, + single_issuer: bool, coop_taskrun: bool, taskrun_flag: bool, + defer_taskrun: bool, eventfd: Option, driver_type: Option, op_flags: OpCodeFlag, @@ -577,8 +579,10 @@ impl ProactorBuilder { sqpoll_idle: None, sqpoll_cpu: None, cqsize: None, + single_issuer: false, coop_taskrun: false, taskrun_flag: false, + defer_taskrun: false, eventfd: None, driver_type: None, op_flags: OpCodeFlag::empty(), @@ -678,6 +682,17 @@ impl ProactorBuilder { self } + /// Set the `io-uring` single issuer hint. + /// + /// # Notes + /// + /// - Available since Linux Kernel 6.0. + /// - Only effective when the `io-uring` feature is enabled + pub fn single_issuer(&mut self, enable: bool) -> &mut Self { + self.single_issuer = enable; + self + } + /// Optimize performance for most cases, especially compio is a single /// thread runtime. /// @@ -706,6 +721,22 @@ impl ProactorBuilder { self } + /// Defer io-uring task work until the driver enters the kernel to wait for + /// completions. + /// + /// This is only applied when [`single_issuer`](Self::single_issuer) is + /// enabled. The kernel requires `IORING_SETUP_SINGLE_ISSUER` for + /// `IORING_SETUP_DEFER_TASKRUN`. + /// + /// # Notes + /// + /// - Available since Linux Kernel 6.1. + /// - Only effective when the `io-uring` feature is enabled + pub fn defer_taskrun(&mut self, enable: bool) -> &mut Self { + self.defer_taskrun = enable; + self + } + /// Register an eventfd to io-uring. /// /// # Notes diff --git a/compio-driver/src/sys/driver/iour/mod.rs b/compio-driver/src/sys/driver/iour/mod.rs index 1414f36c..5a08b2d9 100644 --- a/compio-driver/src/sys/driver/iour/mod.rs +++ b/compio-driver/src/sys/driver/iour/mod.rs @@ -73,6 +73,12 @@ impl Driver { io_uring_builder.setup_sqpoll_cpu(cpu); } } + if builder.single_issuer { + io_uring_builder.setup_single_issuer(); + if builder.defer_taskrun { + io_uring_builder.setup_defer_taskrun(); + } + } if builder.coop_taskrun { io_uring_builder.setup_coop_taskrun(); }