8

I would like to check whether a Linux machine supports io_uring. How can this be done?

Is there some kernel file that describes support for this, or do all Linux 5.1+ kernels have support?

2

2 Answers 2

13

io_uring doesn’t expose any user-visible features, e.g. as a sysctl; it only exposes new system calls. It is available since kernel 5.1, but support for it can be compiled out, and it might be backported to older kernels in some systems.

The safest way to check for support is therefore to check whether the io_uring system calls are available. If you have /proc/kallsyms, you can look there:

grep io_uring_setup /proc/kallsyms

Another way to check for the system call is to attempt a safe but malformed call, and check whether the resulting error is ENOSYS, for example:

#include <errno.h>
#include <linux/io_uring.h>
#include <stddef.h>
#include <sys/syscall.h>
#include <unistd.h>

int main(int argc, char **argv) {
  if (syscall(__NR_io_uring_register, 0, IORING_UNREGISTER_BUFFERS, NULL, 0) && errno == ENOSYS) {
    // No io_uring
  } else {
    // io_uring
  }
}

On a kernel supporting io_uring, the available operations vary as new features are introduced with new kernel versions; to determine the supported operations, use io_uring_get_probe.

2
  • I've read that some containers disable io_uring. Does this solution also apply when io_uring is disabled in a container? Commented May 22, 2024 at 11:38
  • 2
    Yes, as long as the syscall filter returns ENOSYS (which is how it’s supposed to be done). Commented May 22, 2024 at 11:42
7

It's available from Linux 5.1 and upwards and can be enabled during compiling. In Debian and derivatives you can locate the kernel options used during compilation in file /boot/config-{kernel version}-{arch}. In UEFI machines this path may be different.

So type,
grep -i uring /boot/config-$(uname -r)

The output should include CONFIG_IO_URING, y or n, enable or not.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.