Skip to content

Commit 3236b33

Browse files
authored
Add support for IORING_REGISTER_IOWQ_AFF (#246)
* Add support for IORING_REGISTER_IOWQ_AFF * pass cpu_set_t to register_iowq_aff
1 parent 20f525b commit 3236b33

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/submit.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,30 @@ impl<'a> Submitter<'a> {
396396
.map(drop)
397397
}
398398

399+
/// Tell io_uring on what CPUs the async workers can run. By default, async workers
400+
/// created by io_uring will inherit the CPU mask of its parent. This is usually
401+
/// all the CPUs in the system, unless the parent is being run with a limited set.
402+
pub fn register_iowq_aff(&self, cpu_set: &libc::cpu_set_t) -> io::Result<()> {
403+
execute(
404+
self.fd.as_raw_fd(),
405+
sys::IORING_REGISTER_IOWQ_AFF,
406+
cpu_set as *const _ as *const libc::c_void,
407+
mem::size_of::<libc::cpu_set_t>() as u32,
408+
)
409+
.map(drop)
410+
}
411+
412+
/// Undoes a CPU mask previously set with register_iowq_aff
413+
pub fn unregister_iowq_aff(&self) -> io::Result<()> {
414+
execute(
415+
self.fd.as_raw_fd(),
416+
sys::IORING_UNREGISTER_IOWQ_AFF,
417+
ptr::null(),
418+
0,
419+
)
420+
.map(drop)
421+
}
422+
399423
/// Get and/or set the limit for number of io_uring worker threads per NUMA
400424
/// node. `max[0]` holds the limit for bounded workers, which process I/O
401425
/// operations expected to be bound in time, that is I/O on regular files or

0 commit comments

Comments
 (0)