Skip to content

io_uring: register ring fd and reduce code duplication - #2108

Merged
axboe merged 3 commits into
axboe:masterfrom
calebsander:opt/register-ring-fd
Jun 13, 2026
Merged

axboe merged 3 commits into
axboe:masterfrom
calebsander:opt/register-ring-fd

Conversation

@calebsander

Copy link
Copy Markdown
Contributor

Try to issue IORING_REGISTER_RING_FDS in io_uring queue initialization to register the io_uring's own file descriptor. Use the registered ring fd with IORING_ENTER_REGISTERED_RING for all io_uring_enter() syscalls. This improves performance by avoiding the io_uring file descriptor reference-counting overhead on each io_uring_enter() syscall. IORING_REGISTER_RING_FDS isn't supported on older kernels, so fall back to the existing behavior of passing io_uring_enter() a raw fd if the registration fails.

Also consolidate some initialization functions largely duplicated between the io_uring and io_uring_cmd engines.

fio_ioring_cmd_queue_init() is identical to fio_ioring_queue_init()
except for the additional IORING_SETUP_SQE128 and IORING_SETUP_CQE32
flags. Check for is_uring_cmd_eng in fio_ioring_queue_init() and set
these flags accordingly. Replace fio_ioring_cmd_queue_init() with
fio_ioring_queue_init().

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
fio_ioring_cmd_post_init() is identical to fio_ioring_post_init() except
for the additional handling of 128-byte SQEs. Check for is_uring_cmd_eng
in fio_ioring_post_init() and adjust the SQE size accordingly. Replace
fio_ioring_cmd_post_init() with fio_ioring_post_init().

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Try to issue IORING_REGISTER_RING_FDS in io_uring queue initialization
to register the io_uring's own file descriptor. Use the registered ring
fd with IORING_ENTER_REGISTERED_RING for all io_uring_enter() syscalls.
This improves performance by avoiding the io_uring file descriptor
reference-counting overhead on each io_uring_enter() syscall.
IORING_REGISTER_RING_FDS isn't supported on older kernels, so fall back
to the existing behavior of passing io_uring_enter() a raw fd if the
registration fails.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
@axboe
axboe merged commit 8c3d606 into axboe:master Jun 13, 2026
17 checks passed
@calebsander
calebsander deleted the opt/register-ring-fd branch June 15, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址