1IO_URING_ENTER(2) Linux Programmer's Manual IO_URING_ENTER(2)
2
3
4
6 io_uring_enter - initiate and/or complete asynchronous I/O
7
9 #include <linux/io_uring.h>
10
11 int io_uring_enter(unsigned int fd, unsigned int to_submit,
12 unsigned int min_complete, unsigned int flags,
13 sigset_t *sig);
14
16 io_uring_enter() is used to initiate and complete I/O using the shared
17 submission and completion queues setup by a call to io_uring_setup(2).
18 A single call can both submit new I/O and wait for completions of I/O
19 initiated by this call or previous calls to io_uring_enter().
20
21 fd is the file descriptor returned by io_uring_setup(2). to_submit
22 specifies the number of I/Os to submit from the submission queue. If
23 the IORING_ENTER_GETEVENTS bit is set in flags, then the system call
24 will attempt to wait for min_complete event completions before return‐
25 ing. If the io_uring instance was configured for polling, by specify‐
26 ing IORING_SETUP_IOPOLL in the call to io_uring_setup(2), then min_com‐
27 plete has a slightly different meaning. Passing a value of 0 instructs
28 the kernel to return any events which are already complete, without
29 blocking. If min_complete is a non-zero value, the kernel will still
30 return immediately if any completion events are available. If no event
31 completions are available, then the call will poll either until one or
32 more completions become available, or until the process has exceeded
33 its scheduler time slice.
34
35 Note that, for interrupt driven I/O (where IORING_SETUP_IOPOLL was not
36 specified in the call to io_uring_setup(2)), an application may check
37 the completion queue for event completions without entering the kernel
38 at all.
39
40 When the system call returns that a certain amount of SQEs have been
41 consumed and submitted, it's safe to reuse SQE entries in the ring.
42 This is true even if the actual IO submission had to be punted to async
43 context, which means that the SQE may in fact not have been submitted
44 yet. If the kernel requires later use of a particular SQE entry, it
45 will have made a private copy of it.
46
47 sig is a pointer to a signal mask (see sigprocmask(2)); if sig is not
48 NULL, io_uring_enter() first replaces the current signal mask by the
49 one pointed to by sig, then waits for events to become available in the
50 completion queue, and then restores the original signal mask. The fol‐
51 lowing io_uring_enter() call:
52
53 ret = io_uring_enter(fd, 0, 1, IORING_ENTER_GETEVENTS, &sig);
54
55 is equivalent to atomically executing the following calls:
56
57 pthread_sigmask(SIG_SETMASK, &sig, &orig);
58 ret = io_uring_enter(fd, 0, 1, IORING_ENTER_GETEVENTS, NULL);
59 pthread_sigmask(SIG_SETMASK, &orig, NULL);
60
61 See the description of pselect(2) for an explanation of why the sig
62 parameter