polyphony 1.0 → 1.0.2

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 (170) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/CHANGELOG.md +16 -3
  4. data/README.md +1 -0
  5. data/TODO.md +5 -13
  6. data/docs/cheat-sheet.md +248 -0
  7. data/docs/design-principles.md +59 -3
  8. data/docs/faq.md +15 -32
  9. data/docs/fiber-scheduling.md +14 -12
  10. data/docs/overview.md +140 -35
  11. data/docs/readme.md +4 -3
  12. data/docs/tutorial.md +19 -149
  13. data/examples/core/debug.rb +12 -0
  14. data/examples/core/rpc_benchmark.rb +136 -0
  15. data/ext/polyphony/polyphony.c +2 -1
  16. data/lib/polyphony/extensions/fiber.rb +1 -0
  17. data/lib/polyphony/extensions/io.rb +171 -161
  18. data/lib/polyphony/extensions/pipe.rb +3 -5
  19. data/lib/polyphony/extensions/socket.rb +45 -54
  20. data/lib/polyphony/version.rb +1 -1
  21. data/polyphony.gemspec +3 -1
  22. data/test/test_socket.rb +1 -1
  23. metadata +33 -149
  24. data/vendor/liburing/man/IO_URING_CHECK_VERSION.3 +0 -1
  25. data/vendor/liburing/man/IO_URING_VERSION_MAJOR.3 +0 -1
  26. data/vendor/liburing/man/IO_URING_VERSION_MINOR.3 +0 -1
  27. data/vendor/liburing/man/io_uring.7 +0 -781
  28. data/vendor/liburing/man/io_uring_buf_ring_add.3 +0 -53
  29. data/vendor/liburing/man/io_uring_buf_ring_advance.3 +0 -31
  30. data/vendor/liburing/man/io_uring_buf_ring_cq_advance.3 +0 -41
  31. data/vendor/liburing/man/io_uring_buf_ring_init.3 +0 -30
  32. data/vendor/liburing/man/io_uring_buf_ring_mask.3 +0 -27
  33. data/vendor/liburing/man/io_uring_check_version.3 +0 -72
  34. data/vendor/liburing/man/io_uring_close_ring_fd.3 +0 -43
  35. data/vendor/liburing/man/io_uring_cq_advance.3 +0 -49
  36. data/vendor/liburing/man/io_uring_cq_has_overflow.3 +0 -25
  37. data/vendor/liburing/man/io_uring_cq_ready.3 +0 -26
  38. data/vendor/liburing/man/io_uring_cqe_get_data.3 +0 -53
  39. data/vendor/liburing/man/io_uring_cqe_get_data64.3 +0 -1
  40. data/vendor/liburing/man/io_uring_cqe_seen.3 +0 -42
  41. data/vendor/liburing/man/io_uring_enter.2 +0 -1700
  42. data/vendor/liburing/man/io_uring_enter2.2 +0 -1
  43. data/vendor/liburing/man/io_uring_free_probe.3 +0 -27
  44. data/vendor/liburing/man/io_uring_get_events.3 +0 -33
  45. data/vendor/liburing/man/io_uring_get_probe.3 +0 -30
  46. data/vendor/liburing/man/io_uring_get_sqe.3 +0 -57
  47. data/vendor/liburing/man/io_uring_major_version.3 +0 -1
  48. data/vendor/liburing/man/io_uring_minor_version.3 +0 -1
  49. data/vendor/liburing/man/io_uring_opcode_supported.3 +0 -30
  50. data/vendor/liburing/man/io_uring_peek_cqe.3 +0 -38
  51. data/vendor/liburing/man/io_uring_prep_accept.3 +0 -197
  52. data/vendor/liburing/man/io_uring_prep_accept_direct.3 +0 -1
  53. data/vendor/liburing/man/io_uring_prep_cancel.3 +0 -118
  54. data/vendor/liburing/man/io_uring_prep_cancel64.3 +0 -1
  55. data/vendor/liburing/man/io_uring_prep_close.3 +0 -59
  56. data/vendor/liburing/man/io_uring_prep_close_direct.3 +0 -1
  57. data/vendor/liburing/man/io_uring_prep_connect.3 +0 -66
  58. data/vendor/liburing/man/io_uring_prep_fadvise.3 +0 -59
  59. data/vendor/liburing/man/io_uring_prep_fallocate.3 +0 -59
  60. data/vendor/liburing/man/io_uring_prep_fgetxattr.3 +0 -1
  61. data/vendor/liburing/man/io_uring_prep_files_update.3 +0 -92
  62. data/vendor/liburing/man/io_uring_prep_fsetxattr.3 +0 -1
  63. data/vendor/liburing/man/io_uring_prep_fsync.3 +0 -70
  64. data/vendor/liburing/man/io_uring_prep_getxattr.3 +0 -61
  65. data/vendor/liburing/man/io_uring_prep_link.3 +0 -1
  66. data/vendor/liburing/man/io_uring_prep_link_timeout.3 +0 -94
  67. data/vendor/liburing/man/io_uring_prep_linkat.3 +0 -91
  68. data/vendor/liburing/man/io_uring_prep_madvise.3 +0 -56
  69. data/vendor/liburing/man/io_uring_prep_mkdir.3 +0 -1
  70. data/vendor/liburing/man/io_uring_prep_mkdirat.3 +0 -83
  71. data/vendor/liburing/man/io_uring_prep_msg_ring.3 +0 -92
  72. data/vendor/liburing/man/io_uring_prep_msg_ring_cqe_flags.3 +0 -1
  73. data/vendor/liburing/man/io_uring_prep_multishot_accept.3 +0 -1
  74. data/vendor/liburing/man/io_uring_prep_multishot_accept_direct.3 +0 -1
  75. data/vendor/liburing/man/io_uring_prep_nop.3 +0 -28
  76. data/vendor/liburing/man/io_uring_prep_openat.3 +0 -117
  77. data/vendor/liburing/man/io_uring_prep_openat2.3 +0 -117
  78. data/vendor/liburing/man/io_uring_prep_openat2_direct.3 +0 -1
  79. data/vendor/liburing/man/io_uring_prep_openat_direct.3 +0 -1
  80. data/vendor/liburing/man/io_uring_prep_poll_add.3 +0 -72
  81. data/vendor/liburing/man/io_uring_prep_poll_multishot.3 +0 -1
  82. data/vendor/liburing/man/io_uring_prep_poll_remove.3 +0 -55
  83. data/vendor/liburing/man/io_uring_prep_poll_update.3 +0 -89
  84. data/vendor/liburing/man/io_uring_prep_provide_buffers.3 +0 -140
  85. data/vendor/liburing/man/io_uring_prep_read.3 +0 -69
  86. data/vendor/liburing/man/io_uring_prep_read_fixed.3 +0 -72
  87. data/vendor/liburing/man/io_uring_prep_readv.3 +0 -85
  88. data/vendor/liburing/man/io_uring_prep_readv2.3 +0 -111
  89. data/vendor/liburing/man/io_uring_prep_recv.3 +0 -105
  90. data/vendor/liburing/man/io_uring_prep_recv_multishot.3 +0 -1
  91. data/vendor/liburing/man/io_uring_prep_recvmsg.3 +0 -124
  92. data/vendor/liburing/man/io_uring_prep_recvmsg_multishot.3 +0 -1
  93. data/vendor/liburing/man/io_uring_prep_remove_buffers.3 +0 -52
  94. data/vendor/liburing/man/io_uring_prep_rename.3 +0 -1
  95. data/vendor/liburing/man/io_uring_prep_renameat.3 +0 -96
  96. data/vendor/liburing/man/io_uring_prep_send.3 +0 -66
  97. data/vendor/liburing/man/io_uring_prep_send_set_addr.3 +0 -38
  98. data/vendor/liburing/man/io_uring_prep_send_zc.3 +0 -96
  99. data/vendor/liburing/man/io_uring_prep_send_zc_fixed.3 +0 -1
  100. data/vendor/liburing/man/io_uring_prep_sendmsg.3 +0 -89
  101. data/vendor/liburing/man/io_uring_prep_sendmsg_zc.3 +0 -1
  102. data/vendor/liburing/man/io_uring_prep_setxattr.3 +0 -64
  103. data/vendor/liburing/man/io_uring_prep_shutdown.3 +0 -53
  104. data/vendor/liburing/man/io_uring_prep_socket.3 +0 -118
  105. data/vendor/liburing/man/io_uring_prep_socket_direct.3 +0 -1
  106. data/vendor/liburing/man/io_uring_prep_socket_direct_alloc.3 +0 -1
  107. data/vendor/liburing/man/io_uring_prep_splice.3 +0 -120
  108. data/vendor/liburing/man/io_uring_prep_statx.3 +0 -74
  109. data/vendor/liburing/man/io_uring_prep_symlink.3 +0 -1
  110. data/vendor/liburing/man/io_uring_prep_symlinkat.3 +0 -85
  111. data/vendor/liburing/man/io_uring_prep_sync_file_range.3 +0 -59
  112. data/vendor/liburing/man/io_uring_prep_tee.3 +0 -74
  113. data/vendor/liburing/man/io_uring_prep_timeout.3 +0 -95
  114. data/vendor/liburing/man/io_uring_prep_timeout_remove.3 +0 -1
  115. data/vendor/liburing/man/io_uring_prep_timeout_update.3 +0 -98
  116. data/vendor/liburing/man/io_uring_prep_unlink.3 +0 -1
  117. data/vendor/liburing/man/io_uring_prep_unlinkat.3 +0 -82
  118. data/vendor/liburing/man/io_uring_prep_write.3 +0 -67
  119. data/vendor/liburing/man/io_uring_prep_write_fixed.3 +0 -72
  120. data/vendor/liburing/man/io_uring_prep_writev.3 +0 -85
  121. data/vendor/liburing/man/io_uring_prep_writev2.3 +0 -111
  122. data/vendor/liburing/man/io_uring_queue_exit.3 +0 -26
  123. data/vendor/liburing/man/io_uring_queue_init.3 +0 -89
  124. data/vendor/liburing/man/io_uring_queue_init_params.3 +0 -1
  125. data/vendor/liburing/man/io_uring_recvmsg_cmsg_firsthdr.3 +0 -1
  126. data/vendor/liburing/man/io_uring_recvmsg_cmsg_nexthdr.3 +0 -1
  127. data/vendor/liburing/man/io_uring_recvmsg_name.3 +0 -1
  128. data/vendor/liburing/man/io_uring_recvmsg_out.3 +0 -82
  129. data/vendor/liburing/man/io_uring_recvmsg_payload.3 +0 -1
  130. data/vendor/liburing/man/io_uring_recvmsg_payload_length.3 +0 -1
  131. data/vendor/liburing/man/io_uring_recvmsg_validate.3 +0 -1
  132. data/vendor/liburing/man/io_uring_register.2 +0 -834
  133. data/vendor/liburing/man/io_uring_register_buf_ring.3 +0 -140
  134. data/vendor/liburing/man/io_uring_register_buffers.3 +0 -104
  135. data/vendor/liburing/man/io_uring_register_buffers_sparse.3 +0 -1
  136. data/vendor/liburing/man/io_uring_register_buffers_tags.3 +0 -1
  137. data/vendor/liburing/man/io_uring_register_buffers_update_tag.3 +0 -1
  138. data/vendor/liburing/man/io_uring_register_eventfd.3 +0 -51
  139. data/vendor/liburing/man/io_uring_register_eventfd_async.3 +0 -1
  140. data/vendor/liburing/man/io_uring_register_file_alloc_range.3 +0 -52
  141. data/vendor/liburing/man/io_uring_register_files.3 +0 -112
  142. data/vendor/liburing/man/io_uring_register_files_sparse.3 +0 -1
  143. data/vendor/liburing/man/io_uring_register_files_tags.3 +0 -1
  144. data/vendor/liburing/man/io_uring_register_files_update.3 +0 -1
  145. data/vendor/liburing/man/io_uring_register_files_update_tag.3 +0 -1
  146. data/vendor/liburing/man/io_uring_register_iowq_aff.3 +0 -61
  147. data/vendor/liburing/man/io_uring_register_iowq_max_workers.3 +0 -71
  148. data/vendor/liburing/man/io_uring_register_ring_fd.3 +0 -49
  149. data/vendor/liburing/man/io_uring_register_sync_cancel.3 +0 -71
  150. data/vendor/liburing/man/io_uring_setup.2 +0 -669
  151. data/vendor/liburing/man/io_uring_sq_ready.3 +0 -31
  152. data/vendor/liburing/man/io_uring_sq_space_left.3 +0 -25
  153. data/vendor/liburing/man/io_uring_sqe_set_data.3 +0 -48
  154. data/vendor/liburing/man/io_uring_sqe_set_data64.3 +0 -1
  155. data/vendor/liburing/man/io_uring_sqe_set_flags.3 +0 -87
  156. data/vendor/liburing/man/io_uring_sqring_wait.3 +0 -34
  157. data/vendor/liburing/man/io_uring_submit.3 +0 -46
  158. data/vendor/liburing/man/io_uring_submit_and_get_events.3 +0 -31
  159. data/vendor/liburing/man/io_uring_submit_and_wait.3 +0 -38
  160. data/vendor/liburing/man/io_uring_submit_and_wait_timeout.3 +0 -56
  161. data/vendor/liburing/man/io_uring_unregister_buf_ring.3 +0 -30
  162. data/vendor/liburing/man/io_uring_unregister_buffers.3 +0 -27
  163. data/vendor/liburing/man/io_uring_unregister_eventfd.3 +0 -1
  164. data/vendor/liburing/man/io_uring_unregister_files.3 +0 -27
  165. data/vendor/liburing/man/io_uring_unregister_iowq_aff.3 +0 -1
  166. data/vendor/liburing/man/io_uring_unregister_ring_fd.3 +0 -32
  167. data/vendor/liburing/man/io_uring_wait_cqe.3 +0 -40
  168. data/vendor/liburing/man/io_uring_wait_cqe_nr.3 +0 -43
  169. data/vendor/liburing/man/io_uring_wait_cqe_timeout.3 +0 -53
  170. data/vendor/liburing/man/io_uring_wait_cqes.3 +0 -56
@@ -1,834 +0,0 @@
1
- .\" Copyright (C) 2019 Jens Axboe <axboe@kernel.dk>
2
- .\" Copyright (C) 2019 Red Hat, Inc.
3
- .\"
4
- .\" SPDX-License-Identifier: LGPL-2.0-or-later
5
- .\"
6
- .TH io_uring_register 2 2019-01-17 "Linux" "Linux Programmer's Manual"
7
- .SH NAME
8
- io_uring_register \- register files or user buffers for asynchronous I/O
9
- .SH SYNOPSIS
10
- .nf
11
- .BR "#include <liburing.h>"
12
- .PP
13
- .BI "int io_uring_register(unsigned int " fd ", unsigned int " opcode ,
14
- .BI " void *" arg ", unsigned int " nr_args );
15
- .fi
16
- .PP
17
- .SH DESCRIPTION
18
- .PP
19
-
20
- The
21
- .BR io_uring_register (2)
22
- system call registers resources (e.g. user buffers, files, eventfd,
23
- personality, restrictions) for use in an
24
- .BR io_uring (7)
25
- instance referenced by
26
- .IR fd .
27
- Registering files or user buffers allows the kernel to take long term
28
- references to internal data structures or create long term mappings of
29
- application memory, greatly reducing per-I/O overhead.
30
-
31
- .I fd
32
- is the file descriptor returned by a call to
33
- .BR io_uring_setup (2).
34
- If
35
- .I opcode
36
- has the flag
37
- .B IORING_REGISTER_USE_REGISTERED_RING
38
- ored into it,
39
- .I fd
40
- is instead the index of a registered ring fd.
41
-
42
- .I opcode
43
- can be one of:
44
-
45
- .TP
46
- .B IORING_REGISTER_BUFFERS
47
- .I arg
48
- points to a
49
- .I struct iovec
50
- array of
51
- .I nr_args
52
- entries. The buffers associated with the iovecs will be locked in
53
- memory and charged against the user's
54
- .B RLIMIT_MEMLOCK
55
- resource limit. See
56
- .BR getrlimit (2)
57
- for more information. Additionally, there is a size limit of 1GiB per
58
- buffer. Currently, the buffers must be anonymous, non-file-backed
59
- memory, such as that returned by
60
- .BR malloc (3)
61
- or
62
- .BR mmap (2)
63
- with the
64
- .B MAP_ANONYMOUS
65
- flag set. It is expected that this limitation will be lifted in the
66
- future. Huge pages are supported as well. Note that the entire huge
67
- page will be pinned in the kernel, even if only a portion of it is
68
- used.
69
-
70
- After a successful call, the supplied buffers are mapped into the
71
- kernel and eligible for I/O. To make use of them, the application
72
- must specify the
73
- .B IORING_OP_READ_FIXED
74
- or
75
- .B IORING_OP_WRITE_FIXED
76
- opcodes in the submission queue entry (see the
77
- .I struct io_uring_sqe
78
- definition in
79
- .BR io_uring_enter (2)),
80
- and set the
81
- .I buf_index
82
- field to the desired buffer index. The memory range described by the
83
- submission queue entry's
84
- .I addr
85
- and
86
- .I len
87
- fields must fall within the indexed buffer.
88
-
89
- It is perfectly valid to setup a large buffer and then only use part
90
- of it for an I/O, as long as the range is within the originally mapped
91
- region.
92
-
93
- An application can increase or decrease the size or number of
94
- registered buffers by first unregistering the existing buffers, and
95
- then issuing a new call to
96
- .BR io_uring_register (2)
97
- with the new buffers.
98
-
99
- Note that before 5.13 registering buffers would wait for the ring to idle.
100
- If the application currently has requests in-flight, the registration will
101
- wait for those to finish before proceeding.
102
-
103
- An application need not unregister buffers explicitly before shutting
104
- down the io_uring instance. Available since 5.1.
105
-
106
- .TP
107
- .B IORING_REGISTER_BUFFERS2
108
- Register buffers for I/O. Similar to
109
- .B IORING_REGISTER_BUFFERS
110
- but aims to have a more extensible ABI.
111
-
112
- .I arg
113
- points to a
114
- .I struct io_uring_rsrc_register,
115
- and
116
- .I nr_args
117
- should be set to the number of bytes in the structure.
118
-
119
- .PP
120
- .in +8n
121
- .EX
122
- struct io_uring_rsrc_register {
123
- __u32 nr;
124
- __u32 resv;
125
- __u64 resv2;
126
- __aligned_u64 data;
127
- __aligned_u64 tags;
128
- };
129
-
130
- .EE
131
- .in
132
- .PP
133
-
134
- .in +8n
135
-
136
- The
137
- .I data
138
- field contains a pointer to a
139
- .I struct iovec
140
- array of
141
- .I nr
142
- entries.
143
- The
144
- .I tags
145
- field should either be 0, then tagging is disabled, or point to an array
146
- of
147
- .I nr
148
- "tags" (unsigned 64 bit integers). If a tag is zero, then tagging for this
149
- particular resource (a buffer in this case) is disabled. Otherwise, after the
150
- resource had been unregistered and it's not used anymore, a CQE will be
151
- posted with
152
- .I user_data
153
- set to the specified tag and all other fields zeroed.
154
-
155
- Note that resource updates, e.g.
156
- .B IORING_REGISTER_BUFFERS_UPDATE,
157
- don't necessarily deallocate resources by the time it returns, but they might
158
- be held alive until all requests using it complete.
159
-
160
- Available since 5.13.
161
-
162
- .TP
163
- .B IORING_REGISTER_BUFFERS_UPDATE
164
- Updates registered buffers with new ones, either turning a sparse entry into
165
- a real one, or replacing an existing entry.
166
-
167
- .I arg
168
- must contain a pointer to a struct io_uring_rsrc_update2, which contains
169
- an offset on which to start the update, and an array of
170
- .I struct iovec.
171
- .I tags
172
- points to an array of tags.
173
- .I nr
174
- must contain the number of descriptors in the passed in arrays.
175
- See
176
- .B IORING_REGISTER_BUFFERS2
177
- for the resource tagging description.
178
-
179
- .PP
180
- .in +8n
181
- .EX
182
-
183
- struct io_uring_rsrc_update2 {
184
- __u32 offset;
185
- __u32 resv;
186
- __aligned_u64 data;
187
- __aligned_u64 tags;
188
- __u32 nr;
189
- __u32 resv2;
190
- };
191
- .EE
192
- .in
193
- .PP
194
-
195
- .in +8n
196
-
197
- Available since 5.13.
198
-
199
- .TP
200
- .B IORING_UNREGISTER_BUFFERS
201
- This operation takes no argument, and
202
- .I arg
203
- must be passed as NULL. All previously registered buffers associated
204
- with the io_uring instance will be released. Available since 5.1.
205
-
206
- .TP
207
- .B IORING_REGISTER_FILES
208
- Register files for I/O.
209
- .I arg
210
- contains a pointer to an array of
211
- .I nr_args
212
- file descriptors (signed 32 bit integers).
213
-
214
- To make use of the registered files, the
215
- .B IOSQE_FIXED_FILE
216
- flag must be set in the
217
- .I flags
218
- member of the
219
- .IR "struct io_uring_sqe" ,
220
- and the
221
- .I fd
222
- member is set to the index of the file in the file descriptor array.
223
-
224
- The file set may be sparse, meaning that the
225
- .B fd
226
- field in the array may be set to
227
- .B -1.
228
- See
229
- .B IORING_REGISTER_FILES_UPDATE
230
- for how to update files in place.
231
-
232
- Note that before 5.13 registering files would wait for the ring to idle.
233
- If the application currently has requests in-flight, the registration will
234
- wait for those to finish before proceeding. See
235
- .B IORING_REGISTER_FILES_UPDATE
236
- for how to update an existing set without that limitation.
237
-
238
- Files are automatically unregistered when the io_uring instance is
239
- torn down. An application needs only unregister if it wishes to
240
- register a new set of fds. Available since 5.1.
241
-
242
- .TP
243
- .B IORING_REGISTER_FILES2
244
- Register files for I/O. Similar to
245
- .B IORING_REGISTER_FILES.
246
-
247
- .I arg
248
- points to a
249
- .I struct io_uring_rsrc_register,
250
- and
251
- .I nr_args
252
- should be set to the number of bytes in the structure.
253
-
254
- The
255
- .I data
256
- field contains a pointer to an array of
257
- .I nr
258
- file descriptors (signed 32 bit integers).
259
- .I tags
260
- field should either be 0 or or point to an array of
261
- .I nr
262
- "tags" (unsigned 64 bit integers). See
263
- .B IORING_REGISTER_BUFFERS2
264
- for more info on resource tagging.
265
-
266
- Note that resource updates, e.g.
267
- .B IORING_REGISTER_FILES_UPDATE,
268
- don't necessarily deallocate resources, they might be held until all requests
269
- using that resource complete.
270
-
271
- Available since 5.13.
272
-
273
- .TP
274
- .B IORING_REGISTER_FILES_UPDATE
275
- This operation replaces existing files in the registered file set with new
276
- ones, either turning a sparse entry (one where fd is equal to
277
- .B -1
278
- ) into a real one, removing an existing entry (new one is set to
279
- .B -1
280
- ), or replacing an existing entry with a new existing entry.
281
-
282
- .I arg
283
- must contain a pointer to a
284
- .I struct io_uring_files_update,
285
- which contains
286
- an offset on which to start the update, and an array of file descriptors to
287
- use for the update.
288
- .I nr_args
289
- must contain the number of descriptors in the passed in array. Available
290
- since 5.5.
291
-
292
- File descriptors can be skipped if they are set to
293
- .B IORING_REGISTER_FILES_SKIP.
294
- Skipping an fd will not touch the file associated with the previous
295
- fd at that index. Available since 5.12.
296
-
297
- .TP
298
- .B IORING_REGISTER_FILES_UPDATE2
299
- Similar to IORING_REGISTER_FILES_UPDATE, replaces existing files in the
300
- registered file set with new ones, either turning a sparse entry (one where
301
- fd is equal to
302
- .B -1
303
- ) into a real one, removing an existing entry (new one is set to
304
- .B -1
305
- ), or replacing an existing entry with a new existing entry.
306
-
307
- .I arg
308
- must contain a pointer to a
309
- .I struct io_uring_rsrc_update2,
310
- which contains
311
- an offset on which to start the update, and an array of file descriptors to
312
- use for the update stored in
313
- .I data.
314
- .I tags
315
- points to an array of tags.
316
- .I nr
317
- must contain the number of descriptors in the passed in arrays.
318
- See
319
- .B IORING_REGISTER_BUFFERS2
320
- for the resource tagging description.
321
-
322
- Available since 5.13.
323
-
324
- .TP
325
- .B IORING_UNREGISTER_FILES
326
- This operation requires no argument, and
327
- .I arg
328
- must be passed as NULL. All previously registered files associated
329
- with the io_uring instance will be unregistered. Available since 5.1.
330
-
331
- .TP
332
- .B IORING_REGISTER_EVENTFD
333
- It's possible to use eventfd(2) to get notified of completion events on an
334
- io_uring instance. If this is desired, an eventfd file descriptor can be
335
- registered through this operation.
336
- .I arg
337
- must contain a pointer to the eventfd file descriptor, and
338
- .I nr_args
339
- must be 1. Note that while io_uring generally takes care to avoid spurious
340
- events, they can occur. Similarly, batched completions of CQEs may only trigger
341
- a single eventfd notification even if multiple CQEs are posted. The application
342
- should make no assumptions on number of events being available having a direct
343
- correlation to eventfd notifications posted. An eventfd notification must thus
344
- only be treated as a hint to check the CQ ring for completions. Available since
345
- 5.2.
346
-
347
- An application can temporarily disable notifications, coming through the
348
- registered eventfd, by setting the
349
- .B IORING_CQ_EVENTFD_DISABLED
350
- bit in the
351
- .I flags
352
- field of the CQ ring.
353
- Available since 5.8.
354
-
355
- .TP
356
- .B IORING_REGISTER_EVENTFD_ASYNC
357
- This works just like
358
- .B IORING_REGISTER_EVENTFD
359
- , except notifications are only posted for events that complete in an async
360
- manner. This means that events that complete inline while being submitted
361
- do not trigger a notification event. The arguments supplied are the same as
362
- for
363
- .B IORING_REGISTER_EVENTFD.
364
- Available since 5.6.
365
-
366
- .TP
367
- .B IORING_UNREGISTER_EVENTFD
368
- Unregister an eventfd file descriptor to stop notifications. Since only one
369
- eventfd descriptor is currently supported, this operation takes no argument,
370
- and
371
- .I arg
372
- must be passed as NULL and
373
- .I nr_args
374
- must be zero. Available since 5.2.
375
-
376
- .TP
377
- .B IORING_REGISTER_PROBE
378
- This operation returns a structure, io_uring_probe, which contains information
379
- about the opcodes supported by io_uring on the running kernel.
380
- .I arg
381
- must contain a pointer to a struct io_uring_probe, and
382
- .I nr_args
383
- must contain the size of the ops array in that probe struct. The ops array
384
- is of the type io_uring_probe_op, which holds the value of the opcode and
385
- a flags field. If the flags field has
386
- .B IO_URING_OP_SUPPORTED
387
- set, then this opcode is supported on the running kernel. Available since 5.6.
388
-
389
- .TP
390
- .B IORING_REGISTER_PERSONALITY
391
- This operation registers credentials of the running application with io_uring,
392
- and returns an id associated with these credentials. Applications wishing to
393
- share a ring between separate users/processes can pass in this credential id
394
- in the sqe
395
- .B personality
396
- field. If set, that particular sqe will be issued with these credentials. Must
397
- be invoked with
398
- .I arg
399
- set to NULL and
400
- .I nr_args
401
- set to zero. Available since 5.6.
402
-
403
- .TP
404
- .B IORING_UNREGISTER_PERSONALITY
405
- This operation unregisters a previously registered personality with io_uring.
406
- .I nr_args
407
- must be set to the id in question, and
408
- .I arg
409
- must be set to NULL. Available since 5.6.
410
-
411
- .TP
412
- .B IORING_REGISTER_ENABLE_RINGS
413
- This operation enables an io_uring ring started in a disabled state
414
- .RB (IORING_SETUP_R_DISABLED
415
- was specified in the call to
416
- .BR io_uring_setup (2)).
417
- While the io_uring ring is disabled, submissions are not allowed and
418
- registrations are not restricted.
419
-
420
- After the execution of this operation, the io_uring ring is enabled:
421
- submissions and registration are allowed, but they will
422
- be validated following the registered restrictions (if any).
423
- This operation takes no argument, must be invoked with
424
- .I arg
425
- set to NULL and
426
- .I nr_args
427
- set to zero. Available since 5.10.
428
-
429
- .TP
430
- .B IORING_REGISTER_RESTRICTIONS
431
- .I arg
432
- points to a
433
- .I struct io_uring_restriction
434
- array of
435
- .I nr_args
436
- entries.
437
-
438
- With an entry it is possible to allow an
439
- .BR io_uring_register (2)
440
- .I opcode,
441
- or specify which
442
- .I opcode
443
- and
444
- .I flags
445
- of the submission queue entry are allowed,
446
- or require certain
447
- .I flags
448
- to be specified (these flags must be set on each submission queue entry).
449
-
450
- All the restrictions must be submitted with a single
451
- .BR io_uring_register (2)
452
- call and they are handled as an allowlist (opcodes and flags not registered,
453
- are not allowed).
454
-
455
- Restrictions can be registered only if the io_uring ring started in a disabled
456
- state
457
- .RB (IORING_SETUP_R_DISABLED
458
- must be specified in the call to
459
- .BR io_uring_setup (2)).
460
-
461
- Available since 5.10.
462
-
463
- .TP
464
- .B IORING_REGISTER_IOWQ_AFF
465
- By default, async workers created by io_uring will inherit the CPU mask of its
466
- parent. This is usually all the CPUs in the system, unless the parent is being
467
- run with a limited set. If this isn't the desired outcome, the application
468
- may explicitly tell io_uring what CPUs the async workers may run on.
469
- .I arg
470
- must point to a
471
- .B cpu_set_t
472
- mask, and
473
- .I nr_args
474
- the byte size of that mask.
475
-
476
- Available since 5.14.
477
-
478
- .TP
479
- .B IORING_UNREGISTER_IOWQ_AFF
480
- Undoes a CPU mask previously set with
481
- .B IORING_REGISTER_IOWQ_AFF.
482
- Must not have
483
- .I arg
484
- or
485
- .I nr_args
486
- set.
487
-
488
- Available since 5.14.
489
-
490
- .TP
491
- .B IORING_REGISTER_IOWQ_MAX_WORKERS
492
- By default, io_uring limits the unbounded workers created to the maximum
493
- processor count set by
494
- .I RLIMIT_NPROC
495
- and the bounded workers is a function of the SQ ring size and the number
496
- of CPUs in the system. Sometimes this can be excessive (or too little, for
497
- bounded), and this command provides a way to change the count per ring (per NUMA
498
- node) instead.
499
-
500
- .I arg
501
- must be set to an
502
- .I unsigned int
503
- pointer to an array of two values, with the values in the array being set to
504
- the maximum count of workers per NUMA node. Index 0 holds the bounded worker
505
- count, and index 1 holds the unbounded worker count. On successful return, the
506
- passed in array will contain the previous maximum valyes for each type. If the
507
- count being passed in is 0, then this command returns the current maximum values
508
- and doesn't modify the current setting.
509
- .I nr_args
510
- must be set to 2, as the command takes two values.
511
-
512
- Available since 5.15.
513
-
514
- .TP
515
- .B IORING_REGISTER_RING_FDS
516
- Whenever
517
- .BR io_uring_enter (2)
518
- is called to submit request or wait for completions, the kernel must grab a
519
- reference to the file descriptor. If the application using io_uring is threaded,
520
- the file table is marked as shared, and the reference grab and put of the file
521
- descriptor count is more expensive than it is for a non-threaded application.
522
-
523
- Similarly to how io_uring allows registration of files, this allow registration
524
- of the ring file descriptor itself. This reduces the overhead of the
525
- .BR io_uring_enter (2)
526
- system call.
527
-
528
- .I arg
529
- must be set to an unsigned int pointer to an array of type
530
- .I struct io_uring_rsrc_register
531
- of
532
- .I nr_args
533
- number of entries. The
534
- .B data
535
- field of this struct must point to an io_uring file descriptor, and the
536
- .B offset
537
- field can be either
538
- .B -1
539
- or an explicit offset desired for the registered file descriptor value. If
540
- .B -1
541
- is used, then upon successful return of this system call, the field will
542
- contain the value of the registered file descriptor to be used for future
543
- .BR io_uring_enter (2)
544
- system calls.
545
-
546
- On successful completion of this request, the returned descriptors may be used
547
- instead of the real file descriptor for
548
- .BR io_uring_enter (2),
549
- provided that
550
- .B IORING_ENTER_REGISTERED_RING
551
- is set in the
552
- .I flags
553
- for the system call. This flag tells the kernel that a registered descriptor
554
- is used rather than a real file descriptor.
555
-
556
- Each thread or process using a ring must register the file descriptor directly
557
- by issuing this request.
558
-
559
- The maximum number of supported registered ring descriptors is currently
560
- limited to
561
- .B 16.
562
-
563
- Available since 5.18.
564
-
565
- .TP
566
- .B IORING_UNREGISTER_RING_FDS
567
- Unregister descriptors previously registered with
568
- .B IORING_REGISTER_RING_FDS.
569
-
570
- .I arg
571
- must be set to an unsigned int pointer to an array of type
572
- .I struct io_uring_rsrc_register
573
- of
574
- .I nr_args
575
- number of entries. Only the
576
- .B offset
577
- field should be set in the structure, containing the registered file descriptor
578
- offset previously returned from
579
- .B IORING_REGISTER_RING_FDS
580
- that the application wishes to unregister.
581
-
582
- Note that this isn't done automatically on ring exit, if the thread or task
583
- that previously registered a ring file descriptor isn't exiting. It is
584
- recommended to manually unregister any previously registered ring descriptors
585
- if the ring is closed and the task persists. This will free up a registration
586
- slot, making it available for future use.
587
-
588
- Available since 5.18.
589
-
590
- .TP
591
- .B IORING_REGISTER_PBUF_RING
592
- Registers a shared buffer ring to be used with provided buffers. This is a
593
- newer alternative to using
594
- .B IORING_OP_PROVIDE_BUFFERS
595
- which is more efficient, to be used with request types that support the
596
- .B IOSQE_BUFFER_SELECT
597
- flag.
598
-
599
- The
600
- .I arg
601
- argument must be filled in with the appropriate information. It looks as
602
- follows:
603
- .PP
604
- .in +12n
605
- .EX
606
- struct io_uring_buf_reg {
607
- __u64 ring_addr;
608
- __u32 ring_entries;
609
- __u16 bgid;
610
- __u16 pad;
611
- __u64 resv[3];
612
- };
613
- .EE
614
- .in
615
- .PP
616
- .in +8n
617
- The
618
- .I ring_addr
619
- field must contain the address to the memory allocated to fit this ring.
620
- The memory must be page aligned and hence allocated appropriately using eg
621
- .BR posix_memalign (3)
622
- or similar. The size of the ring is the product of
623
- .I ring_entries
624
- and the size of
625
- .IR "struct io_uring_buf" .
626
- .I ring_entries
627
- is the desired size of the ring, and must be a power-of-2 in size. The maximum
628
- size allowed is 2^15 (32768).
629
- .I bgid
630
- is the buffer group ID associated with this ring. SQEs that select a buffer
631
- have a buffer group associated with them in their
632
- .I buf_group
633
- field, and the associated CQEs will have
634
- .B IORING_CQE_F_BUFFER
635
- set in their
636
- .I flags
637
- member, which will also contain the specific ID of the buffer selected. The rest
638
- of the fields are reserved and must be cleared to zero.
639
-
640
- .I nr_args
641
- must be set to 1.
642
-
643
- Also see
644
- .BR io_uring_register_buf_ring (3)
645
- for more details. Available since 5.19.
646
-
647
- .TP
648
- .B IORING_UNREGISTER_PBUF_RING
649
- Unregister a previously registered provided buffer ring.
650
- .I arg
651
- must be set to the address of a struct io_uring_buf_reg, with just the
652
- .I bgid
653
- field set to the buffer group ID of the previously registered provided buffer
654
- group.
655
- .I nr_args
656
- must be set to 1. Also see
657
- .B IORING_REGISTER_PBUF_RING .
658
-
659
- Available since 5.19.
660
-
661
- .TP
662
- .B IORING_REGISTER_SYNC_CANCEL
663
- Performs a synchronous cancelation request, which works in a similar fashion to
664
- .B IORING_OP_ASYNC_CANCEL
665
- except it completes inline. This can be useful for scenarios where cancelations
666
- should happen synchronously, rather than needing to issue an SQE and wait for
667
- completion of that specific CQE.
668
-
669
- .I arg
670
- must be set to a pointer to a struct io_uring_sync_cancel_reg structure, with
671
- the details filled in for what request(s) to target for cancelation. See
672
- .BR io_uring_register_sync_cancel (3)
673
- for details on that. The return values are the same, except they are passed
674
- back synchronously rather than through the CQE
675
- .I res
676
- field.
677
- .I nr_args
678
- must be set to 1.
679
-
680
- Available since 6.0.
681
-
682
- .TP
683
- .B IORING_REGISTER_FILE_ALLOC_RANGE
684
- sets the allowable range for fixed file index allocations within the
685
- kernel. When requests that can instantiate a new fixed file are used with
686
- .B IORING_FILE_INDEX_ALLOC ,
687
- the application is asking the kernel to allocate a new fixed file descriptor
688
- rather than pass in a specific value for one. By default, the kernel will
689
- pick any available fixed file descriptor within the range available.
690
- This effectively allows the application to set aside a range just for dynamic
691
- allocations, with the remainder being used for specific values.
692
-
693
- .I nr_args
694
- must be set to 1 and
695
- .I arg
696
- must be set to a pointer to a struct io_uring_file_index_range:
697
- .PP
698
- .in +12n
699
- .EX
700
- struct io_uring_file_index_range {
701
- __u32 off;
702
- __u32 len;
703
- __u64 resv;
704
- };
705
- .EE
706
- .in
707
- .PP
708
- .in +8n
709
- with
710
- .I off
711
- being set to the starting value for the range, and
712
- .I len
713
- being set to the number of descriptors. The reserved
714
- .I resv
715
- field must be cleared to zero.
716
-
717
- The application must have registered a file table first.
718
-
719
- Available since 6.0.
720
-
721
- .SH RETURN VALUE
722
-
723
- On success,
724
- .BR io_uring_register (2)
725
- returns either 0 or a positive value, depending on the
726
- .I opcode
727
- used. On error, a negative error value is returned. The caller should not rely
728
- on the
729
- .I errno
730
- variable.
731
-
732
- .SH ERRORS
733
- .TP
734
- .B EACCES
735
- The
736
- .I opcode
737
- field is not allowed due to registered restrictions.
738
- .TP
739
- .B EBADF
740
- One or more fds in the
741
- .I fd
742
- array are invalid.
743
- .TP
744
- .B EBADFD
745
- .B IORING_REGISTER_ENABLE_RINGS
746
- or
747
- .B IORING_REGISTER_RESTRICTIONS
748
- was specified, but the io_uring ring is not disabled.
749
- .TP
750
- .B EBUSY
751
- .B IORING_REGISTER_BUFFERS
752
- or
753
- .B IORING_REGISTER_FILES
754
- or
755
- .B IORING_REGISTER_RESTRICTIONS
756
- was specified, but there were already buffers, files, or restrictions
757
- registered.
758
- .TP
759
- .B EFAULT
760
- buffer is outside of the process' accessible address space, or
761
- .I iov_len
762
- is greater than 1GiB.
763
- .TP
764
- .B EINVAL
765
- .B IORING_REGISTER_BUFFERS
766
- or
767
- .B IORING_REGISTER_FILES
768
- was specified, but
769
- .I nr_args
770
- is 0.
771
- .TP
772
- .B EINVAL
773
- .B IORING_REGISTER_BUFFERS
774
- was specified, but
775
- .I nr_args
776
- exceeds
777
- .B UIO_MAXIOV
778
- .TP
779
- .B EINVAL
780
- .B IORING_UNREGISTER_BUFFERS
781
- or
782
- .B IORING_UNREGISTER_FILES
783
- was specified, and
784
- .I nr_args
785
- is non-zero or
786
- .I arg
787
- is non-NULL.
788
- .TP
789
- .B EINVAL
790
- .B IORING_REGISTER_RESTRICTIONS
791
- was specified, but
792
- .I nr_args
793
- exceeds the maximum allowed number of restrictions or restriction
794
- .I opcode
795
- is invalid.
796
- .TP
797
- .B EMFILE
798
- .B IORING_REGISTER_FILES
799
- was specified and
800
- .I nr_args
801
- exceeds the maximum allowed number of files in a fixed file set.
802
- .TP
803
- .B EMFILE
804
- .B IORING_REGISTER_FILES
805
- was specified and adding
806
- .I nr_args
807
- file references would exceed the maximum allowed number of files the user
808
- is allowed to have according to the
809
- .B
810
- RLIMIT_NOFILE
811
- resource limit and the caller does not have
812
- .B CAP_SYS_RESOURCE
813
- capability. Note that this is a per user limit, not per process.
814
- .TP
815
- .B ENOMEM
816
- Insufficient kernel resources are available, or the caller had a
817
- non-zero
818
- .B RLIMIT_MEMLOCK
819
- soft resource limit, but tried to lock more memory than the limit
820
- permitted. This limit is not enforced if the process is privileged
821
- .RB ( CAP_IPC_LOCK ).
822
- .TP
823
- .B ENXIO
824
- .B IORING_UNREGISTER_BUFFERS
825
- or
826
- .B IORING_UNREGISTER_FILES
827
- was specified, but there were no buffers or files registered.
828
- .TP
829
- .B ENXIO
830
- Attempt to register files or buffers on an io_uring instance that is already
831
- undergoing file or buffer registration, or is being torn down.
832
- .TP
833
- .B EOPNOTSUPP
834
- User buffers point to file-backed memory.