1io_uring_queue_init(3) liburing Manual io_uring_queue_init(3)
2
3
4
6 io_uring_queue_init - setup io_uring submission and completion queues
7
9 #include <liburing.h>
10
11 int io_uring_queue_init(unsigned entries,
12 struct io_uring *ring,
13 unsigned flags);
14
15 int io_uring_queue_init_params(unsigned entries,
16 struct io_uring *ring,
17 struct io_uring_params *params);
18
20 The io_uring_queue_init(3) function executes the io_uring_setup(2) sys‐
21 tem call to initialize the submission and completion queues in the ker‐
22 nel with at least entries entries in the submission queue and then maps
23 the resulting file descriptor to memory shared between the application
24 and the kernel.
25
26 By default, the CQ ring will have twice the number of entries as speci‐
27 fied by entries for the SQ ring. This is adequate for regular file or
28 storage workloads, but may be too small networked workloads. The SQ
29 ring entries do not impose a limit on the number of in-flight requests
30 that the ring can support, it merely limits the number that can be sub‐
31 mitted to the kernel in one go (batch). if the CQ ring overflows, e.g.
32 more entries are generated than fits in the ring before the application
33 can reap them, then the ring enters a CQ ring overflow state. This is
34 indicated by IORING_SQ_CQ_OVERFLOW being set in the SQ ring flags. Un‐
35 less the kernel runs out of available memory, entries are not dropped,
36 but it is a much slower completion path and will slow down request pro‐
37 cessing. For that reason it should be avoided and the CQ ring sized ap‐
38 propriately for the workload. Setting cq_entries in struct io_ur‐
39 ing_params will tell the kernel to allocate this many entries for the
40 CQ ring, independent of the SQ ring size in given in entries. If the
41 value isn't a power of 2, it will be rounded up to the nearest power of
42 2.
43
44 On success, io_uring_queue_init(3) returns 0 and ring will point to the
45 shared memory containing the io_uring queues. On failure -errno is re‐
46 turned.
47
48 flags will be passed through to the io_uring_setup syscall (see io_ur‐
49 ing_setup(2)).
50
51 If the io_uring_queue_init_params(3) variant is used, then the parame‐
52 ters indicated by params will be passed straight through to the io_ur‐
53 ing_setup(2) system call.
54
55 On success, the resources held by ring should be released via a corre‐
56 sponding call to io_uring_queue_exit(3).
57
59 io_uring_queue_init(3) returns 0 on success and -errno on failure.
60
62 io_uring_setup(2), io_uring_register_ring_fd(3), mmap(2), io_ur‐
63 ing_queue_exit(3)
64
65
66
67liburing-0.7 July 10, 2020 io_uring_queue_init(3)