Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions compio-driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,10 @@ pub struct ProactorBuilder {
sqpoll_idle: Option<Duration>,
sqpoll_cpu: Option<u32>,
cqsize: Option<u32>,
single_issuer: bool,
coop_taskrun: bool,
taskrun_flag: bool,
defer_taskrun: bool,
eventfd: Option<RawFd>,
driver_type: Option<DriverType>,
op_flags: OpCodeFlag,
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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.
///
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions compio-driver/src/sys/driver/iour/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Loading