Skip to content

Commit

Permalink
Add support for IORING_REGISTER_IOWQ_AFF (#246)
Browse files Browse the repository at this point in the history
* Add support for IORING_REGISTER_IOWQ_AFF

* pass cpu_set_t to register_iowq_aff
  • Loading branch information
mjasny authored Apr 13, 2024
1 parent 20f525b commit 3236b33
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,30 @@ impl<'a> Submitter<'a> {
.map(drop)
}

/// Tell io_uring on what CPUs the async workers can run. By default, async workers
/// created by io_uring will inherit the CPU mask of its parent. This is usually
/// all the CPUs in the system, unless the parent is being run with a limited set.
pub fn register_iowq_aff(&self, cpu_set: &libc::cpu_set_t) -> io::Result<()> {
execute(
self.fd.as_raw_fd(),
sys::IORING_REGISTER_IOWQ_AFF,
cpu_set as *const _ as *const libc::c_void,
mem::size_of::<libc::cpu_set_t>() as u32,
)
.map(drop)
}

/// Undoes a CPU mask previously set with register_iowq_aff
pub fn unregister_iowq_aff(&self) -> io::Result<()> {
execute(
self.fd.as_raw_fd(),
sys::IORING_UNREGISTER_IOWQ_AFF,
ptr::null(),
0,
)
.map(drop)
}

/// Get and/or set the limit for number of io_uring worker threads per NUMA
/// node. `max[0]` holds the limit for bounded workers, which process I/O
/// operations expected to be bound in time, that is I/O on regular files or
Expand Down

0 comments on commit 3236b33

Please sign in to comment.