polyphony 0.84 → 0.86

Sign up to get free protection for your applications and to get access to all the features.
Files changed (241) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/Gemfile.lock +1 -1
  4. data/Rakefile +1 -1
  5. data/examples/core/multi_suspend.rb +39 -0
  6. data/examples/core/shutdown_all_children.rb +41 -0
  7. data/examples/io/gzip.rb +8 -0
  8. data/examples/io/splice_echo_server.rb +15 -0
  9. data/ext/polyphony/backend_io_uring.c +57 -31
  10. data/ext/polyphony/io_extensions.c +137 -26
  11. data/lib/polyphony/extensions/fiber.rb +3 -1
  12. data/lib/polyphony/extensions/io.rb +4 -0
  13. data/lib/polyphony/extensions/pipe.rb +4 -0
  14. data/lib/polyphony/extensions/socket.rb +4 -0
  15. data/lib/polyphony/version.rb +1 -1
  16. data/polyphony.gemspec +1 -1
  17. data/test/test_backend.rb +1 -1
  18. data/test/test_fiber.rb +5 -2
  19. data/test/test_signal.rb +3 -3
  20. data/vendor/liburing/.github/pull_request_template.md +86 -0
  21. data/vendor/liburing/.github/workflows/build.yml +85 -0
  22. data/vendor/liburing/.github/workflows/shellcheck.yml +20 -0
  23. data/vendor/liburing/.gitignore +149 -0
  24. data/vendor/liburing/COPYING +502 -0
  25. data/vendor/liburing/COPYING.GPL +339 -0
  26. data/vendor/liburing/LICENSE +7 -0
  27. data/vendor/liburing/Makefile +82 -0
  28. data/vendor/liburing/Makefile.common +5 -0
  29. data/vendor/liburing/Makefile.quiet +11 -0
  30. data/vendor/liburing/README +46 -0
  31. data/vendor/liburing/configure +486 -0
  32. data/vendor/liburing/debian/README.Debian +7 -0
  33. data/vendor/liburing/debian/changelog +27 -0
  34. data/vendor/liburing/debian/compat +1 -0
  35. data/vendor/liburing/debian/control +48 -0
  36. data/vendor/liburing/debian/copyright +49 -0
  37. data/vendor/liburing/debian/liburing-dev.install +4 -0
  38. data/vendor/liburing/debian/liburing-dev.manpages +6 -0
  39. data/vendor/liburing/debian/liburing1-udeb.install +1 -0
  40. data/vendor/liburing/debian/liburing1.install +1 -0
  41. data/vendor/liburing/debian/liburing1.symbols +32 -0
  42. data/vendor/liburing/debian/patches/series +1 -0
  43. data/vendor/liburing/debian/rules +81 -0
  44. data/vendor/liburing/debian/source/format +1 -0
  45. data/vendor/liburing/debian/source/local-options +2 -0
  46. data/vendor/liburing/debian/source/options +1 -0
  47. data/vendor/liburing/debian/watch +3 -0
  48. data/vendor/liburing/examples/Makefile +38 -0
  49. data/vendor/liburing/examples/io_uring-cp.c +282 -0
  50. data/vendor/liburing/examples/io_uring-test.c +112 -0
  51. data/vendor/liburing/examples/link-cp.c +193 -0
  52. data/vendor/liburing/examples/ucontext-cp.c +273 -0
  53. data/vendor/liburing/liburing.pc.in +12 -0
  54. data/vendor/liburing/liburing.spec +66 -0
  55. data/vendor/liburing/make-debs.sh +53 -0
  56. data/vendor/liburing/man/io_uring.7 +754 -0
  57. data/vendor/liburing/man/io_uring_cq_advance.3 +35 -0
  58. data/vendor/liburing/man/io_uring_cq_ready.3 +25 -0
  59. data/vendor/liburing/man/io_uring_cqe_get_data.3 +34 -0
  60. data/vendor/liburing/man/io_uring_cqe_seen.3 +32 -0
  61. data/vendor/liburing/man/io_uring_enter.2 +1483 -0
  62. data/vendor/liburing/man/io_uring_free_probe.3 +24 -0
  63. data/vendor/liburing/man/io_uring_get_probe.3 +29 -0
  64. data/vendor/liburing/man/io_uring_get_sqe.3 +38 -0
  65. data/vendor/liburing/man/io_uring_opcode_supported.3 +29 -0
  66. data/vendor/liburing/man/io_uring_prep_msg_ring.3 +58 -0
  67. data/vendor/liburing/man/io_uring_prep_read.3 +50 -0
  68. data/vendor/liburing/man/io_uring_prep_read_fixed.3 +54 -0
  69. data/vendor/liburing/man/io_uring_prep_readv.3 +51 -0
  70. data/vendor/liburing/man/io_uring_prep_readv2.3 +79 -0
  71. data/vendor/liburing/man/io_uring_prep_write.3 +50 -0
  72. data/vendor/liburing/man/io_uring_prep_write_fixed.3 +54 -0
  73. data/vendor/liburing/man/io_uring_prep_writev.3 +51 -0
  74. data/vendor/liburing/man/io_uring_prep_writev2.3 +78 -0
  75. data/vendor/liburing/man/io_uring_queue_exit.3 +27 -0
  76. data/vendor/liburing/man/io_uring_queue_init.3 +44 -0
  77. data/vendor/liburing/man/io_uring_register.2 +688 -0
  78. data/vendor/liburing/man/io_uring_register_buffers.3 +41 -0
  79. data/vendor/liburing/man/io_uring_register_files.3 +35 -0
  80. data/vendor/liburing/man/io_uring_setup.2 +534 -0
  81. data/vendor/liburing/man/io_uring_sq_ready.3 +25 -0
  82. data/vendor/liburing/man/io_uring_sq_space_left.3 +25 -0
  83. data/vendor/liburing/man/io_uring_sqe_set_data.3 +30 -0
  84. data/vendor/liburing/man/io_uring_sqe_set_flags.3 +60 -0
  85. data/vendor/liburing/man/io_uring_sqring_wait.3 +30 -0
  86. data/vendor/liburing/man/io_uring_submit.3 +29 -0
  87. data/vendor/liburing/man/io_uring_submit_and_wait.3 +34 -0
  88. data/vendor/liburing/man/io_uring_submit_and_wait_timeout.3 +49 -0
  89. data/vendor/liburing/man/io_uring_unregister_buffers.3 +26 -0
  90. data/vendor/liburing/man/io_uring_unregister_files.3 +26 -0
  91. data/vendor/liburing/man/io_uring_wait_cqe.3 +33 -0
  92. data/vendor/liburing/man/io_uring_wait_cqe_nr.3 +36 -0
  93. data/vendor/liburing/man/io_uring_wait_cqe_timeout.3 +39 -0
  94. data/vendor/liburing/man/io_uring_wait_cqes.3 +46 -0
  95. data/vendor/liburing/src/Makefile +89 -0
  96. data/vendor/liburing/src/arch/aarch64/syscall.h +95 -0
  97. data/vendor/liburing/src/arch/generic/lib.h +21 -0
  98. data/vendor/liburing/src/arch/generic/syscall.h +87 -0
  99. data/vendor/liburing/src/arch/syscall-defs.h +67 -0
  100. data/vendor/liburing/src/arch/x86/lib.h +32 -0
  101. data/vendor/liburing/src/arch/x86/syscall.h +160 -0
  102. data/vendor/liburing/src/include/liburing/barrier.h +81 -0
  103. data/vendor/liburing/src/include/liburing/io_uring.h +442 -0
  104. data/vendor/liburing/src/include/liburing.h +921 -0
  105. data/vendor/liburing/src/int_flags.h +8 -0
  106. data/vendor/liburing/src/lib.h +57 -0
  107. data/vendor/liburing/src/liburing.map +53 -0
  108. data/vendor/liburing/src/nolibc.c +48 -0
  109. data/vendor/liburing/src/queue.c +403 -0
  110. data/vendor/liburing/src/register.c +293 -0
  111. data/vendor/liburing/src/setup.c +332 -0
  112. data/vendor/liburing/src/syscall.c +47 -0
  113. data/vendor/liburing/src/syscall.h +103 -0
  114. data/vendor/liburing/test/232c93d07b74-test.c +306 -0
  115. data/vendor/liburing/test/35fa71a030ca-test.c +329 -0
  116. data/vendor/liburing/test/500f9fbadef8-test.c +89 -0
  117. data/vendor/liburing/test/7ad0e4b2f83c-test.c +93 -0
  118. data/vendor/liburing/test/8a9973408177-test.c +106 -0
  119. data/vendor/liburing/test/917257daa0fe-test.c +53 -0
  120. data/vendor/liburing/test/Makefile +244 -0
  121. data/vendor/liburing/test/a0908ae19763-test.c +58 -0
  122. data/vendor/liburing/test/a4c0b3decb33-test.c +180 -0
  123. data/vendor/liburing/test/accept-link.c +254 -0
  124. data/vendor/liburing/test/accept-reuse.c +164 -0
  125. data/vendor/liburing/test/accept-test.c +79 -0
  126. data/vendor/liburing/test/accept.c +477 -0
  127. data/vendor/liburing/test/across-fork.c +283 -0
  128. data/vendor/liburing/test/b19062a56726-test.c +53 -0
  129. data/vendor/liburing/test/b5837bd5311d-test.c +77 -0
  130. data/vendor/liburing/test/ce593a6c480a-test.c +136 -0
  131. data/vendor/liburing/test/close-opath.c +122 -0
  132. data/vendor/liburing/test/config +10 -0
  133. data/vendor/liburing/test/connect.c +398 -0
  134. data/vendor/liburing/test/cq-full.c +96 -0
  135. data/vendor/liburing/test/cq-overflow.c +294 -0
  136. data/vendor/liburing/test/cq-peek-batch.c +102 -0
  137. data/vendor/liburing/test/cq-ready.c +94 -0
  138. data/vendor/liburing/test/cq-size.c +64 -0
  139. data/vendor/liburing/test/d4ae271dfaae-test.c +96 -0
  140. data/vendor/liburing/test/d77a67ed5f27-test.c +65 -0
  141. data/vendor/liburing/test/defer.c +307 -0
  142. data/vendor/liburing/test/double-poll-crash.c +185 -0
  143. data/vendor/liburing/test/drop-submit.c +92 -0
  144. data/vendor/liburing/test/eeed8b54e0df-test.c +114 -0
  145. data/vendor/liburing/test/empty-eownerdead.c +45 -0
  146. data/vendor/liburing/test/eventfd-disable.c +151 -0
  147. data/vendor/liburing/test/eventfd-reg.c +76 -0
  148. data/vendor/liburing/test/eventfd-ring.c +97 -0
  149. data/vendor/liburing/test/eventfd.c +112 -0
  150. data/vendor/liburing/test/exec-target.c +6 -0
  151. data/vendor/liburing/test/exit-no-cleanup.c +117 -0
  152. data/vendor/liburing/test/fadvise.c +202 -0
  153. data/vendor/liburing/test/fallocate.c +249 -0
  154. data/vendor/liburing/test/fc2a85cb02ef-test.c +131 -0
  155. data/vendor/liburing/test/file-register.c +858 -0
  156. data/vendor/liburing/test/file-update.c +173 -0
  157. data/vendor/liburing/test/file-verify.c +629 -0
  158. data/vendor/liburing/test/files-exit-hang-poll.c +128 -0
  159. data/vendor/liburing/test/files-exit-hang-timeout.c +134 -0
  160. data/vendor/liburing/test/fixed-link.c +90 -0
  161. data/vendor/liburing/test/fpos.c +252 -0
  162. data/vendor/liburing/test/fsync.c +224 -0
  163. data/vendor/liburing/test/hardlink.c +136 -0
  164. data/vendor/liburing/test/helpers.c +135 -0
  165. data/vendor/liburing/test/helpers.h +67 -0
  166. data/vendor/liburing/test/io-cancel.c +550 -0
  167. data/vendor/liburing/test/io_uring_enter.c +296 -0
  168. data/vendor/liburing/test/io_uring_register.c +676 -0
  169. data/vendor/liburing/test/io_uring_setup.c +192 -0
  170. data/vendor/liburing/test/iopoll.c +372 -0
  171. data/vendor/liburing/test/lfs-openat-write.c +119 -0
  172. data/vendor/liburing/test/lfs-openat.c +275 -0
  173. data/vendor/liburing/test/link-timeout.c +1107 -0
  174. data/vendor/liburing/test/link.c +496 -0
  175. data/vendor/liburing/test/link_drain.c +229 -0
  176. data/vendor/liburing/test/madvise.c +195 -0
  177. data/vendor/liburing/test/mkdir.c +108 -0
  178. data/vendor/liburing/test/msg-ring.c +234 -0
  179. data/vendor/liburing/test/multicqes_drain.c +387 -0
  180. data/vendor/liburing/test/nop-all-sizes.c +99 -0
  181. data/vendor/liburing/test/nop.c +115 -0
  182. data/vendor/liburing/test/open-close.c +261 -0
  183. data/vendor/liburing/test/openat2.c +308 -0
  184. data/vendor/liburing/test/personality.c +204 -0
  185. data/vendor/liburing/test/pipe-eof.c +83 -0
  186. data/vendor/liburing/test/pipe-reuse.c +105 -0
  187. data/vendor/liburing/test/poll-cancel-ton.c +135 -0
  188. data/vendor/liburing/test/poll-cancel.c +228 -0
  189. data/vendor/liburing/test/poll-link.c +230 -0
  190. data/vendor/liburing/test/poll-many.c +208 -0
  191. data/vendor/liburing/test/poll-mshot-update.c +273 -0
  192. data/vendor/liburing/test/poll-ring.c +48 -0
  193. data/vendor/liburing/test/poll-v-poll.c +353 -0
  194. data/vendor/liburing/test/poll.c +109 -0
  195. data/vendor/liburing/test/pollfree.c +426 -0
  196. data/vendor/liburing/test/probe.c +135 -0
  197. data/vendor/liburing/test/read-write.c +876 -0
  198. data/vendor/liburing/test/register-restrictions.c +633 -0
  199. data/vendor/liburing/test/rename.c +135 -0
  200. data/vendor/liburing/test/ring-leak.c +173 -0
  201. data/vendor/liburing/test/ring-leak2.c +249 -0
  202. data/vendor/liburing/test/rsrc_tags.c +449 -0
  203. data/vendor/liburing/test/runtests-loop.sh +16 -0
  204. data/vendor/liburing/test/runtests.sh +170 -0
  205. data/vendor/liburing/test/rw_merge_test.c +97 -0
  206. data/vendor/liburing/test/self.c +91 -0
  207. data/vendor/liburing/test/send_recv.c +286 -0
  208. data/vendor/liburing/test/send_recvmsg.c +345 -0
  209. data/vendor/liburing/test/sendmsg_fs_cve.c +200 -0
  210. data/vendor/liburing/test/shared-wq.c +84 -0
  211. data/vendor/liburing/test/short-read.c +75 -0
  212. data/vendor/liburing/test/shutdown.c +165 -0
  213. data/vendor/liburing/test/sigfd-deadlock.c +74 -0
  214. data/vendor/liburing/test/skip-cqe.c +429 -0
  215. data/vendor/liburing/test/socket-rw-eagain.c +158 -0
  216. data/vendor/liburing/test/socket-rw-offset.c +157 -0
  217. data/vendor/liburing/test/socket-rw.c +145 -0
  218. data/vendor/liburing/test/splice.c +512 -0
  219. data/vendor/liburing/test/sq-full-cpp.cc +45 -0
  220. data/vendor/liburing/test/sq-full.c +45 -0
  221. data/vendor/liburing/test/sq-poll-dup.c +204 -0
  222. data/vendor/liburing/test/sq-poll-kthread.c +169 -0
  223. data/vendor/liburing/test/sq-poll-share.c +137 -0
  224. data/vendor/liburing/test/sq-space_left.c +159 -0
  225. data/vendor/liburing/test/sqpoll-cancel-hang.c +157 -0
  226. data/vendor/liburing/test/sqpoll-disable-exit.c +196 -0
  227. data/vendor/liburing/test/sqpoll-exit-hang.c +78 -0
  228. data/vendor/liburing/test/sqpoll-sleep.c +69 -0
  229. data/vendor/liburing/test/statx.c +172 -0
  230. data/vendor/liburing/test/stdout.c +232 -0
  231. data/vendor/liburing/test/submit-link-fail.c +154 -0
  232. data/vendor/liburing/test/submit-reuse.c +239 -0
  233. data/vendor/liburing/test/symlink.c +116 -0
  234. data/vendor/liburing/test/teardowns.c +58 -0
  235. data/vendor/liburing/test/thread-exit.c +143 -0
  236. data/vendor/liburing/test/timeout-new.c +252 -0
  237. data/vendor/liburing/test/timeout-overflow.c +204 -0
  238. data/vendor/liburing/test/timeout.c +1523 -0
  239. data/vendor/liburing/test/unlink.c +112 -0
  240. data/vendor/liburing/test/wakeup-hang.c +162 -0
  241. metadata +227 -2
@@ -0,0 +1,41 @@
1
+ .\" Copyright (C) 2021 Stefan Roesch <shr@fb.com>
2
+ .\"
3
+ .\" SPDX-License-Identifier: LGPL-2.0-or-later
4
+ .\"
5
+ .TH io_uring_register_buffers 3 "November 15, 2021" "liburing-2.1" "liburing Manual"
6
+ .SH NAME
7
+ io_uring_register_buffers - register buffers for fixed buffer operations
8
+ .fi
9
+ .SH SYNOPSIS
10
+ .nf
11
+ .BR "#include <liburing.h>"
12
+ .PP
13
+ .BI "int io_uring_register_buffers(struct io_uring *ring,"
14
+ .BI " const struct iovec *iovecs,
15
+ .BI " unsigned nr_iovecs)"
16
+ .PP
17
+ .SH DESCRIPTION
18
+ .PP
19
+ The io_uring_register_buffers() function registers
20
+ .I nr_iovecs
21
+ number of buffers defined by the array
22
+ .I iovecs
23
+ belonging to the
24
+ .I ring.
25
+
26
+ After the caller has registered the buffers, they can be used with one of the
27
+ fixed buffers functions.
28
+
29
+ Registered buffers is an optimization that is useful in conjunction with
30
+ .B O_DIRECT
31
+ reads and writes, where maps the specified range into the kernel once when
32
+ the buffer is registered, rather than doing a map and unmap for each IO
33
+ every time IO is performed to that region. Additionally, it also avoids
34
+ manipulating the page reference counts for each IO.
35
+
36
+ .SH RETURN VALUE
37
+ On success
38
+ .BR io_uring_register_buffers (3)
39
+ returns 0. On failure it returns -errno.
40
+ .SH SEE ALSO
41
+ .BR io_uring_get_sqe (3), io_uring_unregister_buffers (3), io_uring_prep_read_fixed (3), io_uring_prep_write_fixed (3)
@@ -0,0 +1,35 @@
1
+ .\" Copyright (C) 2021 Stefan Roesch <shr@fb.com>
2
+ .\"
3
+ .\" SPDX-License-Identifier: LGPL-2.0-or-later
4
+ .\"
5
+ .TH io_uring_register_files 3 "November 15, 2021" "liburing-2.1" "liburing Manual"
6
+ .SH NAME
7
+ io_uring_register_files - register file descriptors
8
+ .fi
9
+ .SH SYNOPSIS
10
+ .nf
11
+ .BR "#include <liburing.h>"
12
+ .PP
13
+ .BI "int io_uring_register_files(struct io_uring *ring,"
14
+ .BI " const int *files,"
15
+ .BI " unsigned nr_files)"
16
+ .PP
17
+ .SH DESCRIPTION
18
+ .PP
19
+ The io_uring_register_files() function registers
20
+ .I nr_files
21
+ number of file descriptors defined by the array
22
+ .I files
23
+ belonging to the
24
+ .I ring
25
+ for subsequent operations.
26
+
27
+ After the caller has registered the buffers, they can be used with the
28
+ submission queue polling operations.
29
+
30
+ .SH RETURN VALUE
31
+ On success
32
+ .BR io_uring_register_files (3)
33
+ returns 0. On failure it returns -errno.
34
+ .SH SEE ALSO
35
+ .BR io_uring_get_sqe (3), io_uring_unregister_files (3)
@@ -0,0 +1,534 @@
1
+ .\" Copyright (C) 2019 Jens Axboe <axboe@kernel.dk>
2
+ .\" Copyright (C) 2019 Jon Corbet <corbet@lwn.net>
3
+ .\" Copyright (C) 2019 Red Hat, Inc.
4
+ .\"
5
+ .\" SPDX-License-Identifier: LGPL-2.0-or-later
6
+ .\"
7
+ .TH IO_URING_SETUP 2 2019-01-29 "Linux" "Linux Programmer's Manual"
8
+ .SH NAME
9
+ io_uring_setup \- setup a context for performing asynchronous I/O
10
+ .SH SYNOPSIS
11
+ .nf
12
+ .BR "#include <linux/io_uring.h>"
13
+ .PP
14
+ .BI "int io_uring_setup(u32 " entries ", struct io_uring_params *" p );
15
+ .fi
16
+ .PP
17
+ .SH DESCRIPTION
18
+ .PP
19
+ The io_uring_setup() system call sets up a submission queue (SQ) and
20
+ completion queue (CQ) with at least
21
+ .I entries
22
+ entries, and returns a file descriptor which can be used to perform
23
+ subsequent operations on the io_uring instance. The submission and
24
+ completion queues are shared between userspace and the kernel, which
25
+ eliminates the need to copy data when initiating and completing I/O.
26
+
27
+ .I params
28
+ is used by the application to pass options to the kernel, and by the
29
+ kernel to convey information about the ring buffers.
30
+ .PP
31
+ .in +4n
32
+ .EX
33
+ struct io_uring_params {
34
+ __u32 sq_entries;
35
+ __u32 cq_entries;
36
+ __u32 flags;
37
+ __u32 sq_thread_cpu;
38
+ __u32 sq_thread_idle;
39
+ __u32 features;
40
+ __u32 wq_fd;
41
+ __u32 resv[3];
42
+ struct io_sqring_offsets sq_off;
43
+ struct io_cqring_offsets cq_off;
44
+ };
45
+ .EE
46
+ .in
47
+ .PP
48
+ The
49
+ .IR flags ,
50
+ .IR sq_thread_cpu ,
51
+ and
52
+ .I sq_thread_idle
53
+ fields are used to configure the io_uring instance.
54
+ .I flags
55
+ is a bit mask of 0 or more of the following values ORed
56
+ together:
57
+ .TP
58
+ .B IORING_SETUP_IOPOLL
59
+ Perform busy-waiting for an I/O completion, as opposed to getting
60
+ notifications via an asynchronous IRQ (Interrupt Request). The file
61
+ system (if any) and block device must support polling in order for
62
+ this to work. Busy-waiting provides lower latency, but may consume
63
+ more CPU resources than interrupt driven I/O. Currently, this feature
64
+ is usable only on a file descriptor opened using the
65
+ .B O_DIRECT
66
+ flag. When a read or write is submitted to a polled context, the
67
+ application must poll for completions on the CQ ring by calling
68
+ .BR io_uring_enter (2).
69
+ It is illegal to mix and match polled and non-polled I/O on an io_uring
70
+ instance.
71
+
72
+ .TP
73
+ .B IORING_SETUP_SQPOLL
74
+ When this flag is specified, a kernel thread is created to perform
75
+ submission queue polling. An io_uring instance configured in this way
76
+ enables an application to issue I/O without ever context switching
77
+ into the kernel. By using the submission queue to fill in new
78
+ submission queue entries and watching for completions on the
79
+ completion queue, the application can submit and reap I/Os without
80
+ doing a single system call.
81
+
82
+ If the kernel thread is idle for more than
83
+ .I sq_thread_idle
84
+ milliseconds, it will set the
85
+ .B IORING_SQ_NEED_WAKEUP
86
+ bit in the
87
+ .I flags
88
+ field of the
89
+ .IR "struct io_sq_ring" .
90
+ When this happens, the application must call
91
+ .BR io_uring_enter (2)
92
+ to wake the kernel thread. If I/O is kept busy, the kernel thread
93
+ will never sleep. An application making use of this feature will need
94
+ to guard the
95
+ .BR io_uring_enter (2)
96
+ call with the following code sequence:
97
+
98
+ .in +4n
99
+ .EX
100
+ /*
101
+ * Ensure that the wakeup flag is read after the tail pointer
102
+ * has been written. It's important to use memory load acquire
103
+ * semantics for the flags read, as otherwise the application
104
+ * and the kernel might not agree on the consistency of the
105
+ * wakeup flag.
106
+ */
107
+ unsigned flags = atomic_load_relaxed(sq_ring->flags);
108
+ if (flags & IORING_SQ_NEED_WAKEUP)
109
+ io_uring_enter(fd, 0, 0, IORING_ENTER_SQ_WAKEUP);
110
+ .EE
111
+ .in
112
+
113
+ where
114
+ .I sq_ring
115
+ is a submission queue ring setup using the
116
+ .I struct io_sqring_offsets
117
+ described below.
118
+ .TP
119
+ .BR
120
+ Before version 5.11 of the Linux kernel, to successfully use this feature, the
121
+ application must register a set of files to be used for IO through
122
+ .BR io_uring_register (2)
123
+ using the
124
+ .B IORING_REGISTER_FILES
125
+ opcode. Failure to do so will result in submitted IO being errored with
126
+ .B EBADF.
127
+ The presence of this feature can be detected by the
128
+ .B IORING_FEAT_SQPOLL_NONFIXED
129
+ feature flag.
130
+ In version 5.11 and later, it is no longer necessary to register files to use
131
+ this feature. 5.11 also allows using this as non-root, if the user has the
132
+ .B CAP_SYS_NICE
133
+ capability.
134
+ .TP
135
+ .B IORING_SETUP_SQ_AFF
136
+ If this flag is specified, then the poll thread will be bound to the
137
+ cpu set in the
138
+ .I sq_thread_cpu
139
+ field of the
140
+ .IR "struct io_uring_params" .
141
+ This flag is only meaningful when
142
+ .B IORING_SETUP_SQPOLL
143
+ is specified. When cgroup setting
144
+ .I cpuset.cpus
145
+ changes (typically in container environment), the bounded cpu set may be
146
+ changed as well.
147
+ .TP
148
+ .B IORING_SETUP_CQSIZE
149
+ Create the completion queue with
150
+ .IR "struct io_uring_params.cq_entries"
151
+ entries. The value must be greater than
152
+ .IR entries ,
153
+ and may be rounded up to the next power-of-two.
154
+ .TP
155
+ .B IORING_SETUP_CLAMP
156
+ If this flag is specified, and if
157
+ .IR entries
158
+ exceeds
159
+ .B IORING_MAX_ENTRIES ,
160
+ then
161
+ .IR entries
162
+ will be clamped at
163
+ .B IORING_MAX_ENTRIES .
164
+ If the flag
165
+ .BR IORING_SETUP_SQPOLL
166
+ is set, and if the value of
167
+ .IR "struct io_uring_params.cq_entries"
168
+ exceeds
169
+ .B IORING_MAX_CQ_ENTRIES ,
170
+ then it will be clamped at
171
+ .B IORING_MAX_CQ_ENTRIES .
172
+ .TP
173
+ .B IORING_SETUP_ATTACH_WQ
174
+ This flag should be set in conjunction with
175
+ .IR "struct io_uring_params.wq_fd"
176
+ being set to an existing io_uring ring file descriptor. When set, the
177
+ io_uring instance being created will share the asynchronous worker
178
+ thread backend of the specified io_uring ring, rather than create a new
179
+ separate thread pool.
180
+ .TP
181
+ .B IORING_SETUP_R_DISABLED
182
+ If this flag is specified, the io_uring ring starts in a disabled state.
183
+ In this state, restrictions can be registered, but submissions are not allowed.
184
+ See
185
+ .BR io_uring_register (2)
186
+ for details on how to enable the ring. Available since 5.10.
187
+ .TP
188
+ .B IORING_SETUP_SUBMIT_ALL
189
+ Normally io_uring stops submitting a batch of request, if one of these requests
190
+ results in an error. This can cause submission of less than what is expected,
191
+ if a request ends in error while being submitted. If the ring is creted with
192
+ this flag,
193
+ .BR io_uring_enter (2)
194
+ will continue submitting requests even if it encounters an error submitting
195
+ a request. CQEs are still posted for errored request regardless of whether or
196
+ not this flag is set at ring creation time, the only difference is if the
197
+ submit sequence is halted or continued when an error is observed. Available
198
+ since 5.18.
199
+ .PP
200
+ If no flags are specified, the io_uring instance is setup for
201
+ interrupt driven I/O. I/O may be submitted using
202
+ .BR io_uring_enter (2)
203
+ and can be reaped by polling the completion queue.
204
+
205
+ The
206
+ .I resv
207
+ array must be initialized to zero.
208
+
209
+ .I features
210
+ is filled in by the kernel, which specifies various features supported
211
+ by current kernel version.
212
+ .TP
213
+ .B IORING_FEAT_SINGLE_MMAP
214
+ If this flag is set, the two SQ and CQ rings can be mapped with a single
215
+ .I mmap(2)
216
+ call. The SQEs must still be allocated separately. This brings the necessary
217
+ .I mmap(2)
218
+ calls down from three to two. Available since kernel 5.4.
219
+ .TP
220
+ .B IORING_FEAT_NODROP
221
+ If this flag is set, io_uring supports never dropping completion events.
222
+ If a completion event occurs and the CQ ring is full, the kernel stores
223
+ the event internally until such a time that the CQ ring has room for more
224
+ entries. If this overflow condition is entered, attempting to submit more
225
+ IO will fail with the
226
+ .B -EBUSY
227
+ error value, if it can't flush the overflown events to the CQ ring. If this
228
+ happens, the application must reap events from the CQ ring and attempt the
229
+ submit again. Available since kernel 5.5.
230
+ .TP
231
+ .B IORING_FEAT_SUBMIT_STABLE
232
+ If this flag is set, applications can be certain that any data for
233
+ async offload has been consumed when the kernel has consumed the SQE. Available
234
+ since kernel 5.5.
235
+ .TP
236
+ .B IORING_FEAT_RW_CUR_POS
237
+ If this flag is set, applications can specify
238
+ .I offset
239
+ ==
240
+ .B -1
241
+ with
242
+ .B IORING_OP_{READV,WRITEV}
243
+ ,
244
+ .B IORING_OP_{READ,WRITE}_FIXED
245
+ , and
246
+ .B IORING_OP_{READ,WRITE}
247
+ to mean current file position, which behaves like
248
+ .I preadv2(2)
249
+ and
250
+ .I pwritev2(2)
251
+ with
252
+ .I offset
253
+ ==
254
+ .B -1.
255
+ It'll use (and update) the current file position. This obviously comes
256
+ with the caveat that if the application has multiple reads or writes in flight,
257
+ then the end result will not be as expected. This is similar to threads sharing
258
+ a file descriptor and doing IO using the current file position. Available since
259
+ kernel 5.6.
260
+ .TP
261
+ .B IORING_FEAT_CUR_PERSONALITY
262
+ If this flag is set, then io_uring guarantees that both sync and async
263
+ execution of a request assumes the credentials of the task that called
264
+ .I
265
+ io_uring_enter(2)
266
+ to queue the requests. If this flag isn't set, then requests are issued with
267
+ the credentials of the task that originally registered the io_uring. If only
268
+ one task is using a ring, then this flag doesn't matter as the credentials
269
+ will always be the same. Note that this is the default behavior, tasks can
270
+ still register different personalities through
271
+ .I
272
+ io_uring_register(2)
273
+ with
274
+ .B IORING_REGISTER_PERSONALITY
275
+ and specify the personality to use in the sqe. Available since kernel 5.6.
276
+ .TP
277
+ .B IORING_FEAT_FAST_POLL
278
+ If this flag is set, then io_uring supports using an internal poll mechanism
279
+ to drive data/space readiness. This means that requests that cannot read or
280
+ write data to a file no longer need to be punted to an async thread for
281
+ handling, instead they will begin operation when the file is ready. This is
282
+ similar to doing poll + read/write in userspace, but eliminates the need to do
283
+ so. If this flag is set, requests waiting on space/data consume a lot less
284
+ resources doing so as they are not blocking a thread. Available since kernel
285
+ 5.7.
286
+ .TP
287
+ .B IORING_FEAT_POLL_32BITS
288
+ If this flag is set, the
289
+ .B IORING_OP_POLL_ADD
290
+ command accepts the full 32-bit range of epoll based flags. Most notably
291
+ .B EPOLLEXCLUSIVE
292
+ which allows exclusive (waking single waiters) behavior. Available since kernel
293
+ 5.9.
294
+ .TP
295
+ .B IORING_FEAT_SQPOLL_NONFIXED
296
+ If this flag is set, the
297
+ .B IORING_SETUP_SQPOLL
298
+ feature no longer requires the use of fixed files. Any normal file descriptor
299
+ can be used for IO commands without needing registration. Available since
300
+ kernel 5.11.
301
+ .TP
302
+ .B IORING_FEAT_ENTER_EXT_ARG
303
+ If this flag is set, then the
304
+ .BR io_uring_enter (2)
305
+ system call supports passing in an extended argument instead of just the
306
+ .IR "sigset_t"
307
+ of earlier kernels. This.
308
+ extended argument is of type
309
+ .IR "struct io_uring_getevents_arg"
310
+ and allows the caller to pass in both a
311
+ .IR "sigset_t"
312
+ and a timeout argument for waiting on events. The struct layout is as follows:
313
+ .TP
314
+ .in +8n
315
+ .EX
316
+ struct io_uring_getevents_arg {
317
+ __u64 sigmask;
318
+ __u32 sigmask_sz;
319
+ __u32 pad;
320
+ __u64 ts;
321
+ };
322
+ .EE
323
+
324
+ and a pointer to this struct must be passed in if
325
+ .B IORING_ENTER_EXT_ARG
326
+ is set in the flags for the enter system call. Available since kernel 5.11.
327
+ .TP
328
+ .B IORING_FEAT_NATIVE_WORKERS
329
+ If this flag is set, io_uring is using native workers for its async helpers.
330
+ Previous kernels used kernel threads that assumed the identity of the
331
+ original io_uring owning task, but later kernels will actively create what
332
+ looks more like regular process threads instead. Available since kernel
333
+ 5.12.
334
+ .TP
335
+ .B IORING_FEAT_RSRC_TAGS
336
+ If this flag is set, then io_uring supports a variety of features related
337
+ to fixed files and buffers. In particular, it indicates that registered
338
+ buffers can be updated in-place, whereas before the full set would have to
339
+ be unregistered first. Available since kernel 5.13.
340
+
341
+ .PP
342
+ The rest of the fields in the
343
+ .I struct io_uring_params
344
+ are filled in by the kernel, and provide the information necessary to
345
+ memory map the submission queue, completion queue, and the array of
346
+ submission queue entries.
347
+ .I sq_entries
348
+ specifies the number of submission queue entries allocated.
349
+ .I sq_off
350
+ describes the offsets of various ring buffer fields:
351
+ .PP
352
+ .in +4n
353
+ .EX
354
+ struct io_sqring_offsets {
355
+ __u32 head;
356
+ __u32 tail;
357
+ __u32 ring_mask;
358
+ __u32 ring_entries;
359
+ __u32 flags;
360
+ __u32 dropped;
361
+ __u32 array;
362
+ __u32 resv[3];
363
+ };
364
+ .EE
365
+ .in
366
+ .PP
367
+ Taken together,
368
+ .I sq_entries
369
+ and
370
+ .I sq_off
371
+ provide all of the information necessary for accessing the submission
372
+ queue ring buffer and the submission queue entry array. The
373
+ submission queue can be mapped with a call like:
374
+ .PP
375
+ .in +4n
376
+ .EX
377
+ ptr = mmap(0, sq_off.array + sq_entries * sizeof(__u32),
378
+ PROT_READ|PROT_WRITE, MAP_SHARED|MAP_POPULATE,
379
+ ring_fd, IORING_OFF_SQ_RING);
380
+ .EE
381
+ .in
382
+ .PP
383
+ where
384
+ .I sq_off
385
+ is the
386
+ .I io_sqring_offsets
387
+ structure, and
388
+ .I ring_fd
389
+ is the file descriptor returned from
390
+ .BR io_uring_setup (2).
391
+ The addition of
392
+ .I sq_off.array
393
+ to the length of the region accounts for the fact that the ring
394
+ located at the end of the data structure. As an example, the ring
395
+ buffer head pointer can be accessed by adding
396
+ .I sq_off.head
397
+ to the address returned from
398
+ .BR mmap (2):
399
+ .PP
400
+ .in +4n
401
+ .EX
402
+ head = ptr + sq_off.head;
403
+ .EE
404
+ .in
405
+
406
+ The
407
+ .I flags
408
+ field is used by the kernel to communicate state information to the
409
+ application. Currently, it is used to inform the application when a
410
+ call to
411
+ .BR io_uring_enter (2)
412
+ is necessary. See the documentation for the
413
+ .B IORING_SETUP_SQPOLL
414
+ flag above.
415
+ The
416
+ .I dropped
417
+ member is incremented for each invalid submission queue entry
418
+ encountered in the ring buffer.
419
+
420
+ The head and tail track the ring buffer state. The tail is
421
+ incremented by the application when submitting new I/O, and the head
422
+ is incremented by the kernel when the I/O has been successfully
423
+ submitted. Determining the index of the head or tail into the ring is
424
+ accomplished by applying a mask:
425
+ .PP
426
+ .in +4n
427
+ .EX
428
+ index = tail & ring_mask;
429
+ .EE
430
+ .in
431
+ .PP
432
+ The array of submission queue entries is mapped with:
433
+ .PP
434
+ .in +4n
435
+ .EX
436
+ sqentries = mmap(0, sq_entries * sizeof(struct io_uring_sqe),
437
+ PROT_READ|PROT_WRITE, MAP_SHARED|MAP_POPULATE,
438
+ ring_fd, IORING_OFF_SQES);
439
+ .EE
440
+ .in
441
+ .PP
442
+ The completion queue is described by
443
+ .I cq_entries
444
+ and
445
+ .I cq_off
446
+ shown here:
447
+ .PP
448
+ .in +4n
449
+ .EX
450
+ struct io_cqring_offsets {
451
+ __u32 head;
452
+ __u32 tail;
453
+ __u32 ring_mask;
454
+ __u32 ring_entries;
455
+ __u32 overflow;
456
+ __u32 cqes;
457
+ __u32 flags;
458
+ __u32 resv[3];
459
+ };
460
+ .EE
461
+ .in
462
+ .PP
463
+ The completion queue is simpler, since the entries are not separated
464
+ from the queue itself, and can be mapped with:
465
+ .PP
466
+ .in +4n
467
+ .EX
468
+ ptr = mmap(0, cq_off.cqes + cq_entries * sizeof(struct io_uring_cqe),
469
+ PROT_READ|PROT_WRITE, MAP_SHARED|MAP_POPULATE, ring_fd,
470
+ IORING_OFF_CQ_RING);
471
+ .EE
472
+ .in
473
+ .PP
474
+ Closing the file descriptor returned by
475
+ .BR io_uring_setup (2)
476
+ will free all resources associated with the io_uring context.
477
+ .PP
478
+ .SH RETURN VALUE
479
+ .BR io_uring_setup (2)
480
+ returns a new file descriptor on success. The application may then
481
+ provide the file descriptor in a subsequent
482
+ .BR mmap (2)
483
+ call to map the submission and completion queues, or to the
484
+ .BR io_uring_register (2)
485
+ or
486
+ .BR io_uring_enter (2)
487
+ system calls.
488
+
489
+ On error,
490
+ .B -1
491
+ is returned and
492
+ .I errno
493
+ is set appropriately.
494
+ .PP
495
+ .SH ERRORS
496
+ .TP
497
+ .B EFAULT
498
+ params is outside your accessible address space.
499
+ .TP
500
+ .B EINVAL
501
+ The resv array contains non-zero data, p.flags contains an unsupported
502
+ flag,
503
+ .I entries
504
+ is out of bounds,
505
+ .B IORING_SETUP_SQ_AFF
506
+ was specified, but
507
+ .B IORING_SETUP_SQPOLL
508
+ was not, or
509
+ .B IORING_SETUP_CQSIZE
510
+ was specified, but
511
+ .I io_uring_params.cq_entries
512
+ was invalid.
513
+ .TP
514
+ .B EMFILE
515
+ The per-process limit on the number of open file descriptors has been
516
+ reached (see the description of
517
+ .B RLIMIT_NOFILE
518
+ in
519
+ .BR getrlimit (2)).
520
+ .TP
521
+ .B ENFILE
522
+ The system-wide limit on the total number of open files has been
523
+ reached.
524
+ .TP
525
+ .B ENOMEM
526
+ Insufficient kernel resources are available.
527
+ .TP
528
+ .B EPERM
529
+ .B IORING_SETUP_SQPOLL
530
+ was specified, but the effective user ID of the caller did not have sufficient
531
+ privileges.
532
+ .SH SEE ALSO
533
+ .BR io_uring_register (2),
534
+ .BR io_uring_enter (2)
@@ -0,0 +1,25 @@
1
+ .\" Copyright (C) 2022 Stefan Roesch <shr@fb.com>
2
+ .\"
3
+ .\" SPDX-License-Identifier: LGPL-2.0-or-later
4
+ .\"
5
+ .TH io_uring_sq_ready "January 25, 2022" "liburing-2.1" "liburing Manual"
6
+ .SH NAME
7
+ io_uring_sq_ready - number of unconsumed or unsubmitted entries in the SQ ring
8
+ .SH SYNOPSIS
9
+ .nf
10
+ .BR "#include <liburing.h>"
11
+ .PP
12
+ .BI "unsigned io_uring_sq_ready(const struct io_uring *ring)"
13
+ .fi
14
+ .PP
15
+ .SH DESCRIPTION
16
+ .PP
17
+ The io_uring_sq_ready() function retuns the number of unconsumed (if SQPOLL) or
18
+ unsubmitted entries that exist in the SQ ring belonging to the
19
+ .I ring
20
+ param.
21
+
22
+ .SH RETURN VALUE
23
+ Returns the number of unconsumed or unsubmitted entries in the SQ ring.
24
+ .SH SEE ALSO
25
+ .BR io_uring_cq_ready (3)
@@ -0,0 +1,25 @@
1
+ .\" Copyright (C) 2022 Stefan Roesch <shr@fb.com>
2
+ .\"
3
+ .\" SPDX-License-Identifier: LGPL-2.0-or-later
4
+ .\"
5
+ .TH io_uring_sq_space-left "January 25, 2022" "liburing-2.1" "liburing Manual"
6
+ .SH NAME
7
+ io_uring_sq_space_left - free space in the SQ ring
8
+ .SH SYNOPSIS
9
+ .nf
10
+ .BR "#include <liburing.h>"
11
+ .PP
12
+ .BI "unsigned io_uring_sq_space_left(const struct io_uring *ring)"
13
+ .fi
14
+ .PP
15
+ .SH DESCRIPTION
16
+ .PP
17
+ The io_uring_sq_space_left() function retuns how much space is left in the
18
+ SQ ring belonging to the
19
+ .I ring
20
+ param.
21
+
22
+ .SH RETURN VALUE
23
+ Returns the free space in the SQ ring.
24
+ .SH SEE ALSO
25
+ .BR io_uring_sq_ready (3)
@@ -0,0 +1,30 @@
1
+ .\" Copyright (C) 2021 Stefan Roesch <shr@fb.com>
2
+ .\"
3
+ .\" SPDX-License-Identifier: LGPL-2.0-or-later
4
+ .\"
5
+ .TH io_uring_sqe_set_data 3 "November 15, 2021" "liburing-2.1" "liburing Manual"
6
+ .SH NAME
7
+ io_uring_sqe_set_data - set user data for submission queue event
8
+ .SH SYNOPSIS
9
+ .nf
10
+ .BR "#include <liburing.h>"
11
+ .PP
12
+ .BI "void io_uring_sqe_set_data(struct io_uring_sqe *sqe,"
13
+ .BI " void *user_data)"
14
+ .fi
15
+ .PP
16
+ .SH DESCRIPTION
17
+ .PP
18
+ The io_uring_sqe_set_data() function stores a
19
+ .I user_data
20
+ pointer with the submission queue entry
21
+ .I sqe.
22
+
23
+ After the caller has requested an submission queue entry (SQE) with io_uring_get_sqe(),
24
+ he can associate a data pointer with the SQE. Once the completion arrives, the
25
+ function io_uring_cqe_get_data() can be called to identify the user request.
26
+
27
+ .SH RETURN VALUE
28
+ None
29
+ .SH SEE ALSO
30
+ .BR io_uring_get_sqe (3), io_uring_cqe_get_data (3)