Skip to content

Conversation

tavianator
Copy link
Contributor

This new function is useful for flags like IORING_SETUP_SINGLE_ISSUER that are useful on kernels that support them, but not necessary on older kernels.


git request-pull output:

The following changes since commit 231d5c2bb11092b421c616ea88a8d2bd8c2b0792:

  Merge branch 'man-fixes' of https://github.com/wlukowicz/liburing (2024-12-01 14:46:47 -0700)

are available in the Git repository at:

  https://github.com/tavianator/liburing try-setup-flags

for you to fetch changes up to 375492c1ba1e084f841c0af49ad73e388ff3c1dd:

  io_uring_try_setup_flags: New function to probe kernel flag support (2024-12-04 14:47:40 -0500)

----------------------------------------------------------------
Tavian Barnes (1):
      io_uring_try_setup_flags: New function to probe kernel flag support

 man/io_uring_try_setup_flags.3 | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 src/include/liburing.h         |  2 ++
 src/liburing.map               |  1 +
 src/setup.c                    | 17 +++++++++++++++++
 test/Makefile                  |  1 +
 test/try-setup-flags.c         | 33 +++++++++++++++++++++++++++++++++
 6 files changed, 101 insertions(+)
 create mode 100644 man/io_uring_try_setup_flags.3
 create mode 100644 test/try-setup-flags.c

By submitting this pull request, I acknowledge that:

  1. I have followed the above pull request guidelines.
  2. I have the rights to submit this work under the same license.
  3. I agree to a Developer Certificate of Origin (see https://developercertificate.org for more information).

This new function is useful for flags like IORING_SETUP_SINGLE_ISSUER
that are useful on kernels that support them, but not necessary on older
kernels.

Signed-off-by: Tavian Barnes <[email protected]>
@tavianator
Copy link
Contributor Author

Gentle ping, @axboe is this potentially useful?

@aeolio
Copy link

aeolio commented Apr 8, 2025

From an application view a bit mask, describing the running kernel's io_uring capabilities, would be more useful.

  • Since this a low level internal function, use the system call directly, not the API setup function. io_uring_queue_init_params() should use your probe function to eliminate probing for IORING_SETUP_NO_SQARRAY itself.
  • Actual probing should happen only once.
  • You might use a binsearch-like algorithm to detect the largest supported flag value, starting with kernel 5.1 maximum on one end, and either the maximum in liburing/io_uring.h or 32 (UINT_MAX) on the other end, then derive a bit mask. This should work, because (a) existing flags are contiguous, and (b) new flags are added at the end of the existing block.

This would limit the number of system calls necessary to set up the first ring instance to 4-5 on average, not much worse than current probing.

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