polyphony 0.93 → 0.95

Sign up to get free protection for your applications and to get access to all the features.
Files changed (312) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +2 -2
  3. data/.gitignore +3 -3
  4. data/CHANGELOG.md +14 -0
  5. data/docs/api-reference/fiber.md +2 -2
  6. data/docs/api-reference/object.md +3 -3
  7. data/docs/main-concepts/exception-handling.md +2 -2
  8. data/examples/pipes/echo_server.rb +1 -1
  9. data/examples/pipes/http_server.rb +33 -0
  10. data/ext/polyphony/backend_common.c +53 -8
  11. data/ext/polyphony/backend_common.h +21 -13
  12. data/ext/polyphony/backend_io_uring.c +85 -147
  13. data/ext/polyphony/backend_libev.c +58 -89
  14. data/ext/polyphony/event.c +1 -1
  15. data/ext/polyphony/extconf.rb +7 -5
  16. data/ext/polyphony/fiber.c +5 -13
  17. data/ext/polyphony/io_extensions.c +68 -68
  18. data/ext/polyphony/pipe.c +1 -1
  19. data/ext/polyphony/polyphony.c +23 -23
  20. data/ext/polyphony/polyphony.h +0 -9
  21. data/ext/polyphony/polyphony_ext.c +1 -1
  22. data/ext/polyphony/queue.c +1 -1
  23. data/ext/polyphony/ring_buffer.c +1 -0
  24. data/ext/polyphony/socket_extensions.c +1 -1
  25. data/ext/polyphony/thread.c +1 -1
  26. data/lib/polyphony/extensions/enumerator.rb +16 -0
  27. data/lib/polyphony/extensions/socket.rb +2 -0
  28. data/lib/polyphony/extensions.rb +1 -0
  29. data/lib/polyphony/version.rb +1 -1
  30. data/polyphony.gemspec +2 -2
  31. data/test/test_backend.rb +5 -1
  32. data/test/test_enumerator.rb +46 -0
  33. data/test/test_global_api.rb +1 -1
  34. data/test/test_io.rb +241 -216
  35. data/test/test_socket.rb +1 -1
  36. data/test/test_thread_pool.rb +3 -3
  37. data/vendor/liburing/.github/workflows/build.yml +51 -5
  38. data/vendor/liburing/.github/workflows/shellcheck.yml +1 -1
  39. data/vendor/liburing/.gitignore +6 -123
  40. data/vendor/liburing/CHANGELOG +35 -0
  41. data/vendor/liburing/CITATION.cff +11 -0
  42. data/vendor/liburing/LICENSE +16 -3
  43. data/vendor/liburing/Makefile +3 -1
  44. data/vendor/liburing/Makefile.common +1 -0
  45. data/vendor/liburing/README +14 -2
  46. data/vendor/liburing/SECURITY.md +6 -0
  47. data/vendor/liburing/configure +16 -15
  48. data/vendor/liburing/examples/Makefile +4 -1
  49. data/vendor/liburing/examples/io_uring-udp.c +395 -0
  50. data/vendor/liburing/examples/poll-bench.c +101 -0
  51. data/vendor/liburing/examples/send-zerocopy.c +339 -0
  52. data/vendor/liburing/liburing.spec +1 -1
  53. data/vendor/liburing/man/io_uring.7 +38 -11
  54. data/vendor/liburing/man/io_uring_buf_ring_add.3 +53 -0
  55. data/vendor/liburing/man/io_uring_buf_ring_advance.3 +31 -0
  56. data/vendor/liburing/man/io_uring_buf_ring_cq_advance.3 +41 -0
  57. data/vendor/liburing/man/io_uring_buf_ring_init.3 +30 -0
  58. data/vendor/liburing/man/io_uring_buf_ring_mask.3 +27 -0
  59. data/vendor/liburing/man/io_uring_cq_advance.3 +29 -15
  60. data/vendor/liburing/man/io_uring_cq_has_overflow.3 +25 -0
  61. data/vendor/liburing/man/io_uring_cq_ready.3 +9 -8
  62. data/vendor/liburing/man/io_uring_cqe_get_data.3 +32 -13
  63. data/vendor/liburing/man/io_uring_cqe_get_data64.3 +1 -0
  64. data/vendor/liburing/man/io_uring_cqe_seen.3 +22 -12
  65. data/vendor/liburing/man/io_uring_enter.2 +249 -32
  66. data/vendor/liburing/man/io_uring_enter2.2 +1 -0
  67. data/vendor/liburing/man/io_uring_free_probe.3 +11 -8
  68. data/vendor/liburing/man/io_uring_get_events.3 +33 -0
  69. data/vendor/liburing/man/io_uring_get_probe.3 +9 -8
  70. data/vendor/liburing/man/io_uring_get_sqe.3 +29 -10
  71. data/vendor/liburing/man/io_uring_opcode_supported.3 +11 -10
  72. data/vendor/liburing/man/io_uring_peek_cqe.3 +38 -0
  73. data/vendor/liburing/man/io_uring_prep_accept.3 +197 -0
  74. data/vendor/liburing/man/io_uring_prep_accept_direct.3 +1 -0
  75. data/vendor/liburing/man/io_uring_prep_cancel.3 +118 -0
  76. data/vendor/liburing/man/io_uring_prep_cancel64.3 +1 -0
  77. data/vendor/liburing/man/io_uring_prep_close.3 +59 -0
  78. data/vendor/liburing/man/io_uring_prep_close_direct.3 +1 -0
  79. data/vendor/liburing/man/io_uring_prep_connect.3 +66 -0
  80. data/vendor/liburing/man/io_uring_prep_fadvise.3 +59 -0
  81. data/vendor/liburing/man/io_uring_prep_fallocate.3 +59 -0
  82. data/vendor/liburing/man/io_uring_prep_files_update.3 +92 -0
  83. data/vendor/liburing/man/io_uring_prep_fsync.3 +70 -0
  84. data/vendor/liburing/man/io_uring_prep_link.3 +1 -0
  85. data/vendor/liburing/man/io_uring_prep_linkat.3 +91 -0
  86. data/vendor/liburing/man/io_uring_prep_madvise.3 +56 -0
  87. data/vendor/liburing/man/io_uring_prep_mkdir.3 +1 -0
  88. data/vendor/liburing/man/io_uring_prep_mkdirat.3 +83 -0
  89. data/vendor/liburing/man/io_uring_prep_msg_ring.3 +39 -25
  90. data/vendor/liburing/man/io_uring_prep_multishot_accept.3 +1 -0
  91. data/vendor/liburing/man/io_uring_prep_multishot_accept_direct.3 +1 -0
  92. data/vendor/liburing/man/io_uring_prep_nop.3 +28 -0
  93. data/vendor/liburing/man/io_uring_prep_openat.3 +117 -0
  94. data/vendor/liburing/man/io_uring_prep_openat2.3 +117 -0
  95. data/vendor/liburing/man/io_uring_prep_openat2_direct.3 +1 -0
  96. data/vendor/liburing/man/io_uring_prep_openat_direct.3 +1 -0
  97. data/vendor/liburing/man/io_uring_prep_poll_add.3 +72 -0
  98. data/vendor/liburing/man/io_uring_prep_poll_multishot.3 +1 -0
  99. data/vendor/liburing/man/io_uring_prep_poll_remove.3 +55 -0
  100. data/vendor/liburing/man/io_uring_prep_poll_update.3 +89 -0
  101. data/vendor/liburing/man/io_uring_prep_provide_buffers.3 +131 -0
  102. data/vendor/liburing/man/io_uring_prep_read.3 +33 -14
  103. data/vendor/liburing/man/io_uring_prep_read_fixed.3 +39 -21
  104. data/vendor/liburing/man/io_uring_prep_readv.3 +49 -15
  105. data/vendor/liburing/man/io_uring_prep_readv2.3 +49 -17
  106. data/vendor/liburing/man/io_uring_prep_recv.3 +105 -0
  107. data/vendor/liburing/man/io_uring_prep_recv_multishot.3 +1 -0
  108. data/vendor/liburing/man/io_uring_prep_recvmsg.3 +124 -0
  109. data/vendor/liburing/man/io_uring_prep_recvmsg_multishot.3 +1 -0
  110. data/vendor/liburing/man/io_uring_prep_remove_buffers.3 +52 -0
  111. data/vendor/liburing/man/io_uring_prep_rename.3 +1 -0
  112. data/vendor/liburing/man/io_uring_prep_renameat.3 +96 -0
  113. data/vendor/liburing/man/io_uring_prep_send.3 +57 -0
  114. data/vendor/liburing/man/io_uring_prep_send_zc.3 +64 -0
  115. data/vendor/liburing/man/io_uring_prep_sendmsg.3 +69 -0
  116. data/vendor/liburing/man/io_uring_prep_shutdown.3 +53 -0
  117. data/vendor/liburing/man/io_uring_prep_socket.3 +118 -0
  118. data/vendor/liburing/man/io_uring_prep_socket_direct.3 +1 -0
  119. data/vendor/liburing/man/io_uring_prep_socket_direct_alloc.3 +1 -0
  120. data/vendor/liburing/man/io_uring_prep_splice.3 +80 -0
  121. data/vendor/liburing/man/io_uring_prep_statx.3 +74 -0
  122. data/vendor/liburing/man/io_uring_prep_symlink.3 +1 -0
  123. data/vendor/liburing/man/io_uring_prep_symlinkat.3 +85 -0
  124. data/vendor/liburing/man/io_uring_prep_sync_file_range.3 +59 -0
  125. data/vendor/liburing/man/io_uring_prep_tee.3 +74 -0
  126. data/vendor/liburing/man/io_uring_prep_timeout.3 +95 -0
  127. data/vendor/liburing/man/io_uring_prep_timeout_remove.3 +1 -0
  128. data/vendor/liburing/man/io_uring_prep_timeout_update.3 +98 -0
  129. data/vendor/liburing/man/io_uring_prep_unlink.3 +1 -0
  130. data/vendor/liburing/man/io_uring_prep_unlinkat.3 +82 -0
  131. data/vendor/liburing/man/io_uring_prep_write.3 +32 -15
  132. data/vendor/liburing/man/io_uring_prep_write_fixed.3 +39 -21
  133. data/vendor/liburing/man/io_uring_prep_writev.3 +50 -16
  134. data/vendor/liburing/man/io_uring_prep_writev2.3 +50 -17
  135. data/vendor/liburing/man/io_uring_queue_exit.3 +3 -4
  136. data/vendor/liburing/man/io_uring_queue_init.3 +58 -13
  137. data/vendor/liburing/man/io_uring_queue_init_params.3 +1 -0
  138. data/vendor/liburing/man/io_uring_recvmsg_cmsg_firsthdr.3 +1 -0
  139. data/vendor/liburing/man/io_uring_recvmsg_cmsg_nexthdr.3 +1 -0
  140. data/vendor/liburing/man/io_uring_recvmsg_name.3 +1 -0
  141. data/vendor/liburing/man/io_uring_recvmsg_out.3 +78 -0
  142. data/vendor/liburing/man/io_uring_recvmsg_payload.3 +1 -0
  143. data/vendor/liburing/man/io_uring_recvmsg_payload_length.3 +1 -0
  144. data/vendor/liburing/man/io_uring_recvmsg_validate.3 +1 -0
  145. data/vendor/liburing/man/io_uring_register.2 +153 -13
  146. data/vendor/liburing/man/io_uring_register_buf_ring.3 +140 -0
  147. data/vendor/liburing/man/io_uring_register_buffers.3 +32 -12
  148. data/vendor/liburing/man/io_uring_register_eventfd.3 +51 -0
  149. data/vendor/liburing/man/io_uring_register_eventfd_async.3 +1 -0
  150. data/vendor/liburing/man/io_uring_register_file_alloc_range.3 +52 -0
  151. data/vendor/liburing/man/io_uring_register_files.3 +33 -11
  152. data/vendor/liburing/man/io_uring_register_files_sparse.3 +1 -0
  153. data/vendor/liburing/man/io_uring_register_iowq_aff.3 +61 -0
  154. data/vendor/liburing/man/io_uring_register_iowq_max_workers.3 +71 -0
  155. data/vendor/liburing/man/io_uring_register_ring_fd.3 +49 -0
  156. data/vendor/liburing/man/io_uring_register_sync_cancel.3 +71 -0
  157. data/vendor/liburing/man/io_uring_setup.2 +119 -13
  158. data/vendor/liburing/man/io_uring_sq_ready.3 +14 -8
  159. data/vendor/liburing/man/io_uring_sq_space_left.3 +9 -9
  160. data/vendor/liburing/man/io_uring_sqe_set_data.3 +29 -11
  161. data/vendor/liburing/man/io_uring_sqe_set_data64.3 +1 -0
  162. data/vendor/liburing/man/io_uring_sqe_set_flags.3 +38 -11
  163. data/vendor/liburing/man/io_uring_sqring_wait.3 +13 -9
  164. data/vendor/liburing/man/io_uring_submit.3 +29 -12
  165. data/vendor/liburing/man/io_uring_submit_and_get_events.3 +31 -0
  166. data/vendor/liburing/man/io_uring_submit_and_wait.3 +16 -12
  167. data/vendor/liburing/man/io_uring_submit_and_wait_timeout.3 +30 -23
  168. data/vendor/liburing/man/io_uring_unregister_buf_ring.3 +30 -0
  169. data/vendor/liburing/man/io_uring_unregister_buffers.3 +11 -10
  170. data/vendor/liburing/man/io_uring_unregister_eventfd.3 +1 -0
  171. data/vendor/liburing/man/io_uring_unregister_files.3 +11 -10
  172. data/vendor/liburing/man/io_uring_unregister_iowq_aff.3 +1 -0
  173. data/vendor/liburing/man/io_uring_unregister_ring_fd.3 +32 -0
  174. data/vendor/liburing/man/io_uring_wait_cqe.3 +19 -12
  175. data/vendor/liburing/man/io_uring_wait_cqe_nr.3 +21 -14
  176. data/vendor/liburing/man/io_uring_wait_cqe_timeout.3 +27 -13
  177. data/vendor/liburing/man/io_uring_wait_cqes.3 +24 -14
  178. data/vendor/liburing/src/Makefile +8 -7
  179. data/vendor/liburing/src/arch/aarch64/lib.h +48 -0
  180. data/vendor/liburing/src/arch/aarch64/syscall.h +0 -4
  181. data/vendor/liburing/src/arch/generic/lib.h +0 -4
  182. data/vendor/liburing/src/arch/generic/syscall.h +29 -16
  183. data/vendor/liburing/src/arch/syscall-defs.h +41 -14
  184. data/vendor/liburing/src/arch/x86/lib.h +0 -21
  185. data/vendor/liburing/src/arch/x86/syscall.h +146 -10
  186. data/vendor/liburing/src/include/liburing/io_uring.h +245 -5
  187. data/vendor/liburing/src/include/liburing.h +468 -35
  188. data/vendor/liburing/src/int_flags.h +1 -0
  189. data/vendor/liburing/src/lib.h +20 -16
  190. data/vendor/liburing/src/liburing.map +16 -0
  191. data/vendor/liburing/src/nolibc.c +1 -1
  192. data/vendor/liburing/src/queue.c +87 -55
  193. data/vendor/liburing/src/register.c +129 -53
  194. data/vendor/liburing/src/setup.c +65 -28
  195. data/vendor/liburing/src/syscall.c +14 -32
  196. data/vendor/liburing/src/syscall.h +12 -64
  197. data/vendor/liburing/test/{232c93d07b74-test.c → 232c93d07b74.c} +8 -9
  198. data/vendor/liburing/test/{35fa71a030ca-test.c → 35fa71a030ca.c} +4 -4
  199. data/vendor/liburing/test/{500f9fbadef8-test.c → 500f9fbadef8.c} +7 -7
  200. data/vendor/liburing/test/{7ad0e4b2f83c-test.c → 7ad0e4b2f83c.c} +8 -7
  201. data/vendor/liburing/test/{8a9973408177-test.c → 8a9973408177.c} +4 -3
  202. data/vendor/liburing/test/{917257daa0fe-test.c → 917257daa0fe.c} +3 -2
  203. data/vendor/liburing/test/Makefile +60 -62
  204. data/vendor/liburing/test/{a0908ae19763-test.c → a0908ae19763.c} +3 -2
  205. data/vendor/liburing/test/{a4c0b3decb33-test.c → a4c0b3decb33.c} +3 -2
  206. data/vendor/liburing/test/accept-link.c +5 -4
  207. data/vendor/liburing/test/accept-reuse.c +17 -16
  208. data/vendor/liburing/test/accept-test.c +14 -10
  209. data/vendor/liburing/test/accept.c +529 -107
  210. data/vendor/liburing/test/across-fork.c +7 -6
  211. data/vendor/liburing/test/{b19062a56726-test.c → b19062a56726.c} +3 -2
  212. data/vendor/liburing/test/{b5837bd5311d-test.c → b5837bd5311d.c} +10 -9
  213. data/vendor/liburing/test/buf-ring.c +420 -0
  214. data/vendor/liburing/test/{ce593a6c480a-test.c → ce593a6c480a.c} +15 -12
  215. data/vendor/liburing/test/connect.c +8 -7
  216. data/vendor/liburing/test/cq-full.c +5 -4
  217. data/vendor/liburing/test/cq-overflow.c +242 -12
  218. data/vendor/liburing/test/cq-peek-batch.c +5 -4
  219. data/vendor/liburing/test/cq-ready.c +5 -4
  220. data/vendor/liburing/test/cq-size.c +5 -4
  221. data/vendor/liburing/test/{d4ae271dfaae-test.c → d4ae271dfaae.c} +2 -2
  222. data/vendor/liburing/test/{d77a67ed5f27-test.c → d77a67ed5f27.c} +6 -6
  223. data/vendor/liburing/test/defer-taskrun.c +336 -0
  224. data/vendor/liburing/test/defer.c +26 -14
  225. data/vendor/liburing/test/double-poll-crash.c +15 -5
  226. data/vendor/liburing/test/drop-submit.c +5 -3
  227. data/vendor/liburing/test/{eeed8b54e0df-test.c → eeed8b54e0df.c} +7 -6
  228. data/vendor/liburing/test/empty-eownerdead.c +4 -4
  229. data/vendor/liburing/test/eventfd-disable.c +48 -20
  230. data/vendor/liburing/test/eventfd-reg.c +10 -9
  231. data/vendor/liburing/test/eventfd-ring.c +13 -12
  232. data/vendor/liburing/test/eventfd.c +13 -12
  233. data/vendor/liburing/test/exit-no-cleanup.c +1 -1
  234. data/vendor/liburing/test/fadvise.c +3 -3
  235. data/vendor/liburing/test/fallocate.c +16 -9
  236. data/vendor/liburing/test/{fc2a85cb02ef-test.c → fc2a85cb02ef.c} +4 -3
  237. data/vendor/liburing/test/fd-pass.c +187 -0
  238. data/vendor/liburing/test/file-register.c +302 -36
  239. data/vendor/liburing/test/file-update.c +62 -4
  240. data/vendor/liburing/test/file-verify.c +6 -2
  241. data/vendor/liburing/test/files-exit-hang-poll.c +11 -25
  242. data/vendor/liburing/test/files-exit-hang-timeout.c +13 -10
  243. data/vendor/liburing/test/fixed-buf-iter.c +115 -0
  244. data/vendor/liburing/test/fixed-link.c +10 -10
  245. data/vendor/liburing/test/fixed-reuse.c +160 -0
  246. data/vendor/liburing/test/fpos.c +6 -3
  247. data/vendor/liburing/test/fsync.c +3 -3
  248. data/vendor/liburing/test/hardlink.c +10 -6
  249. data/vendor/liburing/test/helpers.c +137 -4
  250. data/vendor/liburing/test/helpers.h +27 -0
  251. data/vendor/liburing/test/io-cancel.c +16 -11
  252. data/vendor/liburing/test/io_uring_enter.c +46 -81
  253. data/vendor/liburing/test/io_uring_passthrough.c +451 -0
  254. data/vendor/liburing/test/io_uring_register.c +59 -229
  255. data/vendor/liburing/test/io_uring_setup.c +24 -29
  256. data/vendor/liburing/test/iopoll-leak.c +85 -0
  257. data/vendor/liburing/test/iopoll.c +16 -9
  258. data/vendor/liburing/test/lfs-openat-write.c +3 -1
  259. data/vendor/liburing/test/link-timeout.c +4 -3
  260. data/vendor/liburing/test/link.c +8 -7
  261. data/vendor/liburing/test/madvise.c +2 -2
  262. data/vendor/liburing/test/mkdir.c +9 -5
  263. data/vendor/liburing/test/msg-ring.c +46 -20
  264. data/vendor/liburing/test/multicqes_drain.c +51 -12
  265. data/vendor/liburing/test/nolibc.c +60 -0
  266. data/vendor/liburing/test/nop.c +78 -16
  267. data/vendor/liburing/test/nvme.h +168 -0
  268. data/vendor/liburing/test/open-direct-link.c +188 -0
  269. data/vendor/liburing/test/open-direct-pick.c +180 -0
  270. data/vendor/liburing/test/openat2.c +3 -3
  271. data/vendor/liburing/test/poll-cancel-all.c +472 -0
  272. data/vendor/liburing/test/poll-link.c +9 -18
  273. data/vendor/liburing/test/poll-mshot-overflow.c +162 -0
  274. data/vendor/liburing/test/poll-mshot-update.c +83 -33
  275. data/vendor/liburing/test/pollfree.c +2 -2
  276. data/vendor/liburing/test/read-before-exit.c +112 -0
  277. data/vendor/liburing/test/read-write.c +83 -1
  278. data/vendor/liburing/test/recv-msgall-stream.c +398 -0
  279. data/vendor/liburing/test/recv-msgall.c +265 -0
  280. data/vendor/liburing/test/recv-multishot.c +505 -0
  281. data/vendor/liburing/test/rename.c +2 -5
  282. data/vendor/liburing/test/ring-leak.c +97 -0
  283. data/vendor/liburing/test/ringbuf-read.c +200 -0
  284. data/vendor/liburing/test/rsrc_tags.c +25 -13
  285. data/vendor/liburing/test/runtests-quiet.sh +11 -0
  286. data/vendor/liburing/test/runtests.sh +18 -20
  287. data/vendor/liburing/test/rw_merge_test.c +3 -2
  288. data/vendor/liburing/test/send-zerocopy.c +684 -0
  289. data/vendor/liburing/test/send_recv.c +49 -2
  290. data/vendor/liburing/test/send_recvmsg.c +165 -55
  291. data/vendor/liburing/test/shutdown.c +3 -4
  292. data/vendor/liburing/test/sigfd-deadlock.c +22 -8
  293. data/vendor/liburing/test/single-issuer.c +171 -0
  294. data/vendor/liburing/test/socket-rw-eagain.c +2 -12
  295. data/vendor/liburing/test/socket-rw-offset.c +2 -11
  296. data/vendor/liburing/test/socket-rw.c +2 -11
  297. data/vendor/liburing/test/socket.c +409 -0
  298. data/vendor/liburing/test/sq-poll-dup.c +1 -1
  299. data/vendor/liburing/test/sq-poll-share.c +1 -1
  300. data/vendor/liburing/test/statx.c +2 -2
  301. data/vendor/liburing/test/submit-and-wait.c +108 -0
  302. data/vendor/liburing/test/submit-link-fail.c +5 -3
  303. data/vendor/liburing/test/submit-reuse.c +0 -2
  304. data/vendor/liburing/test/sync-cancel.c +235 -0
  305. data/vendor/liburing/test/test.h +35 -0
  306. data/vendor/liburing/test/timeout-overflow.c +11 -11
  307. data/vendor/liburing/test/timeout.c +7 -7
  308. data/vendor/liburing/test/tty-write-dpoll.c +60 -0
  309. data/vendor/liburing/test/unlink.c +1 -1
  310. data/vendor/liburing/test/xattr.c +425 -0
  311. metadata +148 -26
  312. data/Gemfile.lock +0 -82
@@ -0,0 +1,339 @@
1
+ /* SPDX-License-Identifier: MIT */
2
+ /* based on linux-kernel/tools/testing/selftests/net/msg_zerocopy.c */
3
+ #include <stdio.h>
4
+ #include <stdlib.h>
5
+ #include <stdint.h>
6
+ #include <assert.h>
7
+ #include <errno.h>
8
+ #include <error.h>
9
+ #include <limits.h>
10
+ #include <fcntl.h>
11
+ #include <unistd.h>
12
+ #include <stdbool.h>
13
+ #include <string.h>
14
+
15
+ #include <arpa/inet.h>
16
+ #include <linux/errqueue.h>
17
+ #include <linux/if_packet.h>
18
+ #include <linux/ipv6.h>
19
+ #include <linux/socket.h>
20
+ #include <linux/sockios.h>
21
+ #include <net/ethernet.h>
22
+ #include <net/if.h>
23
+ #include <netinet/ip.h>
24
+ #include <netinet/in.h>
25
+ #include <netinet/ip6.h>
26
+ #include <netinet/tcp.h>
27
+ #include <netinet/udp.h>
28
+ #include <sys/socket.h>
29
+ #include <sys/time.h>
30
+ #include <sys/resource.h>
31
+ #include <sys/un.h>
32
+ #include <sys/ioctl.h>
33
+ #include <sys/socket.h>
34
+ #include <sys/stat.h>
35
+ #include <sys/time.h>
36
+ #include <sys/types.h>
37
+ #include <sys/wait.h>
38
+
39
+ #include "liburing.h"
40
+
41
+ #define ZC_TAG 0xfffffffULL
42
+ #define MAX_SUBMIT_NR 512
43
+
44
+ static bool cfg_reg_ringfd = true;
45
+ static bool cfg_fixed_files = 1;
46
+ static bool cfg_zc = 1;
47
+ static int cfg_nr_reqs = 8;
48
+ static bool cfg_fixed_buf = 1;
49
+
50
+ static int cfg_family = PF_UNSPEC;
51
+ static int cfg_payload_len;
52
+ static int cfg_port = 8000;
53
+ static int cfg_runtime_ms = 4200;
54
+
55
+ static socklen_t cfg_alen;
56
+ static struct sockaddr_storage cfg_dst_addr;
57
+
58
+ static char payload[IP_MAXPACKET] __attribute__((aligned(4096)));
59
+
60
+ static unsigned long gettimeofday_ms(void)
61
+ {
62
+ struct timeval tv;
63
+
64
+ gettimeofday(&tv, NULL);
65
+ return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
66
+ }
67
+
68
+ static void do_setsockopt(int fd, int level, int optname, int val)
69
+ {
70
+ if (setsockopt(fd, level, optname, &val, sizeof(val)))
71
+ error(1, errno, "setsockopt %d.%d: %d", level, optname, val);
72
+ }
73
+
74
+ static void setup_sockaddr(int domain, const char *str_addr,
75
+ struct sockaddr_storage *sockaddr)
76
+ {
77
+ struct sockaddr_in6 *addr6 = (void *) sockaddr;
78
+ struct sockaddr_in *addr4 = (void *) sockaddr;
79
+
80
+ switch (domain) {
81
+ case PF_INET:
82
+ memset(addr4, 0, sizeof(*addr4));
83
+ addr4->sin_family = AF_INET;
84
+ addr4->sin_port = htons(cfg_port);
85
+ if (str_addr &&
86
+ inet_pton(AF_INET, str_addr, &(addr4->sin_addr)) != 1)
87
+ error(1, 0, "ipv4 parse error: %s", str_addr);
88
+ break;
89
+ case PF_INET6:
90
+ memset(addr6, 0, sizeof(*addr6));
91
+ addr6->sin6_family = AF_INET6;
92
+ addr6->sin6_port = htons(cfg_port);
93
+ if (str_addr &&
94
+ inet_pton(AF_INET6, str_addr, &(addr6->sin6_addr)) != 1)
95
+ error(1, 0, "ipv6 parse error: %s", str_addr);
96
+ break;
97
+ default:
98
+ error(1, 0, "illegal domain");
99
+ }
100
+ }
101
+
102
+ static int do_setup_tx(int domain, int type, int protocol)
103
+ {
104
+ int fd;
105
+
106
+ fd = socket(domain, type, protocol);
107
+ if (fd == -1)
108
+ error(1, errno, "socket t");
109
+
110
+ do_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, 1 << 21);
111
+
112
+ if (connect(fd, (void *) &cfg_dst_addr, cfg_alen))
113
+ error(1, errno, "connect");
114
+ return fd;
115
+ }
116
+
117
+ static inline struct io_uring_cqe *wait_cqe_fast(struct io_uring *ring)
118
+ {
119
+ struct io_uring_cqe *cqe;
120
+ unsigned head;
121
+ int ret;
122
+
123
+ io_uring_for_each_cqe(ring, head, cqe)
124
+ return cqe;
125
+
126
+ ret = io_uring_wait_cqe(ring, &cqe);
127
+ if (ret)
128
+ error(1, ret, "wait cqe");
129
+ return cqe;
130
+ }
131
+
132
+ static void do_tx(int domain, int type, int protocol)
133
+ {
134
+ unsigned long packets = 0;
135
+ unsigned long bytes = 0;
136
+ struct io_uring ring;
137
+ struct iovec iov;
138
+ uint64_t tstop;
139
+ int i, fd, ret;
140
+ int compl_cqes = 0;
141
+
142
+ fd = do_setup_tx(domain, type, protocol);
143
+
144
+ ret = io_uring_queue_init(512, &ring, IORING_SETUP_COOP_TASKRUN);
145
+ if (ret)
146
+ error(1, ret, "io_uring: queue init");
147
+
148
+ if (cfg_fixed_files) {
149
+ ret = io_uring_register_files(&ring, &fd, 1);
150
+ if (ret < 0)
151
+ error(1, ret, "io_uring: files registration");
152
+ }
153
+ if (cfg_reg_ringfd) {
154
+ ret = io_uring_register_ring_fd(&ring);
155
+ if (ret < 0)
156
+ error(1, ret, "io_uring: io_uring_register_ring_fd");
157
+ }
158
+
159
+ iov.iov_base = payload;
160
+ iov.iov_len = cfg_payload_len;
161
+
162
+ ret = io_uring_register_buffers(&ring, &iov, 1);
163
+ if (ret)
164
+ error(1, ret, "io_uring: buffer registration");
165
+
166
+ tstop = gettimeofday_ms() + cfg_runtime_ms;
167
+ do {
168
+ struct io_uring_sqe *sqe;
169
+ struct io_uring_cqe *cqe;
170
+ unsigned buf_idx = 0;
171
+ unsigned msg_flags = MSG_WAITALL;
172
+
173
+ for (i = 0; i < cfg_nr_reqs; i++) {
174
+ sqe = io_uring_get_sqe(&ring);
175
+
176
+ if (!cfg_zc)
177
+ io_uring_prep_send(sqe, fd, payload,
178
+ cfg_payload_len, 0);
179
+ else {
180
+ io_uring_prep_send_zc(sqe, fd, payload,
181
+ cfg_payload_len, msg_flags, 0);
182
+ if (cfg_fixed_buf) {
183
+ sqe->ioprio |= IORING_RECVSEND_FIXED_BUF;
184
+ sqe->buf_index = buf_idx;
185
+ }
186
+ }
187
+ sqe->user_data = 1;
188
+ if (cfg_fixed_files) {
189
+ sqe->fd = 0;
190
+ sqe->flags |= IOSQE_FIXED_FILE;
191
+ }
192
+ }
193
+
194
+ ret = io_uring_submit(&ring);
195
+ if (ret != cfg_nr_reqs)
196
+ error(1, ret, "submit");
197
+
198
+ for (i = 0; i < cfg_nr_reqs; i++) {
199
+ cqe = wait_cqe_fast(&ring);
200
+
201
+ if (cqe->flags & IORING_CQE_F_NOTIF) {
202
+ if (cqe->flags & IORING_CQE_F_MORE)
203
+ error(1, -EINVAL, "F_MORE notif");
204
+ compl_cqes--;
205
+ i--;
206
+ io_uring_cqe_seen(&ring, cqe);
207
+ continue;
208
+ }
209
+ if (cqe->flags & IORING_CQE_F_MORE)
210
+ compl_cqes++;
211
+
212
+ if (cqe->res >= 0) {
213
+ packets++;
214
+ bytes += cqe->res;
215
+ } else if (cqe->res == -ECONNREFUSED || cqe->res == -EPIPE ||
216
+ cqe->res == -ECONNRESET) {
217
+ fprintf(stderr, "Connection failure");
218
+ goto out_fail;
219
+ } else if (cqe->res != -EAGAIN) {
220
+ error(1, cqe->res, "send failed");
221
+ }
222
+ io_uring_cqe_seen(&ring, cqe);
223
+ }
224
+ } while (gettimeofday_ms() < tstop);
225
+
226
+ out_fail:
227
+ shutdown(fd, SHUT_RDWR);
228
+ if (close(fd))
229
+ error(1, errno, "close");
230
+
231
+ fprintf(stderr, "tx=%lu (MB=%lu), tx/s=%lu (MB/s=%lu)\n",
232
+ packets, bytes >> 20,
233
+ packets / (cfg_runtime_ms / 1000),
234
+ (bytes >> 20) / (cfg_runtime_ms / 1000));
235
+
236
+ while (compl_cqes) {
237
+ struct io_uring_cqe *cqe = wait_cqe_fast(&ring);
238
+
239
+ io_uring_cqe_seen(&ring, cqe);
240
+ compl_cqes--;
241
+ }
242
+ io_uring_queue_exit(&ring);
243
+ }
244
+
245
+ static void do_test(int domain, int type, int protocol)
246
+ {
247
+ int i;
248
+
249
+ for (i = 0; i < IP_MAXPACKET; i++)
250
+ payload[i] = 'a' + (i % 26);
251
+
252
+ do_tx(domain, type, protocol);
253
+ }
254
+
255
+ static void usage(const char *filepath)
256
+ {
257
+ error(1, 0, "Usage: %s [-n<N>] [-z<val>] [-s<payload size>] "
258
+ "(-4|-6) [-t<time s>] -D<dst_ip> udp", filepath);
259
+ }
260
+
261
+ static void parse_opts(int argc, char **argv)
262
+ {
263
+ const int max_payload_len = sizeof(payload) -
264
+ sizeof(struct ipv6hdr) -
265
+ sizeof(struct tcphdr) -
266
+ 40 /* max tcp options */;
267
+ int c;
268
+ char *daddr = NULL;
269
+
270
+ if (argc <= 1)
271
+ usage(argv[0]);
272
+
273
+ cfg_payload_len = max_payload_len;
274
+
275
+ while ((c = getopt(argc, argv, "46D:p:s:t:n:z:b:k")) != -1) {
276
+ switch (c) {
277
+ case '4':
278
+ if (cfg_family != PF_UNSPEC)
279
+ error(1, 0, "Pass one of -4 or -6");
280
+ cfg_family = PF_INET;
281
+ cfg_alen = sizeof(struct sockaddr_in);
282
+ break;
283
+ case '6':
284
+ if (cfg_family != PF_UNSPEC)
285
+ error(1, 0, "Pass one of -4 or -6");
286
+ cfg_family = PF_INET6;
287
+ cfg_alen = sizeof(struct sockaddr_in6);
288
+ break;
289
+ case 'D':
290
+ daddr = optarg;
291
+ break;
292
+ case 'p':
293
+ cfg_port = strtoul(optarg, NULL, 0);
294
+ break;
295
+ case 's':
296
+ cfg_payload_len = strtoul(optarg, NULL, 0);
297
+ break;
298
+ case 't':
299
+ cfg_runtime_ms = 200 + strtoul(optarg, NULL, 10) * 1000;
300
+ break;
301
+ case 'n':
302
+ cfg_nr_reqs = strtoul(optarg, NULL, 0);
303
+ break;
304
+ case 'z':
305
+ cfg_zc = strtoul(optarg, NULL, 0);
306
+ break;
307
+ case 'b':
308
+ cfg_fixed_buf = strtoul(optarg, NULL, 0);
309
+ break;
310
+ }
311
+ }
312
+
313
+ if (cfg_nr_reqs > MAX_SUBMIT_NR)
314
+ error(1, 0, "-n: submit batch nr exceeds max (%d)", MAX_SUBMIT_NR);
315
+ if (cfg_payload_len > max_payload_len)
316
+ error(1, 0, "-s: payload exceeds max (%d)", max_payload_len);
317
+
318
+ setup_sockaddr(cfg_family, daddr, &cfg_dst_addr);
319
+
320
+ if (optind != argc - 1)
321
+ usage(argv[0]);
322
+ }
323
+
324
+ int main(int argc, char **argv)
325
+ {
326
+ const char *cfg_test;
327
+
328
+ parse_opts(argc, argv);
329
+
330
+ cfg_test = argv[argc - 1];
331
+ if (!strcmp(cfg_test, "tcp"))
332
+ do_test(cfg_family, SOCK_STREAM, 0);
333
+ else if (!strcmp(cfg_test, "udp"))
334
+ do_test(cfg_family, SOCK_DGRAM, 0);
335
+ else
336
+ error(1, 0, "unknown cfg_test %s", cfg_test);
337
+
338
+ return 0;
339
+ }
@@ -1,5 +1,5 @@
1
1
  Name: liburing
2
- Version: 2.2
2
+ Version: 2.3
3
3
  Release: 1%{?dist}
4
4
  Summary: Linux-native io_uring I/O access library
5
5
  License: (GPLv2 with exceptions and LGPLv2+) or MIT
@@ -2,7 +2,7 @@
2
2
  .\" SPDX-License-Identifier: LGPL-2.0-or-later
3
3
  .\"
4
4
 
5
- .TH IO_URING 7 2020-07-26 "Linux" "Linux Programmer's Manual"
5
+ .TH io_uring 7 2020-07-26 "Linux" "Linux Programmer's Manual"
6
6
  .SH NAME
7
7
  io_uring \- Asynchronous I/O facility
8
8
  .SH SYNOPSIS
@@ -277,7 +277,8 @@ you need to acquire a submission queue entry (SQE) from the submission
277
277
  queue (SQ),
278
278
  fill it up with details of the operation you want to submit and call
279
279
  .BR io_uring_enter (2).
280
- If you want to avoid calling
280
+ There are helper functions of the form io_uring_prep_X to enable proper
281
+ setup of the SQE. If you want to avoid calling
281
282
  .BR io_uring_enter (2),
282
283
  you have the option of setting up Submission Queue Polling.
283
284
  .PP
@@ -404,10 +405,36 @@ this field can be used to correlate a submission with a completion.
404
405
  is the result from the system call that was performed as part of the
405
406
  submission;
406
407
  its return value.
408
+
407
409
  The
408
410
  .I flags
409
- field could carry request-specific metadata in the future,
410
- but is currently unused.
411
+ field carries request-specific information. As of the 6.0 kernel, the following
412
+ flags are defined:
413
+
414
+ .TP
415
+ .B IORING_CQE_F_BUFFER
416
+ If set, the upper 16 bits of the flags field carries the buffer ID that was
417
+ chosen for this request. The request must have been issued with
418
+ .B IOSQE_BUFFER_SELECT
419
+ set, and used with a request type that supports buffer selection. Additionally,
420
+ buffers must have been provided upfront either via the
421
+ .B IORING_OP_PROVIDE_BUFFERS
422
+ or the
423
+ .B IORING_REGISTER_PBUF_RING
424
+ methods.
425
+ .TP
426
+ .B IORING_CQE_F_MORE
427
+ If set, the application should expect more completions from the request. This
428
+ is used for requests that can generate multiple completions, such as multi-shot
429
+ requests, receive, or accept.
430
+ .TP
431
+ .B IORING_CQE_F_SOCK_NONEMPTY
432
+ If set, upon receiving the data from the socket in the current request, the
433
+ socket still had data left on completion of this request.
434
+ .TP
435
+ .B IORING_CQE_F_NOTIF
436
+ Set for notification CQEs, as seen with the zero-copy networking send and
437
+ receive support.
411
438
  .PP
412
439
  The general sequence to read completion events off the completion queue is
413
440
  as follows:
@@ -484,7 +511,7 @@ them to the submission queue. This avoids the
484
511
  .BR io_uring_enter (2)
485
512
  call you need to make to tell the kernel to pick SQEs up.
486
513
  For high-performance applications,
487
- this means even lesser system call overheads.
514
+ this means even fewer system call overheads.
488
515
  .SH CONFORMING TO
489
516
  .B io_uring
490
517
  is Linux-specific.
@@ -551,8 +578,8 @@ int io_uring_setup(unsigned entries, struct io_uring_params *p)
551
578
  int io_uring_enter(int ring_fd, unsigned int to_submit,
552
579
  unsigned int min_complete, unsigned int flags)
553
580
  {
554
- return (int) syscall(__NR_io_uring_enter, ring_fd, to_submit, min_complete,
555
- flags, NULL, 0);
581
+ return (int) syscall(__NR_io_uring_enter, ring_fd, to_submit,
582
+ min_complete, flags, NULL, 0);
556
583
  }
557
584
 
558
585
  int app_setup_uring(void) {
@@ -696,10 +723,10 @@ int submit_to_sq(int fd, int op) {
696
723
  io_uring_smp_store_release(sring_tail, tail);
697
724
 
698
725
  /*
699
- * Tell the kernel we have submitted events with the io_uring_enter() system
700
- * call. We also pass in the IOURING_ENTER_GETEVENTS flag which causes the
701
- * io_uring_enter() call to wait until min_complete (the 3rd param) events
702
- * complete.
726
+ * Tell the kernel we have submitted events with the io_uring_enter()
727
+ * system call. We also pass in the IOURING_ENTER_GETEVENTS flag which
728
+ * causes the io_uring_enter() call to wait until min_complete
729
+ * (the 3rd param) events complete.
703
730
  * */
704
731
  int ret = io_uring_enter(ring_fd, 1,1,
705
732
  IORING_ENTER_GETEVENTS);
@@ -0,0 +1,53 @@
1
+ .\" Copyright (C) 2022 Jens Axboe <axboe@kernel.dk>
2
+ .\"
3
+ .\" SPDX-License-Identifier: LGPL-2.0-or-later
4
+ .\"
5
+ .TH io_uring_buf_ring_add 3 "May 18, 2022" "liburing-2.2" "liburing Manual"
6
+ .SH NAME
7
+ io_uring_buf_ring_add \- add buffers to a shared buffer ring
8
+ .SH SYNOPSIS
9
+ .nf
10
+ .B #include <liburing.h>
11
+ .PP
12
+ .BI "int io_uring_buf_ring_add(struct io_uring_buf_ring *" br ",
13
+ .BI " void *" addr ",
14
+ .BI " unsigned int " len ",
15
+ .BI " unsigned short " bid ",
16
+ .BI " int " mask ",
17
+ .BI " int " buf_offset ");"
18
+ .fi
19
+ .SH DESCRIPTION
20
+ .PP
21
+ The
22
+ .BR io_uring_buf_ring_add (3)
23
+ adds a new buffer to the shared buffer ring
24
+ .IR br .
25
+ The buffer address is indicated by
26
+ .I addr
27
+ and is of
28
+ .I len
29
+ bytes of length.
30
+ .I bid
31
+ is the buffer ID, which will be returned in the CQE.
32
+ .I mask
33
+ is the size mask of the ring, available from
34
+ .BR io_uring_buf_ring_mask (3) .
35
+ .I buf_offset
36
+ is the offset to insert at from the current tail. If just one buffer is provided
37
+ before the ring tail is committed with
38
+ .BR io_uring_buf_ring_advance (3)
39
+ or
40
+ .BR io_uring_buf_ring_cq_advance (3),
41
+ then
42
+ .I buf_offset
43
+ should be 0. If buffers are provided in a loop before being committed, the
44
+ .I buf_offset
45
+ must be incremented by one for each buffer added.
46
+
47
+ .SH RETURN VALUE
48
+ None
49
+ .SH SEE ALSO
50
+ .BR io_uring_register_buf_ring (3),
51
+ .BR io_uring_buf_ring_mask (3),
52
+ .BR io_uring_buf_ring_advance (3),
53
+ .BR io_uring_buf_ring_cq_advance (3)
@@ -0,0 +1,31 @@
1
+ .\" Copyright (C) 2022 Jens Axboe <axboe@kernel.dk>
2
+ .\"
3
+ .\" SPDX-License-Identifier: LGPL-2.0-or-later
4
+ .\"
5
+ .TH io_uring_buf_ring_advance 3 "May 18, 2022" "liburing-2.2" "liburing Manual"
6
+ .SH NAME
7
+ io_uring_buf_ring_advance \- advance index of provided buffer in buffer ring
8
+ .SH SYNOPSIS
9
+ .nf
10
+ .B #include <liburing.h>
11
+ .PP
12
+ .BI "void io_uring_buf_ring_advance(struct io_uring_buf_ring *" br ",
13
+ .BI " int " count ");"
14
+ .fi
15
+ .SH DESCRIPTION
16
+ .PP
17
+ The
18
+ .BR io_uring_buf_ring_advance (3)
19
+ commits
20
+ .I count
21
+ previously added buffers to the shared buffer ring
22
+ .IR br ,
23
+ making them visible to the kernel and hence consumable. This passes ownership
24
+ of the buffer to the ring.
25
+
26
+ .SH RETURN VALUE
27
+ None
28
+ .SH SEE ALSO
29
+ .BR io_uring_register_buf_ring (3),
30
+ .BR io_uring_buf_ring_add (3),
31
+ .BR io_uring_buf_ring_cq_advance (3)
@@ -0,0 +1,41 @@
1
+ .\" Copyright (C) 2022 Jens Axboe <axboe@kernel.dk>
2
+ .\"
3
+ .\" SPDX-License-Identifier: LGPL-2.0-or-later
4
+ .\"
5
+ .TH io_uring_buf_ring_cq_advance 3 "May 18, 2022" "liburing-2.2" "liburing Manual"
6
+ .SH NAME
7
+ io_uring_buf_ring_cq_advance \- advance index of provided buffer and CQ ring
8
+ .SH SYNOPSIS
9
+ .nf
10
+ .B #include <liburing.h>
11
+ .PP
12
+ .BI "void io_uring_buf_ring_cq_advance(struct io_uring *" ring ",
13
+ .BI " struct io_uring_buf_ring *" br ",
14
+ .BI " int " count ");"
15
+ .fi
16
+ .SH DESCRIPTION
17
+ .PP
18
+ The
19
+ .BR io_uring_buf_ring_cq_advance (3)
20
+ commits
21
+ .I count
22
+ previously added buffers to the shared buffer ring
23
+ .IR br ,
24
+ making them visible to the kernel and hence consumable. This passes ownership
25
+ of the buffer to the ring. At the same time, it advances the CQ ring of
26
+ .I ring
27
+ by
28
+ .I count
29
+ amount. This effectively bundles both a
30
+ .BR io_uring_buf_ring_advance (3)
31
+ call and a
32
+ .BR io_uring_cq_avance (3)
33
+ into one operation. Since updating either ring index entails a store memory
34
+ barrier, doing both at once is more efficient.
35
+
36
+ .SH RETURN VALUE
37
+ None
38
+ .SH SEE ALSO
39
+ .BR io_uring_register_buf_ring (3),
40
+ .BR io_uring_buf_ring_add (3),
41
+ .BR io_uring_buf_ring_advance (3)
@@ -0,0 +1,30 @@
1
+ .\" Copyright (C) 2022 Dylan Yudaken <dylany@fb.com>
2
+ .\"
3
+ .\" SPDX-License-Identifier: LGPL-2.0-or-later
4
+ .\"
5
+ .TH io_uring_buf_ring_init 3 "June 13, 2022" "liburing-2.2" "liburing Manual"
6
+ .SH NAME
7
+ io_uring_buf_ring_init \- Initialise a buffer ring
8
+ .SH SYNOPSIS
9
+ .nf
10
+ .B #include <liburing.h>
11
+ .PP
12
+ .BI "void io_uring_buf_ring_init(struct io_uring_buf_ring *" br ");"
13
+ .fi
14
+ .SH DESCRIPTION
15
+ .PP
16
+ .BR io_uring_buf_ring_init (3)
17
+ initialises
18
+ .IR br
19
+ so that it is ready to be used. It may be called after
20
+ .BR io_uring_register_buf_ring (3)
21
+ but must be called before the buffer ring is used in any other way.
22
+
23
+ .SH RETURN VALUE
24
+ None
25
+
26
+ .SH SEE ALSO
27
+ .BR io_uring_register_buf_ring (3),
28
+ .BR io_uring_buf_ring_add (3)
29
+ .BR io_uring_buf_ring_advance (3),
30
+ .BR io_uring_buf_ring_cq_advance (3)
@@ -0,0 +1,27 @@
1
+ .\" Copyright (C) 2022 Dylan Yudaken <dylany@fb.com>
2
+ .\"
3
+ .\" SPDX-License-Identifier: LGPL-2.0-or-later
4
+ .\"
5
+ .TH io_uring_buf_ring_mask 3 "June 13, 2022" "liburing-2.2" "liburing Manual"
6
+ .SH NAME
7
+ io_uring_buf_ring_mask \- Calculate buffer ring mask size
8
+ .SH SYNOPSIS
9
+ .nf
10
+ .B #include <liburing.h>
11
+ .PP
12
+ .BI "int io_uring_buf_ring_mask(__u32 " ring_entries ");"
13
+ .fi
14
+ .SH DESCRIPTION
15
+ .PP
16
+ .BR io_uring_buf_ring_mask (3)
17
+ calculates the appropriate size mask for a buffer ring.
18
+ .IR ring_entries
19
+ is the ring entries as specified in
20
+ .BR io_uring_register_buf_ring (3) .
21
+
22
+ .SH RETURN VALUE
23
+ Size mask for the buffer ring.
24
+
25
+ .SH SEE ALSO
26
+ .BR io_uring_register_buf_ring (3),
27
+ .BR io_uring_buf_ring_add (3)
@@ -4,32 +4,46 @@
4
4
  .\"
5
5
  .TH io_uring_cq_advance 3 "January 25, 2022" "liburing-2.1" "liburing Manual"
6
6
  .SH NAME
7
- io_uring_cq_advance - Mark one or more io_uring completion events as processed
7
+ io_uring_cq_advance \- mark one or more io_uring completion events as consumed
8
8
  .SH SYNOPSIS
9
9
  .nf
10
- .BR "#include <liburing.h>"
10
+ .B #include <liburing.h>
11
11
  .PP
12
- .BI "void io_uring_cqe_advance(struct io_uring *ring,"
13
- .BI " unsigned nr)"
12
+ .BI "void io_uring_cq_advance(struct io_uring *" ring ","
13
+ .BI " unsigned " nr ");"
14
14
  .fi
15
- .PP
16
15
  .SH DESCRIPTION
17
16
  .PP
18
- The io_uring_cq_advance() function marks
17
+ The
18
+ .BR io_uring_cq_advance (3)
19
+ function marks
19
20
  .I nr
20
- IO completions
21
- belonging to the
21
+ IO completions belonging to the
22
22
  .I ring
23
- param as processed.
23
+ param as consumed.
24
+
25
+ After the caller has submitted a request with
26
+ .BR io_uring_submit (3),
27
+ the application can retrieve the completion with
28
+ .BR io_uring_wait_cqe (3),
29
+ .BR io_uring_peek_cqe (3),
30
+ or any of the other CQE retrieval helpers, and mark it as consumed with
31
+ .BR io_uring_cqe_seen (3).
24
32
 
25
- After the caller has submitted a request with io_uring_submit(), he can retrieve
26
- the completion with io_uring_wait_cqe() and mark it then as processed with
27
- io_uring_cqe_seen().
33
+ The function
34
+ .BR io_uring_cqe_seen (3)
35
+ calls the function
36
+ .BR io_uring_cq_advance (3).
28
37
 
29
- The function io_uring_cqe_seen() calls the function io_uring_cq_advance().
38
+ Completions must be marked as seen, so their slot can get reused. Failure to do
39
+ so will result in the same completion being returned on the next invocation.
30
40
 
31
- Completions must be marked as completed, so their slot can get reused.
32
41
  .SH RETURN VALUE
33
42
  None
34
43
  .SH SEE ALSO
35
- .BR io_uring_submit (3), io_uring_wait_cqe (3), io_uring_cqe_seen (3)
44
+ .BR io_uring_submit (3),
45
+ .BR io_uring_wait_cqe (3),
46
+ .BR io_uring_peek_cqe (3),
47
+ .BR io_uring_wait_cqes (3),
48
+ .BR io_uring_wait_cqe_timeout (3),
49
+ .BR io_uring_cqe_seen (3)