uringmachine 0.10 → 0.11
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/examples/bm_side_running.rb +83 -0
- data/examples/bm_sqlite.rb +1 -1
- data/ext/um/um.c +17 -1
- data/ext/um/um.h +29 -0
- data/ext/um/um_ext.c +2 -0
- data/ext/um/um_stream.c +344 -0
- data/ext/um/um_stream_class.c +140 -0
- data/lib/uringmachine/version.rb +1 -1
- data/lib/uringmachine.rb +20 -16
- data/test/test_stream.rb +133 -0
- data/test/test_um.rb +63 -0
- data/vendor/liburing/.github/workflows/{build.yml → ci.yml} +107 -42
- data/vendor/liburing/.gitignore +1 -0
- data/vendor/liburing/CHANGELOG +10 -0
- data/vendor/liburing/README +5 -0
- data/vendor/liburing/configure +1 -1
- data/vendor/liburing/examples/Makefile +1 -0
- data/vendor/liburing/examples/helpers.c +25 -0
- data/vendor/liburing/examples/helpers.h +13 -0
- data/vendor/liburing/examples/io_uring-test.c +3 -0
- data/vendor/liburing/examples/proxy.c +1 -1
- data/vendor/liburing/examples/reg-wait.c +41 -6
- data/vendor/liburing/examples/send-zerocopy.c +79 -32
- data/vendor/liburing/examples/zcrx.c +436 -0
- data/vendor/liburing/liburing.spec +1 -1
- data/vendor/liburing/src/Makefile +0 -1
- data/vendor/liburing/src/arch/generic/syscall.h +2 -2
- data/vendor/liburing/src/arch/syscall-defs.h +2 -2
- data/vendor/liburing/src/include/liburing/io_uring.h +101 -17
- data/vendor/liburing/src/include/liburing.h +179 -59
- data/vendor/liburing/src/int_flags.h +4 -1
- data/vendor/liburing/src/liburing-ffi.map +14 -2
- data/vendor/liburing/src/liburing.map +9 -2
- data/vendor/liburing/src/queue.c +35 -30
- data/vendor/liburing/src/register.c +46 -15
- data/vendor/liburing/src/sanitize.c +6 -9
- data/vendor/liburing/src/setup.c +37 -71
- data/vendor/liburing/src/syscall.c +2 -2
- data/vendor/liburing/test/232c93d07b74.c +1 -0
- data/vendor/liburing/test/Makefile +9 -0
- data/vendor/liburing/test/accept-test.c +1 -0
- data/vendor/liburing/test/cmd-discard.c +16 -8
- data/vendor/liburing/test/connect.c +11 -7
- data/vendor/liburing/test/epwait.c +420 -0
- data/vendor/liburing/test/eventfd-ring.c +30 -5
- data/vendor/liburing/test/fallocate.c +1 -1
- data/vendor/liburing/test/fixed-hugepage.c +10 -7
- data/vendor/liburing/test/fixed-seg.c +187 -0
- data/vendor/liburing/test/helpers.c +121 -0
- data/vendor/liburing/test/helpers.h +13 -0
- data/vendor/liburing/test/init-mem.c +2 -0
- data/vendor/liburing/test/io_uring_passthrough.c +78 -62
- data/vendor/liburing/test/iopoll-overflow.c +5 -4
- data/vendor/liburing/test/iopoll.c +20 -10
- data/vendor/liburing/test/iowait.c +141 -0
- data/vendor/liburing/test/nvme.h +2 -0
- data/vendor/liburing/test/pipe-bug.c +11 -5
- data/vendor/liburing/test/pipe-eof.c +11 -1
- data/vendor/liburing/test/read-inc-file.c +150 -0
- data/vendor/liburing/test/read-write.c +21 -14
- data/vendor/liburing/test/recv-bundle-short-ooo.c +435 -0
- data/vendor/liburing/test/recv-multishot.c +2 -2
- data/vendor/liburing/test/reg-wait.c +449 -120
- data/vendor/liburing/test/regbuf-clone.c +53 -0
- data/vendor/liburing/test/resize-rings.c +25 -2
- data/vendor/liburing/test/rsrc_tags.c +67 -14
- data/vendor/liburing/test/send-zerocopy.c +52 -130
- data/vendor/liburing/test/sendmsg_iov_clean.c +216 -0
- data/vendor/liburing/test/socket-nb.c +158 -0
- data/vendor/liburing/test/sqwait.c +9 -11
- data/vendor/liburing/test/timeout.c +198 -0
- data/vendor/liburing/test/vec-regbuf.c +609 -0
- data/vendor/liburing/test/wait-timeout.c +1 -1
- data/vendor/liburing/test/wq-aff.c +5 -1
- data/vendor/liburing/test/zcrx.c +928 -0
- metadata +16 -4
- data/vendor/liburing/.github/workflows/codespell.yml +0 -25
- data/vendor/liburing/.github/workflows/shellcheck.yml +0 -20
@@ -0,0 +1,420 @@
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
2
|
+
/*
|
3
|
+
* Test various invocations of IORING_OP_EPOLL_WAIT
|
4
|
+
*/
|
5
|
+
#include <stdio.h>
|
6
|
+
#include <unistd.h>
|
7
|
+
#include <stdlib.h>
|
8
|
+
#include <sys/epoll.h>
|
9
|
+
#include <sys/types.h>
|
10
|
+
#include <poll.h>
|
11
|
+
#include <string.h>
|
12
|
+
#include <pthread.h>
|
13
|
+
#include "liburing.h"
|
14
|
+
#include "helpers.h"
|
15
|
+
|
16
|
+
static int fds[2][2];
|
17
|
+
static int no_epoll_wait;
|
18
|
+
|
19
|
+
static int test_ready(struct io_uring *ring, int efd)
|
20
|
+
{
|
21
|
+
struct io_uring_sqe *sqe;
|
22
|
+
struct io_uring_cqe *cqe;
|
23
|
+
struct epoll_event out[2];
|
24
|
+
char tmp[16];
|
25
|
+
int i, ret;
|
26
|
+
|
27
|
+
for (i = 0; i < 2; i++) {
|
28
|
+
ret = write(fds[i][1], "foo", 3);
|
29
|
+
if (ret < 0)
|
30
|
+
perror("write");
|
31
|
+
}
|
32
|
+
|
33
|
+
memset(out, 0, sizeof(out));
|
34
|
+
sqe = io_uring_get_sqe(ring);
|
35
|
+
io_uring_prep_epoll_wait(sqe, efd, out, 2, 0);
|
36
|
+
sqe->user_data = 1;
|
37
|
+
io_uring_submit(ring);
|
38
|
+
|
39
|
+
for (i = 0; i < 1; i++) {
|
40
|
+
ret = io_uring_wait_cqe(ring, &cqe);
|
41
|
+
if (ret) {
|
42
|
+
fprintf(stderr, "wait_cqe ret = %d\n", ret);
|
43
|
+
return 1;
|
44
|
+
}
|
45
|
+
if (cqe->res == -EINVAL) {
|
46
|
+
no_epoll_wait = 1;
|
47
|
+
return 0;
|
48
|
+
}
|
49
|
+
io_uring_cqe_seen(ring, cqe);
|
50
|
+
}
|
51
|
+
|
52
|
+
for (i = 0; i < 2; i++) {
|
53
|
+
ret = read(out[i].data.fd, tmp, sizeof(tmp));
|
54
|
+
if (ret < 0)
|
55
|
+
perror("read");
|
56
|
+
}
|
57
|
+
|
58
|
+
return 0;
|
59
|
+
}
|
60
|
+
|
61
|
+
static int test_not_ready(struct io_uring *ring, int efd)
|
62
|
+
{
|
63
|
+
struct io_uring_sqe *sqe;
|
64
|
+
struct io_uring_cqe *cqe;
|
65
|
+
struct epoll_event out[2];
|
66
|
+
int i, ret, nr;
|
67
|
+
char tmp[16];
|
68
|
+
|
69
|
+
memset(out, 0, sizeof(out));
|
70
|
+
sqe = io_uring_get_sqe(ring);
|
71
|
+
io_uring_prep_epoll_wait(sqe, efd, out, 2, 0);
|
72
|
+
sqe->user_data = 1;
|
73
|
+
io_uring_submit(ring);
|
74
|
+
|
75
|
+
for (i = 0; i < 2; i++) {
|
76
|
+
usleep(10000);
|
77
|
+
ret = write(fds[i][1], "foo", 3);
|
78
|
+
if (ret < 0)
|
79
|
+
perror("write");
|
80
|
+
}
|
81
|
+
|
82
|
+
nr = 0;
|
83
|
+
for (i = 0; i < 1; i++) {
|
84
|
+
ret = io_uring_wait_cqe(ring, &cqe);
|
85
|
+
if (ret) {
|
86
|
+
fprintf(stderr, "wait_cqe ret = %d\n", ret);
|
87
|
+
break;
|
88
|
+
}
|
89
|
+
nr = cqe->res;
|
90
|
+
io_uring_cqe_seen(ring, cqe);
|
91
|
+
if (nr < 0) {
|
92
|
+
fprintf(stderr, "not ready res %d\n", nr);
|
93
|
+
return 1;
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
for (i = 0; i < nr; i++) {
|
98
|
+
ret = read(out[i].data.fd, tmp, sizeof(tmp));
|
99
|
+
if (ret < 0)
|
100
|
+
perror("read");
|
101
|
+
}
|
102
|
+
|
103
|
+
return 0;
|
104
|
+
}
|
105
|
+
|
106
|
+
static int test_del(struct io_uring *ring, int efd)
|
107
|
+
{
|
108
|
+
struct io_uring_sqe *sqe;
|
109
|
+
struct io_uring_cqe *cqe;
|
110
|
+
struct epoll_event ev, out[2];
|
111
|
+
int i, ret;
|
112
|
+
char tmp[16];
|
113
|
+
|
114
|
+
memset(out, 0, sizeof(out));
|
115
|
+
sqe = io_uring_get_sqe(ring);
|
116
|
+
io_uring_prep_epoll_wait(sqe, efd, out, 2, 0);
|
117
|
+
sqe->user_data = 1;
|
118
|
+
io_uring_submit(ring);
|
119
|
+
|
120
|
+
ev.events = EPOLLIN;
|
121
|
+
ev.data.fd = fds[0][0];
|
122
|
+
ret = epoll_ctl(efd, EPOLL_CTL_DEL, fds[0][0], &ev);
|
123
|
+
if (ret < 0) {
|
124
|
+
perror("epoll_ctl");
|
125
|
+
return T_EXIT_FAIL;
|
126
|
+
}
|
127
|
+
|
128
|
+
for (i = 0; i < 2; i++) {
|
129
|
+
ret = write(fds[i][1], "foo", 3);
|
130
|
+
if (ret < 0)
|
131
|
+
perror("write");
|
132
|
+
}
|
133
|
+
|
134
|
+
for (i = 0; i < 1; i++) {
|
135
|
+
ret = io_uring_wait_cqe(ring, &cqe);
|
136
|
+
if (ret) {
|
137
|
+
fprintf(stderr, "wait_cqe ret = %d\n", ret);
|
138
|
+
break;
|
139
|
+
}
|
140
|
+
io_uring_cqe_seen(ring, cqe);
|
141
|
+
}
|
142
|
+
|
143
|
+
for (i = 0; i < 2; i++) {
|
144
|
+
ret = read(fds[i][0], tmp, sizeof(tmp));
|
145
|
+
if (ret < 0)
|
146
|
+
perror("read");
|
147
|
+
}
|
148
|
+
|
149
|
+
ev.events = EPOLLIN;
|
150
|
+
ev.data.fd = fds[0][0];
|
151
|
+
ret = epoll_ctl(efd, EPOLL_CTL_ADD, fds[0][0], &ev);
|
152
|
+
if (ret < 0) {
|
153
|
+
perror("epoll_ctl");
|
154
|
+
return T_EXIT_FAIL;
|
155
|
+
}
|
156
|
+
|
157
|
+
return 0;
|
158
|
+
}
|
159
|
+
|
160
|
+
static int test_remove(struct io_uring *ring, int efd)
|
161
|
+
{
|
162
|
+
struct io_uring_sqe *sqe;
|
163
|
+
struct io_uring_cqe *cqe;
|
164
|
+
struct epoll_event out[2];
|
165
|
+
int i, ret;
|
166
|
+
|
167
|
+
memset(out, 0, sizeof(out));
|
168
|
+
sqe = io_uring_get_sqe(ring);
|
169
|
+
io_uring_prep_epoll_wait(sqe, efd, out, 2, 0);
|
170
|
+
sqe->user_data = 1;
|
171
|
+
io_uring_submit(ring);
|
172
|
+
|
173
|
+
close(efd);
|
174
|
+
|
175
|
+
usleep(10000);
|
176
|
+
for (i = 0; i < 2; i++) {
|
177
|
+
ret = write(fds[i][1], "foo", 3);
|
178
|
+
if (ret < 0)
|
179
|
+
perror("write");
|
180
|
+
}
|
181
|
+
|
182
|
+
for (i = 0; i < 1; i++) {
|
183
|
+
ret = io_uring_peek_cqe(ring, &cqe);
|
184
|
+
if (ret == -EAGAIN) {
|
185
|
+
break;
|
186
|
+
} else if (ret) {
|
187
|
+
fprintf(stderr, "wait_cqe ret = %d\n", ret);
|
188
|
+
break;
|
189
|
+
}
|
190
|
+
io_uring_cqe_seen(ring, cqe);
|
191
|
+
}
|
192
|
+
|
193
|
+
return 0;
|
194
|
+
}
|
195
|
+
|
196
|
+
#define LOOPS 500
|
197
|
+
#define NPIPES 8
|
198
|
+
|
199
|
+
struct d {
|
200
|
+
int pipes[NPIPES][2];
|
201
|
+
};
|
202
|
+
|
203
|
+
static void *thread_fn(void *data)
|
204
|
+
{
|
205
|
+
struct d *d = data;
|
206
|
+
int i, j;
|
207
|
+
|
208
|
+
for (j = 0; j < LOOPS; j++) {
|
209
|
+
usleep(150);
|
210
|
+
for (i = 0; i < NPIPES; i++) {
|
211
|
+
int ret;
|
212
|
+
|
213
|
+
ret = write(d->pipes[i][1], "foo", 3);
|
214
|
+
if (ret < 0)
|
215
|
+
perror("write");
|
216
|
+
}
|
217
|
+
}
|
218
|
+
|
219
|
+
return NULL;
|
220
|
+
}
|
221
|
+
|
222
|
+
static void prune(struct epoll_event *evs, int nr)
|
223
|
+
{
|
224
|
+
char tmp[32];
|
225
|
+
int i, ret;
|
226
|
+
|
227
|
+
for (i = 0; i < nr; i++) {
|
228
|
+
ret = read(evs[i].data.fd, tmp, sizeof(tmp));
|
229
|
+
if (ret < 0)
|
230
|
+
perror("read");
|
231
|
+
}
|
232
|
+
}
|
233
|
+
|
234
|
+
static int test_race(int flags)
|
235
|
+
{
|
236
|
+
struct io_uring_cqe *cqe;
|
237
|
+
struct io_uring_sqe *sqe;
|
238
|
+
struct io_uring ring;
|
239
|
+
struct d d;
|
240
|
+
struct epoll_event ev;
|
241
|
+
struct epoll_event out[NPIPES];
|
242
|
+
pthread_t thread;
|
243
|
+
int i, j, efd, ret;
|
244
|
+
void *tret;
|
245
|
+
|
246
|
+
ret = t_create_ring(32, &ring, flags);
|
247
|
+
if (ret == T_SETUP_SKIP) {
|
248
|
+
return 0;
|
249
|
+
} else if (ret != T_SETUP_OK) {
|
250
|
+
fprintf(stderr, "ring create failed %x -> %d\n", flags, ret);
|
251
|
+
return 1;
|
252
|
+
}
|
253
|
+
|
254
|
+
for (i = 0; i < NPIPES; i++) {
|
255
|
+
if (pipe(d.pipes[i]) < 0) {
|
256
|
+
perror("pipe");
|
257
|
+
return 1;
|
258
|
+
}
|
259
|
+
}
|
260
|
+
|
261
|
+
efd = epoll_create1(0);
|
262
|
+
if (efd < 0) {
|
263
|
+
perror("epoll_create");
|
264
|
+
return T_EXIT_FAIL;
|
265
|
+
}
|
266
|
+
|
267
|
+
for (i = 0; i < NPIPES; i++) {
|
268
|
+
ev.events = EPOLLIN;
|
269
|
+
ev.data.fd = d.pipes[i][0];
|
270
|
+
ret = epoll_ctl(efd, EPOLL_CTL_ADD, d.pipes[i][0], &ev);
|
271
|
+
if (ret < 0) {
|
272
|
+
perror("epoll_ctl");
|
273
|
+
return T_EXIT_FAIL;
|
274
|
+
}
|
275
|
+
}
|
276
|
+
|
277
|
+
sqe = io_uring_get_sqe(&ring);
|
278
|
+
io_uring_prep_epoll_wait(sqe, efd, out, NPIPES, 0);
|
279
|
+
io_uring_submit(&ring);
|
280
|
+
|
281
|
+
pthread_create(&thread, NULL, thread_fn, &d);
|
282
|
+
|
283
|
+
for (j = 0; j < LOOPS; j++) {
|
284
|
+
io_uring_submit_and_wait(&ring, 1);
|
285
|
+
|
286
|
+
ret = io_uring_wait_cqe(&ring, &cqe);
|
287
|
+
if (ret) {
|
288
|
+
fprintf(stderr, "wait %d\n", ret);
|
289
|
+
return 1;
|
290
|
+
}
|
291
|
+
if (cqe->res < 0) {
|
292
|
+
fprintf(stderr, "race res %d\n", cqe->res);
|
293
|
+
return 1;
|
294
|
+
}
|
295
|
+
prune(out, cqe->res);
|
296
|
+
io_uring_cqe_seen(&ring, cqe);
|
297
|
+
usleep(100);
|
298
|
+
sqe = io_uring_get_sqe(&ring);
|
299
|
+
io_uring_prep_epoll_wait(sqe, efd, out, NPIPES, 0);
|
300
|
+
}
|
301
|
+
|
302
|
+
pthread_join(thread, &tret);
|
303
|
+
|
304
|
+
for (i = 0; i < NPIPES; i++) {
|
305
|
+
close(d.pipes[i][0]);
|
306
|
+
close(d.pipes[i][1]);
|
307
|
+
}
|
308
|
+
close(efd);
|
309
|
+
io_uring_queue_exit(&ring);
|
310
|
+
return 0;
|
311
|
+
}
|
312
|
+
|
313
|
+
static int test(int flags)
|
314
|
+
{
|
315
|
+
struct epoll_event ev = { };
|
316
|
+
struct io_uring ring;
|
317
|
+
int epollfd, ret, i;
|
318
|
+
|
319
|
+
ret = t_create_ring(8, &ring, flags);
|
320
|
+
if (ret == T_SETUP_SKIP) {
|
321
|
+
return T_EXIT_SKIP;
|
322
|
+
} else if (ret != T_SETUP_OK) {
|
323
|
+
fprintf(stderr, "ring create failed %x -> %d\n", flags, ret);
|
324
|
+
return T_EXIT_FAIL;
|
325
|
+
}
|
326
|
+
|
327
|
+
for (i = 0; i < 2; i++) {
|
328
|
+
if (pipe(fds[i]) < 0) {
|
329
|
+
perror("pipe");
|
330
|
+
return T_EXIT_FAIL;
|
331
|
+
}
|
332
|
+
}
|
333
|
+
|
334
|
+
epollfd = epoll_create1(0);
|
335
|
+
if (epollfd < 0) {
|
336
|
+
perror("epoll_create");
|
337
|
+
return T_EXIT_FAIL;
|
338
|
+
}
|
339
|
+
|
340
|
+
for (i = 0; i < 2; i++) {
|
341
|
+
ev.events = EPOLLIN;
|
342
|
+
ev.data.fd = fds[i][0];
|
343
|
+
ret = epoll_ctl(epollfd, EPOLL_CTL_ADD, fds[i][0], &ev);
|
344
|
+
if (ret < 0) {
|
345
|
+
perror("epoll_ctl");
|
346
|
+
return T_EXIT_FAIL;
|
347
|
+
}
|
348
|
+
}
|
349
|
+
|
350
|
+
ret = test_ready(&ring, epollfd);
|
351
|
+
if (ret) {
|
352
|
+
fprintf(stderr, "test_ready failed\n");
|
353
|
+
return T_EXIT_FAIL;
|
354
|
+
}
|
355
|
+
if (no_epoll_wait)
|
356
|
+
return T_EXIT_SKIP;
|
357
|
+
|
358
|
+
ret = test_not_ready(&ring, epollfd);
|
359
|
+
if (ret) {
|
360
|
+
fprintf(stderr, "test_not_ready failed\n");
|
361
|
+
return T_EXIT_FAIL;
|
362
|
+
}
|
363
|
+
|
364
|
+
ret = test_del(&ring, epollfd);
|
365
|
+
if (ret) {
|
366
|
+
fprintf(stderr, "test_del failed\n");
|
367
|
+
return T_EXIT_FAIL;
|
368
|
+
}
|
369
|
+
|
370
|
+
/* keep last */
|
371
|
+
ret = test_remove(&ring, epollfd);
|
372
|
+
if (ret) {
|
373
|
+
fprintf(stderr, "test_remove failed\n");
|
374
|
+
return T_EXIT_FAIL;
|
375
|
+
}
|
376
|
+
|
377
|
+
for (i = 0; i < 2; i++) {
|
378
|
+
close(fds[i][0]);
|
379
|
+
close(fds[i][1]);
|
380
|
+
}
|
381
|
+
|
382
|
+
ret = test_race(flags);
|
383
|
+
if (ret) {
|
384
|
+
fprintf(stderr, "test_race failed\n");
|
385
|
+
return T_EXIT_FAIL;
|
386
|
+
}
|
387
|
+
|
388
|
+
close(epollfd);
|
389
|
+
return 0;
|
390
|
+
}
|
391
|
+
|
392
|
+
int main(int argc, char *argv[])
|
393
|
+
{
|
394
|
+
int ret;
|
395
|
+
|
396
|
+
if (argc > 1)
|
397
|
+
return T_EXIT_SKIP;
|
398
|
+
|
399
|
+
ret = test(0);
|
400
|
+
if (ret == T_EXIT_SKIP)
|
401
|
+
return T_EXIT_SKIP;
|
402
|
+
else if (ret) {
|
403
|
+
fprintf(stderr, "test 0 failed\n");
|
404
|
+
return T_EXIT_FAIL;
|
405
|
+
}
|
406
|
+
|
407
|
+
ret = test(IORING_SETUP_DEFER_TASKRUN|IORING_SETUP_SINGLE_ISSUER);
|
408
|
+
if (ret) {
|
409
|
+
fprintf(stderr, "test defer failed\n");
|
410
|
+
return T_EXIT_FAIL;
|
411
|
+
}
|
412
|
+
|
413
|
+
ret = test(IORING_SETUP_SQPOLL);
|
414
|
+
if (ret) {
|
415
|
+
fprintf(stderr, "test sqpoll failed\n");
|
416
|
+
return T_EXIT_FAIL;
|
417
|
+
}
|
418
|
+
|
419
|
+
return T_EXIT_PASS;
|
420
|
+
}
|
@@ -15,16 +15,14 @@
|
|
15
15
|
#include "liburing.h"
|
16
16
|
#include "helpers.h"
|
17
17
|
|
18
|
-
int
|
18
|
+
static int test(int flags)
|
19
19
|
{
|
20
20
|
struct io_uring_params p = {};
|
21
21
|
struct io_uring ring1, ring2;
|
22
22
|
struct io_uring_sqe *sqe;
|
23
23
|
int ret, evfd1, evfd2;
|
24
24
|
|
25
|
-
|
26
|
-
return T_EXIT_SKIP;
|
27
|
-
|
25
|
+
p.flags = flags;
|
28
26
|
ret = io_uring_queue_init_params(8, &ring1, &p);
|
29
27
|
if (ret) {
|
30
28
|
fprintf(stderr, "ring setup failed: %d\n", ret);
|
@@ -34,7 +32,7 @@ int main(int argc, char *argv[])
|
|
34
32
|
fprintf(stdout, "Skipping\n");
|
35
33
|
return T_EXIT_SKIP;
|
36
34
|
}
|
37
|
-
ret = io_uring_queue_init(8, &ring2,
|
35
|
+
ret = io_uring_queue_init(8, &ring2, flags);
|
38
36
|
if (ret) {
|
39
37
|
fprintf(stderr, "ring setup failed: %d\n", ret);
|
40
38
|
return T_EXIT_FAIL;
|
@@ -94,5 +92,32 @@ int main(int argc, char *argv[])
|
|
94
92
|
return T_EXIT_FAIL;
|
95
93
|
}
|
96
94
|
|
95
|
+
return T_EXIT_PASS;
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
int main(int argc, char *argv[])
|
100
|
+
{
|
101
|
+
int ret;
|
102
|
+
|
103
|
+
if (argc > 1)
|
104
|
+
return T_EXIT_SKIP;
|
105
|
+
|
106
|
+
ret = test(0);
|
107
|
+
if (ret == T_EXIT_SKIP) {
|
108
|
+
return T_EXIT_SKIP;
|
109
|
+
} else if (ret != T_EXIT_PASS) {
|
110
|
+
fprintf(stderr, "test 0 failed\n");
|
111
|
+
return T_EXIT_FAIL;
|
112
|
+
}
|
113
|
+
|
114
|
+
ret = test(IORING_SETUP_DEFER_TASKRUN|IORING_SETUP_SINGLE_ISSUER);
|
115
|
+
if (ret == T_EXIT_SKIP) {
|
116
|
+
return T_EXIT_SKIP;
|
117
|
+
} else if (ret != T_EXIT_PASS) {
|
118
|
+
fprintf(stderr, "test defer failed\n");
|
119
|
+
return T_EXIT_FAIL;
|
120
|
+
}
|
121
|
+
|
97
122
|
return T_EXIT_PASS;
|
98
123
|
}
|
@@ -47,8 +47,11 @@ static void unmap(struct iovec *iov, int nr_bufs, size_t offset)
|
|
47
47
|
{
|
48
48
|
int i;
|
49
49
|
|
50
|
-
for (i = 0; i < nr_bufs; i++)
|
50
|
+
for (i = 0; i < nr_bufs; i++) {
|
51
|
+
if (!iov[i].iov_base)
|
52
|
+
continue;
|
51
53
|
munmap(iov[i].iov_base - offset, iov[i].iov_len + offset);
|
54
|
+
}
|
52
55
|
}
|
53
56
|
|
54
57
|
static int mmap_hugebufs(struct iovec *iov, int nr_bufs, size_t buf_size, size_t offset)
|
@@ -246,7 +249,7 @@ static int register_submit(struct io_uring *ring, struct iovec *iov,
|
|
246
249
|
|
247
250
|
ret = io_uring_register_buffers(ring, iov, nr_bufs);
|
248
251
|
if (ret) {
|
249
|
-
if (ret != -ENOMEM)
|
252
|
+
if (ret != -ENOMEM && ret != -EINVAL)
|
250
253
|
fprintf(stderr, "Error registering buffers: %s\n", strerror(-ret));
|
251
254
|
return ret;
|
252
255
|
}
|
@@ -283,7 +286,7 @@ static int test_one_hugepage(struct io_uring *ring, int fd_in, int fd_out)
|
|
283
286
|
|
284
287
|
ret = register_submit(ring, iov, NR_BUFS, fd_in, fd_out);
|
285
288
|
unmap(iov, NR_BUFS, 0);
|
286
|
-
if (ret == -ENOMEM)
|
289
|
+
if (ret == -ENOMEM || ret == -EINVAL)
|
287
290
|
return T_EXIT_SKIP;
|
288
291
|
return ret ? T_EXIT_FAIL : T_EXIT_PASS;
|
289
292
|
}
|
@@ -299,7 +302,7 @@ static int test_multi_hugepages(struct io_uring *ring, int fd_in, int fd_out)
|
|
299
302
|
|
300
303
|
ret = register_submit(ring, iov, NR_BUFS, fd_in, fd_out);
|
301
304
|
unmap(iov, NR_BUFS, 0);
|
302
|
-
if (ret == -ENOMEM)
|
305
|
+
if (ret == -ENOMEM || ret == -EINVAL)
|
303
306
|
return T_EXIT_SKIP;
|
304
307
|
return ret ? T_EXIT_FAIL : T_EXIT_PASS;
|
305
308
|
}
|
@@ -316,7 +319,7 @@ static int test_unaligned_hugepage(struct io_uring *ring, int fd_in, int fd_out)
|
|
316
319
|
|
317
320
|
ret = register_submit(ring, iov, NR_BUFS, fd_in, fd_out);
|
318
321
|
unmap(iov, NR_BUFS, offset);
|
319
|
-
if (ret == -ENOMEM)
|
322
|
+
if (ret == -ENOMEM || ret == -EINVAL)
|
320
323
|
return T_EXIT_SKIP;
|
321
324
|
return ret ? T_EXIT_FAIL : T_EXIT_PASS;
|
322
325
|
}
|
@@ -333,7 +336,7 @@ static int test_multi_unaligned_mthps(struct io_uring *ring, int fd_in, int fd_o
|
|
333
336
|
|
334
337
|
ret = register_submit(ring, iov, NR_BUFS, fd_in, fd_out);
|
335
338
|
free_bufs(iov, NR_BUFS, offset);
|
336
|
-
if (ret == -ENOMEM)
|
339
|
+
if (ret == -ENOMEM || ret == -EINVAL)
|
337
340
|
return T_EXIT_SKIP;
|
338
341
|
return ret ? T_EXIT_FAIL : T_EXIT_PASS;
|
339
342
|
}
|
@@ -350,7 +353,7 @@ static int test_page_mixture(struct io_uring *ring, int fd_in, int fd_out, int h
|
|
350
353
|
|
351
354
|
ret = register_submit(ring, iov, NR_BUFS, fd_in, fd_out);
|
352
355
|
unmap(iov, NR_BUFS, 0);
|
353
|
-
if (ret == -ENOMEM)
|
356
|
+
if (ret == -ENOMEM || ret == -EINVAL)
|
354
357
|
return T_EXIT_SKIP;
|
355
358
|
return ret ? T_EXIT_FAIL : T_EXIT_PASS;
|
356
359
|
}
|