-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
io_uring: Update to kernel changes in 6.11 and 6.12 #23062
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
linusg
reviewed
Mar 3, 2025
Found it failing in a new way on that kernel.
ring.get_probe returns io_uring_probe which can be use to probe capabilities of the current running kernel. Ref: https://unixism.net/loti/ref-liburing/supported_caps.html https://github.com/axboe/liburing/blob/e1003e496e66f9b0ae06674869795edf772d5500/src/setup.c#L454
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
alexrp
approved these changes
Mar 26, 2025
Member
alexrp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems okay from my limited knowledge of io_uring.
linusg
approved these changes
Mar 26, 2025
Collaborator
linusg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too familiar either but LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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.