Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io_uring: Update to kernel changes in 6.11 and 6.12 #23062

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

ianic
Copy link
Contributor

@ianic ianic commented Mar 3, 2025

io_uring is in active development and each new kernel brings some new features. This is an update to the most important changes from kernels 6.11 and 6.12.

Bind/listen support
IoUring.bind and IoUring.listen functions are added. For listening sockets is it common to set some socket options, so I added generic IoUring.cmd_sock but also posix like IoUring.setsokopt and IoUring.getsockopt.

Probing capabilities
When app has to run on different kernels it is handy to check if some operation is supported on the running kernel.
Example:

const probe = try ring.get_probe();
if (!probe.is_supported(.LISTEN)) return error.SkipZigTest;

Incremental provided buffer consumption
IoUring.BufferGroup will now use incremental consumption whenever kernel supports it.

Before, provided buffers were wholly consumed when picked. Now, each cqe points to a different buffer. With this, cqe points to the part of the buffer. Multiple cqes can reuse the same buffer. Appropriate buffer sizing becomes less important.

There are slight changes in BufferGroup interface (it now needs to track the current receive point for each buffer). Init requires an allocator instead of buffers slice, it will allocate buffers slice and head pointers slice. Get and put now requires cqe because there we have information will the buffer be reused.

ianic added 6 commits March 5, 2025 13:35
Found it failing in a new way on that kernel.
ring.cmd_sock is generic socket operation. Two most common uses are
setsockopt and getsockopt. This provides same interface as posix
versions of this methods.

libring has also [sqe_set_flags](https://man7.org/linux/man-pages/man3/io_uring_sqe_set_flags.3.html)
method. Adding that in our io_uring_sqe. Adding sqe.link_next method for setting most common flag.
[Incremental provided buffer
consumption](https://github.com/axboe/liburing/wiki/What's-new-with-io_uring-in-6.11-and-6.12#incremental-provided-buffer-consumption)
support is added in kernel 6.12.

IoUring.BufferGroup will now use incremental consumption whenever
kernel supports it.

Before, provided buffers are wholly consumed when picked. Each cqe
points to the different buffer. With this, cqe points to the part of the
buffer. Multiple cqe's can reuse same buffer.
Appropriate sizing of buffers becomes less important.

There are slight changes in BufferGroup interface (it now needs to track
current receive point for each buffer). Init requires allocator
instead of buffers slice, it will allocate buffers slice and head
pointers slice. Get and put now requires cqe becasue there we have
information will the buffer be reused.
Use packed struct instead of or-ed integers.

Thanks to @linsug for pr comments: ziglang#23062
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.

3 participants