1io_uring_queue_init(3)          liburing Manual         io_uring_queue_init(3)
2
3
4

NAME

6       io_uring_queue_init - setup io_uring submission and completion queues
7

SYNOPSIS

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
19       int io_uring_queue_init_mem(unsigned entries,
20                                   struct io_uring *ring,
21                                   struct io_uring_params *params,
22                                   void *buf, size_t buf_size);
23

DESCRIPTION

25       The io_uring_queue_init(3) function executes the io_uring_setup(2) sys‐
26       tem call to initialize the submission and completion queues in the ker‐
27       nel with at least entries entries in the submission queue and then maps
28       the resulting file descriptor to memory shared between the  application
29       and the kernel.
30
31       By default, the CQ ring will have twice the number of entries as speci‐
32       fied by entries for the SQ ring. This is adequate for regular  file  or
33       storage workloads, but may be too small for networked workloads. The SQ
34       ring entries do not impose a limit on the number of in-flight  requests
35       that the ring can support, it merely limits the number that can be sub‐
36       mitted to the kernel in one go (batch). if the CQ ring overflows,  e.g.
37       more entries are generated than fits in the ring before the application
38       can reap them, then if the kernel supports IORING_FEAT_NODROP the  ring
39       enters a CQ ring overflow state. Otherwise it drops the CQEs and incre‐
40       ments cq.koverflow in stuct io_uring with the number of  CQEs  dropped.
41       The  overflow  state is indicated by IORING_SQ_CQ_OVERFLOW being set in
42       the SQ ring flags. Unless the kernel runs out of available memory,  en‐
43       tries are not dropped, but it is a much slower completion path and will
44       slow down request processing. For that reason it should be avoided  and
45       the CQ ring sized appropriately for the workload. Setting cq_entries in
46       struct io_uring_params will tell the kernel to allocate this  many  en‐
47       tries  for the CQ ring, independent of the SQ ring size in given in en‐
48       tries.  If the value isn't a power of 2, it will be rounded up  to  the
49       nearest power of 2.
50
51       On success, io_uring_queue_init(3) returns 0 and ring will point to the
52       shared memory containing the io_uring queues. On failure -errno is  re‐
53       turned.
54
55       flags  will be passed through to the io_uring_setup syscall (see io_ur‐
56       ing_setup(2)).
57
58       The io_uring_queue_init_params(3) and io_uring_queue_init_mem(3)  vari‐
59       ants  will  pass the parameters indicated by params straight through to
60       the io_uring_setup(2) system call.
61
62       The io_uring_queue_init_mem(3) variant uses the provided buf with asso‐
63       ciated  size  buf_size  as  the  memory  for  the  ring, using the IOR‐
64       ING_SETUP_NO_MMAP flag to  io_uring_setup(2).   The  buffer  passed  to
65       io_uring_queue_init_mem(3)  must  already  be  zeroed.   Typically, the
66       caller should  allocate  a  huge  page  and  pass  that  in  to  io_ur‐
67       ing_queue_init_mem(3).   Pages  allocated  by  mmap are already zeroed.
68       io_uring_queue_init_mem(3) returns the number of bytes  used  from  the
69       provided buffer, so that the app can reuse the buffer with the returned
70       offset to put more rings in the same huge page.
71
72       On success, the resources held by ring should be released via a  corre‐
73       sponding call to io_uring_queue_exit(3).
74

RETURN VALUE

76       io_uring_queue_init(3)  and  io_uring_queue_init_params(3)  return 0 on
77       success and -errno on failure.
78
79       io_uring_queue_init_mem(3) returns the number of bytes  used  from  the
80       provided buffer on success, and -errno on failure.
81

SEE ALSO

83       io_uring_setup(2),    io_uring_register_ring_fd(3),   mmap(2),   io_ur‐
84       ing_queue_exit(3)
85
86
87
88liburing-0.7                     July 10, 2020          io_uring_queue_init(3)
Impressum