uringmachine 0.16 → 0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +3 -0
  3. data/.gitmodules +4 -0
  4. data/CHANGELOG.md +8 -0
  5. data/TODO.md +12 -3
  6. data/examples/bm_send.rb +86 -0
  7. data/ext/um/um.c +28 -1
  8. data/ext/um/um.h +3 -0
  9. data/ext/um/um_class.c +17 -0
  10. data/ext/um/um_utils.c +38 -15
  11. data/lib/uringmachine/version.rb +1 -1
  12. data/test/test_um.rb +76 -0
  13. data/vendor/libressl/.github/scripts/changelog.sh +74 -0
  14. data/vendor/libressl/.github/workflows/android.yml +35 -0
  15. data/vendor/libressl/.github/workflows/cifuzz.yml +33 -0
  16. data/vendor/libressl/.github/workflows/cmake-config.yml +98 -0
  17. data/vendor/libressl/.github/workflows/coverity.yml +69 -0
  18. data/vendor/libressl/.github/workflows/emscripten.yml +71 -0
  19. data/vendor/libressl/.github/workflows/fedora-rawhide.yml +39 -0
  20. data/vendor/libressl/.github/workflows/freebsd.yml +71 -0
  21. data/vendor/libressl/.github/workflows/linux.yml +71 -0
  22. data/vendor/libressl/.github/workflows/macos.yml +37 -0
  23. data/vendor/libressl/.github/workflows/release.yml +81 -0
  24. data/vendor/libressl/.github/workflows/rust-openssl.yml +47 -0
  25. data/vendor/libressl/.github/workflows/solaris.yml +37 -0
  26. data/vendor/libressl/.github/workflows/windows.yml +70 -0
  27. data/vendor/libressl/.gitignore +333 -0
  28. data/vendor/libressl/CMakeLists.txt +581 -0
  29. data/vendor/libressl/COPYING +133 -0
  30. data/vendor/libressl/ChangeLog +3280 -0
  31. data/vendor/libressl/FindLibreSSL.cmake +232 -0
  32. data/vendor/libressl/LibreSSLConfig.cmake.in +36 -0
  33. data/vendor/libressl/Makefile.am +60 -0
  34. data/vendor/libressl/Makefile.am.common +20 -0
  35. data/vendor/libressl/OPENBSD_BRANCH +1 -0
  36. data/vendor/libressl/README.md +238 -0
  37. data/vendor/libressl/README.mingw.md +43 -0
  38. data/vendor/libressl/apps/CMakeLists.txt +18 -0
  39. data/vendor/libressl/apps/Makefile.am +5 -0
  40. data/vendor/libressl/apps/nc/CMakeLists.txt +67 -0
  41. data/vendor/libressl/apps/nc/Makefile.am +64 -0
  42. data/vendor/libressl/apps/nc/compat/accept4.c +17 -0
  43. data/vendor/libressl/apps/nc/compat/readpassphrase.c +205 -0
  44. data/vendor/libressl/apps/nc/compat/socket.c +29 -0
  45. data/vendor/libressl/apps/nc/compat/sys/socket.h +30 -0
  46. data/vendor/libressl/apps/ocspcheck/CMakeLists.txt +44 -0
  47. data/vendor/libressl/apps/ocspcheck/Makefile.am +45 -0
  48. data/vendor/libressl/apps/ocspcheck/compat/.gitignore +0 -0
  49. data/vendor/libressl/apps/openssl/CMakeLists.txt +97 -0
  50. data/vendor/libressl/apps/openssl/Makefile.am +108 -0
  51. data/vendor/libressl/apps/openssl/apps_win.c +138 -0
  52. data/vendor/libressl/apps/openssl/certhash_win.c +13 -0
  53. data/vendor/libressl/apps/openssl/compat/clock_gettime_osx.c +26 -0
  54. data/vendor/libressl/apps/openssl/compat/poll_win.c +329 -0
  55. data/vendor/libressl/appveyor.yml +53 -0
  56. data/vendor/libressl/autogen.sh +15 -0
  57. data/vendor/libressl/check-release.sh +86 -0
  58. data/vendor/libressl/cmake_export_symbol.cmake +71 -0
  59. data/vendor/libressl/cmake_uninstall.cmake.in +36 -0
  60. data/vendor/libressl/config +17 -0
  61. data/vendor/libressl/configure.ac +165 -0
  62. data/vendor/libressl/crypto/CMakeLists.txt +863 -0
  63. data/vendor/libressl/crypto/Makefile.am +962 -0
  64. data/vendor/libressl/crypto/Makefile.am.arc4random +46 -0
  65. data/vendor/libressl/crypto/Makefile.am.elf-mips +14 -0
  66. data/vendor/libressl/crypto/Makefile.am.elf-mips64 +14 -0
  67. data/vendor/libressl/crypto/Makefile.am.elf-x86_64 +35 -0
  68. data/vendor/libressl/crypto/Makefile.am.macosx-x86_64 +35 -0
  69. data/vendor/libressl/crypto/Makefile.am.masm-x86_64 +22 -0
  70. data/vendor/libressl/crypto/Makefile.am.mingw64-x86_64 +23 -0
  71. data/vendor/libressl/crypto/arch/aarch64/crypto_cpu_caps_darwin.c +60 -0
  72. data/vendor/libressl/crypto/arch/aarch64/crypto_cpu_caps_linux.c +62 -0
  73. data/vendor/libressl/crypto/arch/aarch64/crypto_cpu_caps_none.c +26 -0
  74. data/vendor/libressl/crypto/arch/aarch64/crypto_cpu_caps_windows.c +36 -0
  75. data/vendor/libressl/crypto/arch/loongarch64/crypto_arch.h +21 -0
  76. data/vendor/libressl/crypto/arch/mips/crypto_arch.h +21 -0
  77. data/vendor/libressl/crypto/bn/arch/loongarch64/bn_arch.h +23 -0
  78. data/vendor/libressl/crypto/bn/arch/mips/bn_arch.h +24 -0
  79. data/vendor/libressl/crypto/compat/.gitignore +31 -0
  80. data/vendor/libressl/crypto/compat/arc4random.h +41 -0
  81. data/vendor/libressl/crypto/compat/b_win.c +55 -0
  82. data/vendor/libressl/crypto/compat/bsd-asprintf.c +96 -0
  83. data/vendor/libressl/crypto/compat/crypto_lock_win.c +56 -0
  84. data/vendor/libressl/crypto/compat/explicit_bzero_win.c +13 -0
  85. data/vendor/libressl/crypto/compat/freezero.c +32 -0
  86. data/vendor/libressl/crypto/compat/getdelim.c +78 -0
  87. data/vendor/libressl/crypto/compat/getline.c +40 -0
  88. data/vendor/libressl/crypto/compat/getopt_long.c +528 -0
  89. data/vendor/libressl/crypto/compat/getpagesize.c +18 -0
  90. data/vendor/libressl/crypto/compat/getprogname_linux.c +23 -0
  91. data/vendor/libressl/crypto/compat/getprogname_unimpl.c +7 -0
  92. data/vendor/libressl/crypto/compat/getprogname_windows.c +13 -0
  93. data/vendor/libressl/crypto/compat/posix_win.c +296 -0
  94. data/vendor/libressl/crypto/compat/syslog_r.c +19 -0
  95. data/vendor/libressl/crypto/compat/ui_openssl_win.c +334 -0
  96. data/vendor/libressl/dist.sh +22 -0
  97. data/vendor/libressl/gen-coverage-report.sh +58 -0
  98. data/vendor/libressl/gen-openbsd-tags.sh +20 -0
  99. data/vendor/libressl/include/CMakeLists.txt +61 -0
  100. data/vendor/libressl/include/Makefile.am +79 -0
  101. data/vendor/libressl/include/arch/loongarch64/opensslconf.h +150 -0
  102. data/vendor/libressl/include/arch/mips/opensslconf.h +150 -0
  103. data/vendor/libressl/include/compat/arpa/inet.h +15 -0
  104. data/vendor/libressl/include/compat/arpa/nameser.h +25 -0
  105. data/vendor/libressl/include/compat/cet.h +19 -0
  106. data/vendor/libressl/include/compat/dirent.h +17 -0
  107. data/vendor/libressl/include/compat/dirent_msvc.h +611 -0
  108. data/vendor/libressl/include/compat/endian.h +161 -0
  109. data/vendor/libressl/include/compat/err.h +95 -0
  110. data/vendor/libressl/include/compat/fcntl.h +32 -0
  111. data/vendor/libressl/include/compat/getopt.h +50 -0
  112. data/vendor/libressl/include/compat/limits.h +25 -0
  113. data/vendor/libressl/include/compat/netdb.h +10 -0
  114. data/vendor/libressl/include/compat/netinet/in.h +19 -0
  115. data/vendor/libressl/include/compat/netinet/ip.h +49 -0
  116. data/vendor/libressl/include/compat/netinet/tcp.h +10 -0
  117. data/vendor/libressl/include/compat/poll.h +63 -0
  118. data/vendor/libressl/include/compat/pthread.h +122 -0
  119. data/vendor/libressl/include/compat/readpassphrase.h +44 -0
  120. data/vendor/libressl/include/compat/resolv.h +24 -0
  121. data/vendor/libressl/include/compat/stdint.h +31 -0
  122. data/vendor/libressl/include/compat/stdio.h +65 -0
  123. data/vendor/libressl/include/compat/stdlib.h +57 -0
  124. data/vendor/libressl/include/compat/string.h +98 -0
  125. data/vendor/libressl/include/compat/sys/_null.h +18 -0
  126. data/vendor/libressl/include/compat/sys/ioctl.h +11 -0
  127. data/vendor/libressl/include/compat/sys/mman.h +19 -0
  128. data/vendor/libressl/include/compat/sys/param.h +15 -0
  129. data/vendor/libressl/include/compat/sys/queue.h +536 -0
  130. data/vendor/libressl/include/compat/sys/select.h +10 -0
  131. data/vendor/libressl/include/compat/sys/socket.h +18 -0
  132. data/vendor/libressl/include/compat/sys/stat.h +129 -0
  133. data/vendor/libressl/include/compat/sys/time.h +37 -0
  134. data/vendor/libressl/include/compat/sys/tree.h +1006 -0
  135. data/vendor/libressl/include/compat/sys/types.h +69 -0
  136. data/vendor/libressl/include/compat/sys/uio.h +17 -0
  137. data/vendor/libressl/include/compat/syslog.h +38 -0
  138. data/vendor/libressl/include/compat/time.h +59 -0
  139. data/vendor/libressl/include/compat/unistd.h +83 -0
  140. data/vendor/libressl/include/compat/win32netcompat.h +57 -0
  141. data/vendor/libressl/include/openssl/Makefile.am.tpl +45 -0
  142. data/vendor/libressl/libcrypto.pc.in +28 -0
  143. data/vendor/libressl/libressl.pub +2 -0
  144. data/vendor/libressl/libssl.pc.in +28 -0
  145. data/vendor/libressl/libtls.pc.in +28 -0
  146. data/vendor/libressl/m4/ax_add_fortify_source.m4 +80 -0
  147. data/vendor/libressl/m4/ax_check_compile_flag.m4 +53 -0
  148. data/vendor/libressl/m4/check-hardening-options.m4 +110 -0
  149. data/vendor/libressl/m4/check-libc.m4 +189 -0
  150. data/vendor/libressl/m4/check-os-options.m4 +181 -0
  151. data/vendor/libressl/m4/disable-compiler-warnings.m4 +44 -0
  152. data/vendor/libressl/man/CMakeLists.txt +26 -0
  153. data/vendor/libressl/man/links +2780 -0
  154. data/vendor/libressl/man/update_links.sh +25 -0
  155. data/vendor/libressl/openssl.pc.in +11 -0
  156. data/vendor/libressl/patches/bn_shift.patch +34 -0
  157. data/vendor/libressl/patches/crypto_arch.h.patch +34 -0
  158. data/vendor/libressl/patches/crypto_namespace.h.patch +22 -0
  159. data/vendor/libressl/patches/netcat.c.patch +178 -0
  160. data/vendor/libressl/patches/openssl.c.patch +12 -0
  161. data/vendor/libressl/patches/opensslfeatures.h.patch +49 -0
  162. data/vendor/libressl/patches/patch-amd64-crypto-cpu-caps.c.patch +20 -0
  163. data/vendor/libressl/patches/patch-i386-crypto-cpu-caps.c.patch +20 -0
  164. data/vendor/libressl/patches/speed.c.patch +114 -0
  165. data/vendor/libressl/patches/ssl_namespace.h.patch +21 -0
  166. data/vendor/libressl/patches/tls.h.patch +16 -0
  167. data/vendor/libressl/patches/tls_config.c.patch +15 -0
  168. data/vendor/libressl/patches/win32_amd64_bn_arch.h.patch +28 -0
  169. data/vendor/libressl/patches/windows_headers.patch +80 -0
  170. data/vendor/libressl/scripts/config.guess +1774 -0
  171. data/vendor/libressl/scripts/config.sub +1907 -0
  172. data/vendor/libressl/scripts/i686-w64-mingw32.cmake +9 -0
  173. data/vendor/libressl/scripts/test +210 -0
  174. data/vendor/libressl/scripts/wrap-compiler-for-flag-check +31 -0
  175. data/vendor/libressl/scripts/x86_64-w64-mingw32.cmake +9 -0
  176. data/vendor/libressl/ssl/CMakeLists.txt +183 -0
  177. data/vendor/libressl/ssl/Makefile.am +187 -0
  178. data/vendor/libressl/tests/CMakeLists.txt +970 -0
  179. data/vendor/libressl/tests/Makefile.am +944 -0
  180. data/vendor/libressl/tests/aeadtest.sh +30 -0
  181. data/vendor/libressl/tests/arc4randomforktest.sh +21 -0
  182. data/vendor/libressl/tests/asn1time_small.test +10 -0
  183. data/vendor/libressl/tests/cmake/CMakeLists.txt +52 -0
  184. data/vendor/libressl/tests/cmake/crypto.c +7 -0
  185. data/vendor/libressl/tests/cmake/ssl.c +6 -0
  186. data/vendor/libressl/tests/cmake/tls.c +6 -0
  187. data/vendor/libressl/tests/compat/pipe2.c +186 -0
  188. data/vendor/libressl/tests/dtlstest.sh +28 -0
  189. data/vendor/libressl/tests/evptest.sh +22 -0
  190. data/vendor/libressl/tests/keypairtest.sh +27 -0
  191. data/vendor/libressl/tests/mlkem_tests.sh +39 -0
  192. data/vendor/libressl/tests/ocsptest.bat +25 -0
  193. data/vendor/libressl/tests/ocsptest.sh +23 -0
  194. data/vendor/libressl/tests/openssl.cnf +29 -0
  195. data/vendor/libressl/tests/optionstest.c +381 -0
  196. data/vendor/libressl/tests/pidwraptest.c +85 -0
  197. data/vendor/libressl/tests/pidwraptest.sh +26 -0
  198. data/vendor/libressl/tests/quictest.bat +27 -0
  199. data/vendor/libressl/tests/quictest.sh +30 -0
  200. data/vendor/libressl/tests/renegotiation_test.bat +27 -0
  201. data/vendor/libressl/tests/renegotiation_test.sh +30 -0
  202. data/vendor/libressl/tests/rfc5280time_small.test +10 -0
  203. data/vendor/libressl/tests/servertest.bat +27 -0
  204. data/vendor/libressl/tests/servertest.sh +30 -0
  205. data/vendor/libressl/tests/shutdowntest.bat +27 -0
  206. data/vendor/libressl/tests/shutdowntest.sh +30 -0
  207. data/vendor/libressl/tests/ssltest.bat +32 -0
  208. data/vendor/libressl/tests/ssltest.sh +48 -0
  209. data/vendor/libressl/tests/testdsa.bat +47 -0
  210. data/vendor/libressl/tests/testdsa.sh +57 -0
  211. data/vendor/libressl/tests/testenc.bat +85 -0
  212. data/vendor/libressl/tests/testenc.sh +93 -0
  213. data/vendor/libressl/tests/testrsa.bat +47 -0
  214. data/vendor/libressl/tests/testrsa.sh +57 -0
  215. data/vendor/libressl/tests/testssl.bat +171 -0
  216. data/vendor/libressl/tests/tlstest.bat +27 -0
  217. data/vendor/libressl/tests/tlstest.sh +28 -0
  218. data/vendor/libressl/tls/CMakeLists.txt +125 -0
  219. data/vendor/libressl/tls/Makefile.am +76 -0
  220. data/vendor/libressl/tls/compat/ftruncate.c +17 -0
  221. data/vendor/libressl/tls/compat/pread.c +29 -0
  222. data/vendor/libressl/tls/compat/pwrite.c +29 -0
  223. data/vendor/libressl/update.sh +460 -0
  224. data/vendor/liburing/.github/workflows/ci.yml +8 -0
  225. data/vendor/liburing/configure +23 -2
  226. data/vendor/liburing/examples/helpers.c +1 -1
  227. data/vendor/liburing/examples/helpers.h +1 -1
  228. data/vendor/liburing/examples/reg-wait.c +3 -3
  229. data/vendor/liburing/examples/zcrx.c +5 -5
  230. data/vendor/liburing/liburing.spec +1 -1
  231. data/vendor/liburing/src/include/liburing/io_uring.h +16 -0
  232. data/vendor/liburing/src/include/liburing.h +20 -4
  233. data/vendor/liburing/src/lib.h +2 -4
  234. data/vendor/liburing/src/liburing-ffi.map +7 -0
  235. data/vendor/liburing/src/liburing.map +7 -0
  236. data/vendor/liburing/src/register.c +5 -0
  237. data/vendor/liburing/src/sanitize.c +5 -4
  238. data/vendor/liburing/src/setup.c +43 -28
  239. data/vendor/liburing/test/Makefile +7 -0
  240. data/vendor/liburing/test/cmd-discard.c +2 -2
  241. data/vendor/liburing/test/evfd-short-read.c +84 -0
  242. data/vendor/liburing/test/fdinfo-sqpoll.c +117 -0
  243. data/vendor/liburing/test/fdinfo.c +1 -1
  244. data/vendor/liburing/test/fixed-buf-merge.c +2 -2
  245. data/vendor/liburing/test/futex-kill.c +135 -0
  246. data/vendor/liburing/test/helpers.c +1 -1
  247. data/vendor/liburing/test/helpers.h +1 -1
  248. data/vendor/liburing/test/init-mem.c +50 -12
  249. data/vendor/liburing/test/io_uring_passthrough.c +25 -6
  250. data/vendor/liburing/test/msg-ring.c +123 -9
  251. data/vendor/liburing/test/recv-bundle-short-ooo.c +16 -1
  252. data/vendor/liburing/test/recv-inc-ooo.c +411 -0
  253. data/vendor/liburing/test/recv-mshot-fair.c +513 -0
  254. data/vendor/liburing/test/reg-wait.c +14 -14
  255. data/vendor/liburing/test/send-zerocopy.c +4 -4
  256. data/vendor/liburing/test/timerfd-short-read.c +81 -0
  257. data/vendor/liburing/test/timestamp.c +382 -0
  258. data/vendor/liburing/test/zcrx.c +22 -22
  259. metadata +222 -2
@@ -28,6 +28,13 @@
28
28
  #define uring_likely(cond) __builtin_expect(!!(cond), 1)
29
29
  #endif
30
30
 
31
+ /*
32
+ * NOTE: Only use IOURINGINLINE macro for 'static inline' functions
33
+ * that are expected to be available in the FFI bindings.
34
+ *
35
+ * Functions that are marked as IOURINGINLINE should be
36
+ * included in the liburing-ffi.map file.
37
+ */
31
38
  #ifndef IOURINGINLINE
32
39
  #define IOURINGINLINE static inline
33
40
  #endif
@@ -146,6 +153,11 @@ struct io_uring_zcrx_rq {
146
153
  * Library interface
147
154
  */
148
155
 
156
+ static inline __u64 uring_ptr_to_u64(const void *ptr)
157
+ {
158
+ return (__u64) (unsigned long) ptr;
159
+ }
160
+
149
161
  /*
150
162
  * return an allocated io_uring_probe structure, or NULL if probe fails (for
151
163
  * example, if it is not available). The caller is responsible for freeing it
@@ -274,6 +286,7 @@ int io_uring_unregister_buf_ring(struct io_uring *ring, int bgid);
274
286
  int io_uring_buf_ring_head(struct io_uring *ring, int buf_group, uint16_t *head);
275
287
  int io_uring_register_sync_cancel(struct io_uring *ring,
276
288
  struct io_uring_sync_cancel_reg *reg);
289
+ int io_uring_register_sync_msg(struct io_uring_sqe *sqe);
277
290
 
278
291
  int io_uring_register_file_alloc_range(struct io_uring *ring,
279
292
  unsigned off, unsigned len);
@@ -355,7 +368,7 @@ struct io_uring_cqe_iter {
355
368
  unsigned tail;
356
369
  };
357
370
 
358
- IOURINGINLINE struct io_uring_cqe_iter
371
+ static inline struct io_uring_cqe_iter
359
372
  io_uring_cqe_iter_init(const struct io_uring *ring)
360
373
  {
361
374
  return (struct io_uring_cqe_iter) {
@@ -368,7 +381,7 @@ io_uring_cqe_iter_init(const struct io_uring *ring)
368
381
  };
369
382
  }
370
383
 
371
- IOURINGINLINE bool io_uring_cqe_iter_next(struct io_uring_cqe_iter *iter,
384
+ static inline bool io_uring_cqe_iter_next(struct io_uring_cqe_iter *iter,
372
385
  struct io_uring_cqe **cqe)
373
386
  {
374
387
  if (iter->head == iter->tail)
@@ -716,7 +729,7 @@ IOURINGINLINE void io_uring_prep_accept(struct io_uring_sqe *sqe, int fd,
716
729
  socklen_t *addrlen, int flags)
717
730
  {
718
731
  io_uring_prep_rw(IORING_OP_ACCEPT, sqe, fd, addr, 0,
719
- (__u64) (unsigned long) addrlen);
732
+ uring_ptr_to_u64(addrlen));
720
733
  sqe->accept_flags = (__u32) flags;
721
734
  }
722
735
 
@@ -902,7 +915,7 @@ IOURINGINLINE void io_uring_prep_statx(struct io_uring_sqe *sqe, int dfd,
902
915
  unsigned mask, struct statx *statxbuf)
903
916
  {
904
917
  io_uring_prep_rw(IORING_OP_STATX, sqe, dfd, path, mask,
905
- (__u64) (unsigned long) statxbuf);
918
+ uring_ptr_to_u64(statxbuf));
906
919
  sqe->statx_flags = (__u32) flags;
907
920
  }
908
921
 
@@ -1746,6 +1759,9 @@ struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring);
1746
1759
  ssize_t io_uring_mlock_size(unsigned entries, unsigned flags);
1747
1760
  ssize_t io_uring_mlock_size_params(unsigned entries, struct io_uring_params *p);
1748
1761
 
1762
+ ssize_t io_uring_memory_size(unsigned entries, unsigned flags);
1763
+ ssize_t io_uring_memory_size_params(unsigned entries, struct io_uring_params *p);
1764
+
1749
1765
  /*
1750
1766
  * Versioning information for liburing.
1751
1767
  *
@@ -29,10 +29,8 @@
29
29
  #endif
30
30
 
31
31
  #ifndef container_of
32
- #define container_of(PTR, TYPE, FIELD) ({ \
33
- __typeof__(((TYPE *)0)->FIELD) *__FIELD_PTR = (PTR); \
34
- (TYPE *)((char *) __FIELD_PTR - offsetof(TYPE, FIELD)); \
35
- })
32
+ #define container_of(PTR, TYPE, MEMBER) \
33
+ ((TYPE *)((char *)(PTR) - __builtin_offsetof(TYPE, MEMBER)))
36
34
  #endif
37
35
 
38
36
  #define __maybe_unused __attribute__((__unused__))
@@ -237,3 +237,10 @@ LIBURING_2.10 {
237
237
  __io_uring_clone_buffers;
238
238
  __io_uring_clone_buffers_offset;
239
239
  } LIBURING_2.9;
240
+
241
+ LIBURING_2.11 {
242
+ global:
243
+ io_uring_memory_size;
244
+ io_uring_memory_size_params;
245
+ io_uring_register_sync_msg;
246
+ } LIBURING_2.10;
@@ -119,3 +119,10 @@ LIBURING_2.10 {
119
119
  __io_uring_clone_buffers;
120
120
  __io_uring_clone_buffers_offset;
121
121
  } LIBURING_2.9;
122
+
123
+ LIBURING_2.11 {
124
+ global:
125
+ io_uring_memory_size;
126
+ io_uring_memory_size_params;
127
+ io_uring_register_sync_msg;
128
+ } LIBURING_2.10;
@@ -368,6 +368,11 @@ int io_uring_register_sync_cancel(struct io_uring *ring,
368
368
  return do_register(ring, IORING_REGISTER_SYNC_CANCEL, reg, 1);
369
369
  }
370
370
 
371
+ int io_uring_register_sync_msg(struct io_uring_sqe *sqe)
372
+ {
373
+ return __sys_io_uring_register(-1, IORING_REGISTER_SEND_MSG_RING, sqe, 1);
374
+ }
375
+
371
376
  int io_uring_register_file_alloc_range(struct io_uring *ring,
372
377
  unsigned off, unsigned len)
373
378
  {
@@ -115,10 +115,11 @@ static inline void initialize_sanitize_handlers()
115
115
  sanitize_handlers[IORING_OP_FTRUNCATE] = sanitize_sqe_addr;
116
116
  sanitize_handlers[IORING_OP_BIND] = sanitize_sqe_addr;
117
117
  sanitize_handlers[IORING_OP_LISTEN] = sanitize_sqe_addr;
118
- sanitize_handlers[IORING_OP_RECV_ZC] = sanitize_sqe_addr,
119
- sanitize_handlers[IORING_OP_EPOLL_WAIT] = sanitize_sqe_addr,
120
- sanitize_handlers[IORING_OP_READV_FIXED] = sanitize_sqe_addr,
121
- sanitize_handlers[IORING_OP_WRITEV_FIXED] = sanitize_sqe_addr,
118
+ sanitize_handlers[IORING_OP_RECV_ZC] = sanitize_sqe_addr;
119
+ sanitize_handlers[IORING_OP_EPOLL_WAIT] = sanitize_sqe_addr;
120
+ sanitize_handlers[IORING_OP_READV_FIXED] = sanitize_sqe_addr;
121
+ sanitize_handlers[IORING_OP_WRITEV_FIXED] = sanitize_sqe_addr;
122
+ _Static_assert(IORING_OP_WRITEV_FIXED + 1 == IORING_OP_LAST, "Need an implementation for all IORING_OP_* codes");
122
123
  sanitize_handlers_initialized = true;
123
124
  }
124
125
 
@@ -7,6 +7,7 @@
7
7
  #include "int_flags.h"
8
8
  #include "setup.h"
9
9
  #include "liburing/io_uring.h"
10
+ #include <stdio.h>
10
11
 
11
12
  #define KERN_MAX_ENTRIES 32768
12
13
  #define KERN_MAX_CQ_ENTRIES (2 * KERN_MAX_ENTRIES)
@@ -498,27 +499,57 @@ __cold void io_uring_free_probe(struct io_uring_probe *probe)
498
499
  free(probe);
499
500
  }
500
501
 
501
- static size_t npages(size_t size, long page_size)
502
- {
503
- size--;
504
- size /= page_size;
505
- return __fls((int) size);
506
- }
507
-
508
502
  static size_t rings_size(struct io_uring_params *p, unsigned entries,
509
503
  unsigned cq_entries, long page_size)
510
504
  {
511
505
  size_t pages, sq_size, cq_size;
512
506
 
513
- cq_size = KRING_SIZE + params_cq_size(p, cq_entries);
514
- cq_size = (cq_size + 63) & ~63UL;
515
- pages = (size_t) 1 << npages(cq_size, page_size);
507
+ /*
508
+ * CQ ring size is number of pages that we need for the
509
+ * struct io_uring_cqe entries, which may be 16b (default) or
510
+ * 32b if the ring is setup with IORING_SETUP_CQE32. We also need
511
+ * room for the head/tail parts.
512
+ */
513
+ cq_size = params_cq_size(p, cq_entries);
514
+ cq_size += KRING_SIZE;
515
+ cq_size = (cq_size + page_size - 1) & ~(page_size - 1);
516
+ pages = (size_t) cq_size / page_size;
516
517
 
517
518
  sq_size = params_sqes_size(p, entries);
518
- pages += (size_t) 1 << npages(sq_size, page_size);
519
+ sq_size = (sq_size + page_size - 1) & ~(page_size - 1);
520
+ pages += sq_size / page_size;
519
521
  return pages * page_size;
520
522
  }
521
523
 
524
+ ssize_t io_uring_memory_size_params(unsigned entries, struct io_uring_params *p)
525
+ {
526
+ unsigned sq, cq;
527
+ long page_size;
528
+ ssize_t ret;
529
+
530
+ if (!entries)
531
+ return -EINVAL;
532
+ if (entries > KERN_MAX_ENTRIES) {
533
+ if (!(p->flags & IORING_SETUP_CLAMP))
534
+ return -EINVAL;
535
+ entries = KERN_MAX_ENTRIES;
536
+ }
537
+
538
+ ret = get_sq_cq_entries(entries, p, &sq, &cq);
539
+ if (ret)
540
+ return ret;
541
+
542
+ page_size = get_page_size();
543
+ return rings_size(p, sq, cq, page_size);
544
+ }
545
+
546
+ ssize_t io_uring_memory_size(unsigned entries, unsigned ring_flags)
547
+ {
548
+ struct io_uring_params p = { .flags = ring_flags, };
549
+
550
+ return io_uring_memory_size_params(entries, &p);
551
+ }
552
+
522
553
  /*
523
554
  * Return the required ulimit -l memlock memory required for a given ring
524
555
  * setup, in bytes. May return -errno on error. On newer (5.12+) kernels,
@@ -532,10 +563,7 @@ __cold ssize_t io_uring_mlock_size_params(unsigned entries,
532
563
  {
533
564
  struct io_uring_params lp;
534
565
  struct io_uring ring;
535
- unsigned cq_entries, sq;
536
- long page_size;
537
566
  ssize_t ret;
538
- int cret;
539
567
 
540
568
  memset(&lp, 0, sizeof(lp));
541
569
 
@@ -557,20 +585,7 @@ __cold ssize_t io_uring_mlock_size_params(unsigned entries,
557
585
  if (lp.features & IORING_FEAT_NATIVE_WORKERS)
558
586
  return 0;
559
587
 
560
- if (!entries)
561
- return -EINVAL;
562
- if (entries > KERN_MAX_ENTRIES) {
563
- if (!(p->flags & IORING_SETUP_CLAMP))
564
- return -EINVAL;
565
- entries = KERN_MAX_ENTRIES;
566
- }
567
-
568
- cret = get_sq_cq_entries(entries, p, &sq, &cq_entries);
569
- if (cret)
570
- return cret;
571
-
572
- page_size = get_page_size();
573
- return rings_size(p, sq, cq_entries, page_size);
588
+ return io_uring_memory_size_params(entries, p);
574
589
  }
575
590
 
576
591
  /*
@@ -86,6 +86,7 @@ test_srcs := \
86
86
  eventfd-disable.c \
87
87
  eventfd-reg.c \
88
88
  eventfd-ring.c \
89
+ evfd-short-read.c \
89
90
  evloop.c \
90
91
  exec-target.c \
91
92
  exit-no-cleanup.c \
@@ -95,6 +96,7 @@ test_srcs := \
95
96
  fd-install.c \
96
97
  fd-pass.c \
97
98
  fdinfo.c \
99
+ fdinfo-sqpoll.c \
98
100
  fifo-nonblock-read.c \
99
101
  file-exit-unreg.c \
100
102
  file-register.c \
@@ -112,6 +114,7 @@ test_srcs := \
112
114
  fsnotify.c \
113
115
  fsync.c \
114
116
  futex.c \
117
+ futex-kill.c \
115
118
  hardlink.c \
116
119
  ignore-single-mmap.c \
117
120
  init-mem.c \
@@ -174,8 +177,10 @@ test_srcs := \
174
177
  read-mshot-stdin.c \
175
178
  read-write.c \
176
179
  recv-bundle-short-ooo.c \
180
+ recv-inc-ooo.c \
177
181
  recv-msgall.c \
178
182
  recv-msgall-stream.c \
183
+ recv-mshot-fair.c \
179
184
  recv-multishot.c \
180
185
  reg-fd-only.c \
181
186
  reg-hint.c \
@@ -232,6 +237,7 @@ test_srcs := \
232
237
  sync-cancel.c \
233
238
  teardowns.c \
234
239
  thread-exit.c \
240
+ timerfd-short-read.c \
235
241
  timeout.c \
236
242
  timeout-new.c \
237
243
  truncate.c \
@@ -246,6 +252,7 @@ test_srcs := \
246
252
  xattr.c \
247
253
  zcrx.c \
248
254
  vec-regbuf.c \
255
+ timestamp.c \
249
256
  # EOL
250
257
 
251
258
  # Please keep this list sorted alphabetically.
@@ -380,9 +380,9 @@ int main(int argc, char *argv[])
380
380
  bdev_size_lbas = bdev_size / lba_size;
381
381
  close(fd);
382
382
 
383
- buffer = aligned_alloc(lba_size, lba_size);
383
+ buffer = t_aligned_alloc(lba_size, lba_size);
384
384
  if (!buffer) {
385
- fprintf(stderr, "aligned_alloc failed\n");
385
+ fprintf(stderr, "t_aligned_alloc failed\n");
386
386
  return T_EXIT_FAIL;
387
387
  }
388
388
  for (i = 0; i < lba_size; i++)
@@ -0,0 +1,84 @@
1
+ /* SPDX-License-Identifier: MIT */
2
+ /*
3
+ * Description: Check that trying to read two eventfd events will still
4
+ * return one when generated. There was a kernel commit that
5
+ * all of a sudden pretended that anonymous inodes were
6
+ * regular files, which broke the io_uring short read/write
7
+ * handling logic. See:
8
+ *
9
+ * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cfd86ef7e8e7
10
+ */
11
+ #include <errno.h>
12
+ #include <stdio.h>
13
+ #include <unistd.h>
14
+ #include <stdlib.h>
15
+ #include <string.h>
16
+ #include <fcntl.h>
17
+ #include <poll.h>
18
+ #include <sys/eventfd.h>
19
+
20
+ #include "liburing.h"
21
+ #include "helpers.h"
22
+
23
+ static void sig_alrm(int sig)
24
+ {
25
+ fprintf(stderr, "Test failed due to timeout\n");
26
+ exit(T_EXIT_FAIL);
27
+ }
28
+
29
+ int main(int argc, char *argv[])
30
+ {
31
+ struct io_uring_params p = {};
32
+ struct sigaction act = { };
33
+ struct io_uring_sqe *sqe;
34
+ struct io_uring_cqe *cqe;
35
+ struct io_uring ring;
36
+ uint64_t ptr[2], tmp;
37
+ int ret, evfd;
38
+
39
+ if (argc > 1)
40
+ return T_EXIT_SKIP;
41
+
42
+ ret = io_uring_queue_init_params(8, &ring, &p);
43
+ if (ret) {
44
+ fprintf(stderr, "ring setup failed: %d\n", ret);
45
+ return T_EXIT_FAIL;
46
+ }
47
+
48
+ evfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
49
+ if (evfd < 0) {
50
+ perror("eventfd");
51
+ return T_EXIT_FAIL;
52
+ }
53
+
54
+ sqe = io_uring_get_sqe(&ring);
55
+ io_uring_prep_read(sqe, evfd, ptr, sizeof(ptr), 0);
56
+ sqe->user_data = 1;
57
+
58
+ io_uring_submit(&ring);
59
+
60
+ act.sa_handler = sig_alrm;
61
+ sigaction(SIGALRM, &act, NULL);
62
+ alarm(1);
63
+
64
+ usleep(10000);
65
+ tmp = 1;
66
+ ret = write(evfd, &tmp, sizeof(tmp));
67
+ if (ret < 0) {
68
+ perror("write");
69
+ return T_EXIT_FAIL;
70
+ } else if (ret != sizeof(tmp)) {
71
+ fprintf(stderr, "Short eventfd write\n");
72
+ return T_EXIT_FAIL;
73
+ }
74
+
75
+ ret = io_uring_wait_cqe(&ring, &cqe);
76
+ if (ret) {
77
+ fprintf(stderr, "wait: %d\n", ret);
78
+ return T_EXIT_FAIL;
79
+ }
80
+
81
+ io_uring_cqe_seen(&ring, cqe);
82
+ close(evfd);
83
+ return 0;
84
+ }
@@ -0,0 +1,117 @@
1
+ /* SPDX-License-Identifier: MIT */
2
+ /*
3
+ * Description: Race fdinfo reading with SQPOLL thread exiting
4
+ */
5
+ #include <errno.h>
6
+ #include <stdio.h>
7
+ #include <unistd.h>
8
+ #include <stdlib.h>
9
+ #include <string.h>
10
+ #include <fcntl.h>
11
+ #include <sys/types.h>
12
+ #include <pthread.h>
13
+
14
+ #include "helpers.h"
15
+ #include "liburing.h"
16
+
17
+ struct data {
18
+ struct io_uring ring;
19
+ pthread_t thread;
20
+ pthread_barrier_t barrier;
21
+ volatile int done;
22
+ };
23
+
24
+ static int rand_between(int a, int b)
25
+ {
26
+ return a + rand() % (b - a + 1);
27
+ }
28
+
29
+ static void *fdinfo_read(void *__data)
30
+ {
31
+ struct data *d = __data;
32
+ char fd_name[128];
33
+ char *buf;
34
+ int fd;
35
+
36
+ buf = malloc(4096);
37
+
38
+ sprintf(fd_name, "/proc/self/fdinfo/%d", d->ring.ring_fd);
39
+ fd = open(fd_name, O_RDONLY);
40
+ if (fd < 0) {
41
+ perror("open");
42
+ return NULL;
43
+ }
44
+
45
+ pthread_barrier_wait(&d->barrier);
46
+
47
+ do {
48
+ int ret = read(fd, buf, 4096);
49
+
50
+ if (ret < 0) {
51
+ perror("fdinfo read");
52
+ break;
53
+ }
54
+ } while (!d->done);
55
+
56
+ close(fd);
57
+ free(buf);
58
+ return NULL;
59
+ }
60
+
61
+ static int __test(void)
62
+ {
63
+ struct data d = { };
64
+ void *tret;
65
+ int ret;
66
+
67
+ ret = t_create_ring(8, &d.ring, IORING_SETUP_SQPOLL);
68
+ if (ret == T_SETUP_SKIP)
69
+ exit(T_EXIT_SKIP);
70
+ else if (ret < 0)
71
+ exit(T_EXIT_FAIL);
72
+ pthread_barrier_init(&d.barrier, NULL, 2);
73
+ pthread_create(&d.thread, NULL, fdinfo_read, &d);
74
+ pthread_barrier_wait(&d.barrier);
75
+ usleep(rand_between(1000, 100000));
76
+ d.done = 1;
77
+ pthread_join(d.thread, &tret);
78
+ exit(T_EXIT_PASS);
79
+ }
80
+
81
+ static int test(void)
82
+ {
83
+ pid_t pid;
84
+
85
+ pid = fork();
86
+ if (pid) {
87
+ int wstatus;
88
+
89
+ usleep(rand_between(10, 2000));
90
+ kill(pid, SIGINT);
91
+ waitpid(pid, &wstatus, 0);
92
+ } else {
93
+ return __test();
94
+ }
95
+
96
+ return T_EXIT_PASS;
97
+ }
98
+
99
+ int main(int argc, char *argv[])
100
+ {
101
+ int i, ret;
102
+
103
+ if (argc > 1)
104
+ return T_EXIT_SKIP;
105
+
106
+ for (i = 0; i < 1000; i++) {
107
+ ret = test();
108
+ if (ret == T_EXIT_SKIP) {
109
+ return T_EXIT_SKIP;
110
+ } else if (ret) {
111
+ fprintf(stderr, "test failed\n");
112
+ return T_EXIT_FAIL;
113
+ }
114
+ }
115
+
116
+ return T_EXIT_PASS;
117
+ }
@@ -1,6 +1,6 @@
1
1
  /* SPDX-License-Identifier: MIT */
2
2
  /*
3
- * Description: basic read/write tests with buffered, O_DIRECT, and SQPOLL
3
+ * Description: do SQPOLL IO with concurrent fdinfo reading
4
4
  */
5
5
  #include <errno.h>
6
6
  #include <stdio.h>
@@ -44,9 +44,9 @@ int main(int argc, char *argv[])
44
44
  goto err_unlink;
45
45
  }
46
46
 
47
- to_free = buffer = aligned_alloc(4096, 128 * 4096);
47
+ to_free = buffer = t_aligned_alloc(4096, 128 * 4096);
48
48
  if (!buffer) {
49
- perror("aligned_alloc");
49
+ perror("t_aligned_alloc");
50
50
  goto err_unlink;
51
51
  }
52
52
 
@@ -0,0 +1,135 @@
1
+ /* SPDX-License-Identifier: MIT */
2
+ /*
3
+ * Description: Test FUTEX2_PRIVATE with an active waiter being killed
4
+ *
5
+ */
6
+ #include <errno.h>
7
+ #include <stdio.h>
8
+ #include <unistd.h>
9
+ #include <stdlib.h>
10
+ #include <string.h>
11
+ #include <linux/futex.h>
12
+
13
+ #include "liburing.h"
14
+ #include "helpers.h"
15
+
16
+ #ifndef FUTEX2_SIZE_U32
17
+ #define FUTEX2_SIZE_U32 0x02
18
+ #endif
19
+ #ifndef FUTEX2_PRIVATE
20
+ #define FUTEX2_PRIVATE 128
21
+ #endif
22
+
23
+ static int do_child(int ring_flags, int async, int vectored)
24
+ {
25
+ struct io_uring_params p = { .flags = ring_flags, };
26
+ struct io_uring_sqe *sqe;
27
+ struct io_uring ring;
28
+ struct futex_waitv fw = { };
29
+ unsigned int *futex;
30
+ int ret;
31
+
32
+ ret = t_create_ring_params(16, &ring, &p);
33
+ if (ret) {
34
+ if (ret == T_SETUP_SKIP)
35
+ return T_EXIT_SKIP;
36
+ fprintf(stderr, "ring setup failed\n");
37
+ return T_EXIT_FAIL;
38
+ }
39
+
40
+ futex = malloc(sizeof(*futex));
41
+ *futex = 0;
42
+ fw.uaddr = (unsigned long) futex;
43
+ fw.flags = FUTEX2_SIZE_U32|FUTEX2_PRIVATE;
44
+
45
+ sqe = io_uring_get_sqe(&ring);
46
+ if (!vectored)
47
+ io_uring_prep_futex_wait(sqe, futex, 0, FUTEX_BITSET_MATCH_ANY,
48
+ FUTEX2_SIZE_U32|FUTEX2_PRIVATE, 0);
49
+ else
50
+ io_uring_prep_futex_waitv(sqe, &fw, 1, 0);
51
+ if (async)
52
+ sqe->flags |= IOSQE_ASYNC;
53
+ io_uring_submit(&ring);
54
+ return T_EXIT_PASS;
55
+ }
56
+
57
+ static int test(int sqpoll, int async, int vectored)
58
+ {
59
+ int status, ring_flags = 0;
60
+ pid_t pid;
61
+
62
+ if (sqpoll)
63
+ ring_flags |= IORING_SETUP_SQPOLL;
64
+
65
+ pid = fork();
66
+ if (pid < 0) {
67
+ perror("fork");
68
+ return T_EXIT_FAIL;
69
+ } else if (!pid) {
70
+ exit(do_child(ring_flags, async, vectored));
71
+ }
72
+
73
+ usleep(10000);
74
+ kill(pid, 9);
75
+ waitpid(pid, &status, 0);
76
+ return T_EXIT_PASS;
77
+ }
78
+
79
+ int main(int argc, char *argv[])
80
+ {
81
+ int ret;
82
+
83
+ ret = test(0, 0, 0);
84
+ if (ret == T_EXIT_FAIL) {
85
+ fprintf(stderr, "test 0 0 0 failed\n");
86
+ return T_EXIT_FAIL;
87
+ } else if (ret == T_EXIT_SKIP) {
88
+ return T_EXIT_SKIP;
89
+ }
90
+
91
+ ret = test(0, 1, 0);
92
+ if (ret == T_EXIT_FAIL) {
93
+ fprintf(stderr, "test 0 1 0 failed\n");
94
+ return T_EXIT_FAIL;
95
+ }
96
+
97
+ ret = test(0, 0, 1);
98
+ if (ret == T_EXIT_FAIL) {
99
+ fprintf(stderr, "test 0 0 1 failed\n");
100
+ return T_EXIT_FAIL;
101
+ }
102
+
103
+ ret = test(0, 1, 1);
104
+ if (ret == T_EXIT_FAIL) {
105
+ fprintf(stderr, "test 0 1 1 failed\n");
106
+ return T_EXIT_FAIL;
107
+ }
108
+
109
+
110
+ ret = test(IORING_SETUP_SQPOLL, 0, 0);
111
+ if (ret == T_EXIT_FAIL) {
112
+ fprintf(stderr, "test SQPOLL 0 0 failed\n");
113
+ return T_EXIT_FAIL;
114
+ }
115
+
116
+ ret = test(IORING_SETUP_SQPOLL, 1, 0);
117
+ if (ret == T_EXIT_FAIL) {
118
+ fprintf(stderr, "test SQPOLL 1 0 failed\n");
119
+ return T_EXIT_FAIL;
120
+ }
121
+
122
+ ret = test(IORING_SETUP_SQPOLL, 0, 1);
123
+ if (ret == T_EXIT_FAIL) {
124
+ fprintf(stderr, "test SQPOLL 0 1 failed\n");
125
+ return T_EXIT_FAIL;
126
+ }
127
+
128
+ ret = test(IORING_SETUP_SQPOLL, 1, 1);
129
+ if (ret == T_EXIT_FAIL) {
130
+ fprintf(stderr, "test SQPOLL 1 1 failed\n");
131
+ return T_EXIT_FAIL;
132
+ }
133
+
134
+ return T_EXIT_PASS;
135
+ }
@@ -364,7 +364,7 @@ unsigned long long utime_since_now(struct timeval *tv)
364
364
  return utime_since(tv, &end);
365
365
  }
366
366
 
367
- void *aligned_alloc(size_t alignment, size_t size)
367
+ void *t_aligned_alloc(size_t alignment, size_t size)
368
368
  {
369
369
  void *ret;
370
370
 
@@ -31,7 +31,7 @@ enum t_test_result {
31
31
  * To avoid making large changes in tests, define a helper
32
32
  * function that wraps posix_memalign as our own aligned_alloc.
33
33
  */
34
- void *aligned_alloc(size_t alignment, size_t size);
34
+ void *t_aligned_alloc(size_t alignment, size_t size);
35
35
 
36
36
  /*
37
37
  * Helper for binding socket to an ephemeral port.