uringmachine 0.1
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 +7 -0
- data/.github/dependabot.yml +12 -0
- data/.github/workflows/test.yml +35 -0
- data/.gitignore +59 -0
- data/.gitmodules +3 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +11 -0
- data/Rakefile +39 -0
- data/TODO.md +0 -0
- data/examples/echo_server.rb +52 -0
- data/examples/event_loop.rb +69 -0
- data/examples/fibers.rb +105 -0
- data/examples/http_server.rb +56 -0
- data/examples/http_server_multishot.rb +57 -0
- data/examples/http_server_simpler.rb +34 -0
- data/ext/um/extconf.rb +71 -0
- data/ext/um/iou.h +101 -0
- data/ext/um/op_ctx.c +138 -0
- data/ext/um/ring.c +755 -0
- data/ext/um/um.c +267 -0
- data/ext/um/um.h +97 -0
- data/ext/um/um_class.c +175 -0
- data/ext/um/um_ext.c +11 -0
- data/ext/um/um_op.c +87 -0
- data/ext/um/um_utils.c +23 -0
- data/lib/uringmachine/version.rb +3 -0
- data/lib/uringmachine.rb +8 -0
- data/test/helper.rb +70 -0
- data/test/test_iou.rb +876 -0
- data/test/test_um.rb +168 -0
- data/uringmachine.gemspec +27 -0
- data/vendor/liburing/.github/actions/codespell/stopwords +7 -0
- data/vendor/liburing/.github/pull_request_template.md +86 -0
- data/vendor/liburing/.github/workflows/build.yml +137 -0
- data/vendor/liburing/.github/workflows/codespell.yml +25 -0
- data/vendor/liburing/.github/workflows/shellcheck.yml +20 -0
- data/vendor/liburing/.gitignore +41 -0
- data/vendor/liburing/CHANGELOG +111 -0
- data/vendor/liburing/CITATION.cff +11 -0
- data/vendor/liburing/COPYING +502 -0
- data/vendor/liburing/COPYING.GPL +339 -0
- data/vendor/liburing/LICENSE +20 -0
- data/vendor/liburing/Makefile +96 -0
- data/vendor/liburing/Makefile.common +7 -0
- data/vendor/liburing/Makefile.quiet +11 -0
- data/vendor/liburing/README +106 -0
- data/vendor/liburing/SECURITY.md +6 -0
- data/vendor/liburing/configure +624 -0
- data/vendor/liburing/debian/README.Debian +7 -0
- data/vendor/liburing/debian/changelog +38 -0
- data/vendor/liburing/debian/control +39 -0
- data/vendor/liburing/debian/copyright +49 -0
- data/vendor/liburing/debian/liburing-dev.install +4 -0
- data/vendor/liburing/debian/liburing-dev.manpages +5 -0
- data/vendor/liburing/debian/liburing2.install +1 -0
- data/vendor/liburing/debian/liburing2.symbols +56 -0
- data/vendor/liburing/debian/patches/series +1 -0
- data/vendor/liburing/debian/rules +29 -0
- data/vendor/liburing/debian/source/format +1 -0
- data/vendor/liburing/debian/source/local-options +2 -0
- data/vendor/liburing/debian/source/options +1 -0
- data/vendor/liburing/debian/watch +3 -0
- data/vendor/liburing/examples/Makefile +53 -0
- data/vendor/liburing/examples/helpers.c +62 -0
- data/vendor/liburing/examples/helpers.h +7 -0
- data/vendor/liburing/examples/io_uring-close-test.c +123 -0
- data/vendor/liburing/examples/io_uring-cp.c +282 -0
- data/vendor/liburing/examples/io_uring-test.c +112 -0
- data/vendor/liburing/examples/io_uring-udp.c +403 -0
- data/vendor/liburing/examples/link-cp.c +193 -0
- data/vendor/liburing/examples/napi-busy-poll-client.c +509 -0
- data/vendor/liburing/examples/napi-busy-poll-server.c +450 -0
- data/vendor/liburing/examples/poll-bench.c +101 -0
- data/vendor/liburing/examples/proxy.c +2461 -0
- data/vendor/liburing/examples/proxy.h +102 -0
- data/vendor/liburing/examples/rsrc-update-bench.c +100 -0
- data/vendor/liburing/examples/send-zerocopy.c +658 -0
- data/vendor/liburing/examples/ucontext-cp.c +258 -0
- data/vendor/liburing/liburing-ffi.pc.in +12 -0
- data/vendor/liburing/liburing.pc.in +12 -0
- data/vendor/liburing/liburing.spec +66 -0
- data/vendor/liburing/make-debs.sh +55 -0
- data/vendor/liburing/src/Makefile +129 -0
- data/vendor/liburing/src/arch/aarch64/lib.h +47 -0
- data/vendor/liburing/src/arch/aarch64/syscall.h +91 -0
- data/vendor/liburing/src/arch/generic/lib.h +17 -0
- data/vendor/liburing/src/arch/generic/syscall.h +100 -0
- data/vendor/liburing/src/arch/riscv64/lib.h +48 -0
- data/vendor/liburing/src/arch/riscv64/syscall.h +100 -0
- data/vendor/liburing/src/arch/syscall-defs.h +94 -0
- data/vendor/liburing/src/arch/x86/lib.h +11 -0
- data/vendor/liburing/src/arch/x86/syscall.h +296 -0
- data/vendor/liburing/src/ffi.c +15 -0
- data/vendor/liburing/src/include/liburing/barrier.h +81 -0
- data/vendor/liburing/src/include/liburing/io_uring.h +818 -0
- data/vendor/liburing/src/include/liburing.h +1602 -0
- data/vendor/liburing/src/int_flags.h +11 -0
- data/vendor/liburing/src/lib.h +52 -0
- data/vendor/liburing/src/liburing-ffi.map +211 -0
- data/vendor/liburing/src/liburing.map +104 -0
- data/vendor/liburing/src/nolibc.c +55 -0
- data/vendor/liburing/src/queue.c +468 -0
- data/vendor/liburing/src/register.c +374 -0
- data/vendor/liburing/src/setup.c +689 -0
- data/vendor/liburing/src/setup.h +9 -0
- data/vendor/liburing/src/syscall.c +29 -0
- data/vendor/liburing/src/syscall.h +53 -0
- data/vendor/liburing/src/version.c +21 -0
- data/vendor/liburing/test/232c93d07b74.c +305 -0
- data/vendor/liburing/test/35fa71a030ca.c +329 -0
- data/vendor/liburing/test/500f9fbadef8.c +91 -0
- data/vendor/liburing/test/7ad0e4b2f83c.c +94 -0
- data/vendor/liburing/test/8a9973408177.c +107 -0
- data/vendor/liburing/test/917257daa0fe.c +54 -0
- data/vendor/liburing/test/Makefile +297 -0
- data/vendor/liburing/test/a0908ae19763.c +59 -0
- data/vendor/liburing/test/a4c0b3decb33.c +181 -0
- data/vendor/liburing/test/accept-link.c +255 -0
- data/vendor/liburing/test/accept-non-empty.c +256 -0
- data/vendor/liburing/test/accept-reuse.c +163 -0
- data/vendor/liburing/test/accept-test.c +83 -0
- data/vendor/liburing/test/accept.c +919 -0
- data/vendor/liburing/test/across-fork.c +284 -0
- data/vendor/liburing/test/b19062a56726.c +54 -0
- data/vendor/liburing/test/b5837bd5311d.c +78 -0
- data/vendor/liburing/test/bind-listen.c +408 -0
- data/vendor/liburing/test/buf-ring-nommap.c +123 -0
- data/vendor/liburing/test/buf-ring-put.c +83 -0
- data/vendor/liburing/test/buf-ring.c +473 -0
- data/vendor/liburing/test/ce593a6c480a.c +139 -0
- data/vendor/liburing/test/close-opath.c +123 -0
- data/vendor/liburing/test/config +14 -0
- data/vendor/liburing/test/connect-rep.c +204 -0
- data/vendor/liburing/test/connect.c +442 -0
- data/vendor/liburing/test/coredump.c +60 -0
- data/vendor/liburing/test/cq-full.c +97 -0
- data/vendor/liburing/test/cq-overflow.c +530 -0
- data/vendor/liburing/test/cq-peek-batch.c +103 -0
- data/vendor/liburing/test/cq-ready.c +95 -0
- data/vendor/liburing/test/cq-size.c +65 -0
- data/vendor/liburing/test/d4ae271dfaae.c +96 -0
- data/vendor/liburing/test/d77a67ed5f27.c +65 -0
- data/vendor/liburing/test/defer-taskrun.c +391 -0
- data/vendor/liburing/test/defer-tw-timeout.c +173 -0
- data/vendor/liburing/test/defer.c +319 -0
- data/vendor/liburing/test/double-poll-crash.c +195 -0
- data/vendor/liburing/test/drop-submit.c +94 -0
- data/vendor/liburing/test/eeed8b54e0df.c +120 -0
- data/vendor/liburing/test/empty-eownerdead.c +45 -0
- data/vendor/liburing/test/eploop.c +74 -0
- data/vendor/liburing/test/eventfd-disable.c +179 -0
- data/vendor/liburing/test/eventfd-reg.c +77 -0
- data/vendor/liburing/test/eventfd-ring.c +98 -0
- data/vendor/liburing/test/eventfd.c +113 -0
- data/vendor/liburing/test/evloop.c +73 -0
- data/vendor/liburing/test/exec-target.c +6 -0
- data/vendor/liburing/test/exit-no-cleanup.c +117 -0
- data/vendor/liburing/test/fadvise.c +202 -0
- data/vendor/liburing/test/fallocate.c +265 -0
- data/vendor/liburing/test/fc2a85cb02ef.c +132 -0
- data/vendor/liburing/test/fd-install.c +500 -0
- data/vendor/liburing/test/fd-pass.c +237 -0
- data/vendor/liburing/test/fdinfo.c +419 -0
- data/vendor/liburing/test/file-register.c +1189 -0
- data/vendor/liburing/test/file-update.c +231 -0
- data/vendor/liburing/test/file-verify.c +654 -0
- data/vendor/liburing/test/files-exit-hang-poll.c +114 -0
- data/vendor/liburing/test/files-exit-hang-timeout.c +137 -0
- data/vendor/liburing/test/fixed-buf-iter.c +115 -0
- data/vendor/liburing/test/fixed-buf-merge.c +101 -0
- data/vendor/liburing/test/fixed-hugepage.c +411 -0
- data/vendor/liburing/test/fixed-link.c +90 -0
- data/vendor/liburing/test/fixed-reuse.c +160 -0
- data/vendor/liburing/test/fpos.c +255 -0
- data/vendor/liburing/test/fsnotify.c +118 -0
- data/vendor/liburing/test/fsync.c +224 -0
- data/vendor/liburing/test/futex.c +571 -0
- data/vendor/liburing/test/hardlink.c +170 -0
- data/vendor/liburing/test/helpers.c +318 -0
- data/vendor/liburing/test/helpers.h +108 -0
- data/vendor/liburing/test/ignore-single-mmap.c +48 -0
- data/vendor/liburing/test/init-mem.c +164 -0
- data/vendor/liburing/test/io-cancel.c +561 -0
- data/vendor/liburing/test/io_uring_enter.c +264 -0
- data/vendor/liburing/test/io_uring_passthrough.c +482 -0
- data/vendor/liburing/test/io_uring_register.c +503 -0
- data/vendor/liburing/test/io_uring_setup.c +110 -0
- data/vendor/liburing/test/iopoll-leak.c +85 -0
- data/vendor/liburing/test/iopoll-overflow.c +118 -0
- data/vendor/liburing/test/iopoll.c +465 -0
- data/vendor/liburing/test/lfs-openat-write.c +119 -0
- data/vendor/liburing/test/lfs-openat.c +273 -0
- data/vendor/liburing/test/link-timeout.c +1108 -0
- data/vendor/liburing/test/link.c +497 -0
- data/vendor/liburing/test/link_drain.c +255 -0
- data/vendor/liburing/test/madvise.c +195 -0
- data/vendor/liburing/test/min-timeout-wait.c +354 -0
- data/vendor/liburing/test/min-timeout.c +233 -0
- data/vendor/liburing/test/mkdir.c +112 -0
- data/vendor/liburing/test/msg-ring-fd.c +331 -0
- data/vendor/liburing/test/msg-ring-flags.c +212 -0
- data/vendor/liburing/test/msg-ring-overflow.c +159 -0
- data/vendor/liburing/test/msg-ring.c +467 -0
- data/vendor/liburing/test/multicqes_drain.c +429 -0
- data/vendor/liburing/test/napi-test.c +215 -0
- data/vendor/liburing/test/napi-test.sh +48 -0
- data/vendor/liburing/test/no-mmap-inval.c +42 -0
- data/vendor/liburing/test/nolibc.c +62 -0
- data/vendor/liburing/test/nop-all-sizes.c +99 -0
- data/vendor/liburing/test/nop.c +177 -0
- data/vendor/liburing/test/nvme.h +169 -0
- data/vendor/liburing/test/ooo-file-unreg.c +82 -0
- data/vendor/liburing/test/open-close.c +261 -0
- data/vendor/liburing/test/open-direct-link.c +188 -0
- data/vendor/liburing/test/open-direct-pick.c +180 -0
- data/vendor/liburing/test/openat2.c +312 -0
- data/vendor/liburing/test/personality.c +204 -0
- data/vendor/liburing/test/pipe-bug.c +95 -0
- data/vendor/liburing/test/pipe-eof.c +83 -0
- data/vendor/liburing/test/pipe-reuse.c +105 -0
- data/vendor/liburing/test/poll-cancel-all.c +496 -0
- data/vendor/liburing/test/poll-cancel-ton.c +135 -0
- data/vendor/liburing/test/poll-cancel.c +228 -0
- data/vendor/liburing/test/poll-link.c +221 -0
- data/vendor/liburing/test/poll-many.c +230 -0
- data/vendor/liburing/test/poll-mshot-overflow.c +265 -0
- data/vendor/liburing/test/poll-mshot-update.c +323 -0
- data/vendor/liburing/test/poll-race-mshot.c +276 -0
- data/vendor/liburing/test/poll-race.c +105 -0
- data/vendor/liburing/test/poll-ring.c +48 -0
- data/vendor/liburing/test/poll-v-poll.c +353 -0
- data/vendor/liburing/test/poll.c +327 -0
- data/vendor/liburing/test/probe.c +135 -0
- data/vendor/liburing/test/read-before-exit.c +129 -0
- data/vendor/liburing/test/read-mshot-empty.c +153 -0
- data/vendor/liburing/test/read-mshot.c +404 -0
- data/vendor/liburing/test/read-write.c +1013 -0
- data/vendor/liburing/test/recv-msgall-stream.c +398 -0
- data/vendor/liburing/test/recv-msgall.c +263 -0
- data/vendor/liburing/test/recv-multishot.c +602 -0
- data/vendor/liburing/test/recvsend_bundle.c +691 -0
- data/vendor/liburing/test/reg-fd-only.c +131 -0
- data/vendor/liburing/test/reg-hint.c +56 -0
- data/vendor/liburing/test/reg-reg-ring.c +90 -0
- data/vendor/liburing/test/regbuf-merge.c +91 -0
- data/vendor/liburing/test/register-restrictions.c +633 -0
- data/vendor/liburing/test/rename.c +132 -0
- data/vendor/liburing/test/ring-leak.c +283 -0
- data/vendor/liburing/test/ring-leak2.c +249 -0
- data/vendor/liburing/test/ringbuf-read.c +196 -0
- data/vendor/liburing/test/ringbuf-status.c +242 -0
- data/vendor/liburing/test/rsrc_tags.c +461 -0
- data/vendor/liburing/test/runtests-loop.sh +16 -0
- data/vendor/liburing/test/runtests-quiet.sh +11 -0
- data/vendor/liburing/test/runtests.sh +168 -0
- data/vendor/liburing/test/rw_merge_test.c +98 -0
- data/vendor/liburing/test/self.c +91 -0
- data/vendor/liburing/test/send-zerocopy.c +971 -0
- data/vendor/liburing/test/send_recv.c +412 -0
- data/vendor/liburing/test/send_recvmsg.c +444 -0
- data/vendor/liburing/test/shared-wq.c +84 -0
- data/vendor/liburing/test/short-read.c +75 -0
- data/vendor/liburing/test/shutdown.c +165 -0
- data/vendor/liburing/test/sigfd-deadlock.c +88 -0
- data/vendor/liburing/test/single-issuer.c +169 -0
- data/vendor/liburing/test/skip-cqe.c +428 -0
- data/vendor/liburing/test/socket-getsetsock-cmd.c +346 -0
- data/vendor/liburing/test/socket-io-cmd.c +237 -0
- data/vendor/liburing/test/socket-rw-eagain.c +149 -0
- data/vendor/liburing/test/socket-rw-offset.c +149 -0
- data/vendor/liburing/test/socket-rw.c +137 -0
- data/vendor/liburing/test/socket.c +408 -0
- data/vendor/liburing/test/splice.c +512 -0
- data/vendor/liburing/test/sq-full-cpp.cc +45 -0
- data/vendor/liburing/test/sq-full.c +45 -0
- data/vendor/liburing/test/sq-poll-dup.c +211 -0
- data/vendor/liburing/test/sq-poll-kthread.c +169 -0
- data/vendor/liburing/test/sq-poll-share.c +138 -0
- data/vendor/liburing/test/sq-space_left.c +159 -0
- data/vendor/liburing/test/sqpoll-disable-exit.c +196 -0
- data/vendor/liburing/test/sqpoll-exec.c +132 -0
- data/vendor/liburing/test/sqpoll-exit-hang.c +78 -0
- data/vendor/liburing/test/sqpoll-sleep.c +69 -0
- data/vendor/liburing/test/statx.c +172 -0
- data/vendor/liburing/test/stdout.c +232 -0
- data/vendor/liburing/test/submit-and-wait.c +108 -0
- data/vendor/liburing/test/submit-link-fail.c +156 -0
- data/vendor/liburing/test/submit-reuse.c +237 -0
- data/vendor/liburing/test/symlink.c +117 -0
- data/vendor/liburing/test/sync-cancel.c +235 -0
- data/vendor/liburing/test/teardowns.c +58 -0
- data/vendor/liburing/test/test.h +36 -0
- data/vendor/liburing/test/thread-exit.c +143 -0
- data/vendor/liburing/test/timeout-new.c +256 -0
- data/vendor/liburing/test/timeout.c +1798 -0
- data/vendor/liburing/test/truncate.c +186 -0
- data/vendor/liburing/test/tty-write-dpoll.c +60 -0
- data/vendor/liburing/test/unlink.c +112 -0
- data/vendor/liburing/test/version.c +25 -0
- data/vendor/liburing/test/wait-timeout.c +287 -0
- data/vendor/liburing/test/waitid.c +373 -0
- data/vendor/liburing/test/wakeup-hang.c +162 -0
- data/vendor/liburing/test/wq-aff.c +146 -0
- data/vendor/liburing/test/xattr.c +442 -0
- metadata +412 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
/*
|
|
3
|
+
* Description: Helpers for tests.
|
|
4
|
+
*/
|
|
5
|
+
#include <stdlib.h>
|
|
6
|
+
#include <assert.h>
|
|
7
|
+
#include <string.h>
|
|
8
|
+
#include <stdio.h>
|
|
9
|
+
#include <fcntl.h>
|
|
10
|
+
#include <unistd.h>
|
|
11
|
+
#include <stdarg.h>
|
|
12
|
+
#include <sys/types.h>
|
|
13
|
+
|
|
14
|
+
#include <arpa/inet.h>
|
|
15
|
+
#include <netinet/ip.h>
|
|
16
|
+
#include <netinet/tcp.h>
|
|
17
|
+
|
|
18
|
+
#include "helpers.h"
|
|
19
|
+
#include "liburing.h"
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
* Helper for allocating memory in tests.
|
|
23
|
+
*/
|
|
24
|
+
void *t_malloc(size_t size)
|
|
25
|
+
{
|
|
26
|
+
void *ret;
|
|
27
|
+
ret = malloc(size);
|
|
28
|
+
assert(ret);
|
|
29
|
+
return ret;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
* Helper for binding socket to an ephemeral port.
|
|
34
|
+
* The port number to be bound is returned in @addr->sin_port.
|
|
35
|
+
*/
|
|
36
|
+
int t_bind_ephemeral_port(int fd, struct sockaddr_in *addr)
|
|
37
|
+
{
|
|
38
|
+
socklen_t addrlen;
|
|
39
|
+
int ret;
|
|
40
|
+
|
|
41
|
+
addr->sin_port = 0;
|
|
42
|
+
if (bind(fd, (struct sockaddr *)addr, sizeof(*addr)))
|
|
43
|
+
return -errno;
|
|
44
|
+
|
|
45
|
+
addrlen = sizeof(*addr);
|
|
46
|
+
ret = getsockname(fd, (struct sockaddr *)addr, &addrlen);
|
|
47
|
+
assert(!ret);
|
|
48
|
+
assert(addr->sin_port != 0);
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/*
|
|
53
|
+
* Helper for allocating size bytes aligned on a boundary.
|
|
54
|
+
*/
|
|
55
|
+
void t_posix_memalign(void **memptr, size_t alignment, size_t size)
|
|
56
|
+
{
|
|
57
|
+
int ret;
|
|
58
|
+
ret = posix_memalign(memptr, alignment, size);
|
|
59
|
+
assert(!ret);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/*
|
|
63
|
+
* Helper for allocating space for an array of nmemb elements
|
|
64
|
+
* with size bytes for each element.
|
|
65
|
+
*/
|
|
66
|
+
void *t_calloc(size_t nmemb, size_t size)
|
|
67
|
+
{
|
|
68
|
+
void *ret;
|
|
69
|
+
ret = calloc(nmemb, size);
|
|
70
|
+
assert(ret);
|
|
71
|
+
return ret;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/*
|
|
75
|
+
* Helper for creating file and write @size byte buf with 0xaa value in the file.
|
|
76
|
+
*/
|
|
77
|
+
static void __t_create_file(const char *file, size_t size, char pattern)
|
|
78
|
+
{
|
|
79
|
+
ssize_t ret;
|
|
80
|
+
char *buf;
|
|
81
|
+
int fd;
|
|
82
|
+
|
|
83
|
+
buf = t_malloc(size);
|
|
84
|
+
memset(buf, pattern, size);
|
|
85
|
+
|
|
86
|
+
fd = open(file, O_WRONLY | O_CREAT, 0644);
|
|
87
|
+
assert(fd >= 0);
|
|
88
|
+
|
|
89
|
+
ret = write(fd, buf, size);
|
|
90
|
+
fsync(fd);
|
|
91
|
+
close(fd);
|
|
92
|
+
free(buf);
|
|
93
|
+
assert(ret == size);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
void t_create_file(const char *file, size_t size)
|
|
97
|
+
{
|
|
98
|
+
__t_create_file(file, size, 0xaa);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
void t_create_file_pattern(const char *file, size_t size, char pattern)
|
|
102
|
+
{
|
|
103
|
+
__t_create_file(file, size, pattern);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/*
|
|
107
|
+
* Helper for creating @buf_num number of iovec
|
|
108
|
+
* with @buf_size bytes buffer of each iovec.
|
|
109
|
+
*/
|
|
110
|
+
struct iovec *t_create_buffers(size_t buf_num, size_t buf_size)
|
|
111
|
+
{
|
|
112
|
+
struct iovec *vecs;
|
|
113
|
+
int i;
|
|
114
|
+
|
|
115
|
+
vecs = t_malloc(buf_num * sizeof(struct iovec));
|
|
116
|
+
for (i = 0; i < buf_num; i++) {
|
|
117
|
+
t_posix_memalign(&vecs[i].iov_base, buf_size, buf_size);
|
|
118
|
+
vecs[i].iov_len = buf_size;
|
|
119
|
+
}
|
|
120
|
+
return vecs;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/*
|
|
124
|
+
* Helper for setting up an io_uring instance, skipping if the given user isn't
|
|
125
|
+
* allowed to.
|
|
126
|
+
*/
|
|
127
|
+
enum t_setup_ret t_create_ring_params(int depth, struct io_uring *ring,
|
|
128
|
+
struct io_uring_params *p)
|
|
129
|
+
{
|
|
130
|
+
int ret;
|
|
131
|
+
|
|
132
|
+
ret = io_uring_queue_init_params(depth, ring, p);
|
|
133
|
+
if (!ret)
|
|
134
|
+
return T_SETUP_OK;
|
|
135
|
+
if ((p->flags & IORING_SETUP_SQPOLL) && ret == -EPERM && geteuid()) {
|
|
136
|
+
fprintf(stdout, "SQPOLL skipped for regular user\n");
|
|
137
|
+
return T_SETUP_SKIP;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (ret != -EINVAL)
|
|
141
|
+
fprintf(stderr, "queue_init: %s\n", strerror(-ret));
|
|
142
|
+
return ret;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
enum t_setup_ret t_create_ring(int depth, struct io_uring *ring,
|
|
146
|
+
unsigned int flags)
|
|
147
|
+
{
|
|
148
|
+
struct io_uring_params p = { };
|
|
149
|
+
|
|
150
|
+
p.flags = flags;
|
|
151
|
+
return t_create_ring_params(depth, ring, &p);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
enum t_setup_ret t_register_buffers(struct io_uring *ring,
|
|
155
|
+
const struct iovec *iovecs,
|
|
156
|
+
unsigned nr_iovecs)
|
|
157
|
+
{
|
|
158
|
+
int ret;
|
|
159
|
+
|
|
160
|
+
ret = io_uring_register_buffers(ring, iovecs, nr_iovecs);
|
|
161
|
+
if (!ret)
|
|
162
|
+
return T_SETUP_OK;
|
|
163
|
+
|
|
164
|
+
if ((ret == -EPERM || ret == -ENOMEM) && geteuid()) {
|
|
165
|
+
fprintf(stdout, "too large non-root buffer registration, skip\n");
|
|
166
|
+
return T_SETUP_SKIP;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
fprintf(stderr, "buffer register failed: %s\n", strerror(-ret));
|
|
170
|
+
return ret;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
int t_create_socket_pair(int fd[2], bool stream)
|
|
174
|
+
{
|
|
175
|
+
int ret;
|
|
176
|
+
int type = stream ? SOCK_STREAM : SOCK_DGRAM;
|
|
177
|
+
int val;
|
|
178
|
+
struct sockaddr_in serv_addr;
|
|
179
|
+
struct sockaddr *paddr;
|
|
180
|
+
socklen_t paddrlen;
|
|
181
|
+
|
|
182
|
+
type |= SOCK_CLOEXEC;
|
|
183
|
+
fd[0] = socket(AF_INET, type, 0);
|
|
184
|
+
if (fd[0] < 0)
|
|
185
|
+
return errno;
|
|
186
|
+
fd[1] = socket(AF_INET, type, 0);
|
|
187
|
+
if (fd[1] < 0) {
|
|
188
|
+
ret = errno;
|
|
189
|
+
close(fd[0]);
|
|
190
|
+
return ret;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
val = 1;
|
|
194
|
+
if (setsockopt(fd[0], SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)))
|
|
195
|
+
goto errno_cleanup;
|
|
196
|
+
|
|
197
|
+
memset(&serv_addr, 0, sizeof(serv_addr));
|
|
198
|
+
serv_addr.sin_family = AF_INET;
|
|
199
|
+
serv_addr.sin_port = 0;
|
|
200
|
+
inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr);
|
|
201
|
+
|
|
202
|
+
paddr = (struct sockaddr *)&serv_addr;
|
|
203
|
+
paddrlen = sizeof(serv_addr);
|
|
204
|
+
|
|
205
|
+
if (bind(fd[0], paddr, paddrlen)) {
|
|
206
|
+
fprintf(stderr, "bind failed\n");
|
|
207
|
+
goto errno_cleanup;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (stream && listen(fd[0], 16)) {
|
|
211
|
+
fprintf(stderr, "listen failed\n");
|
|
212
|
+
goto errno_cleanup;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (getsockname(fd[0], (struct sockaddr *)&serv_addr,
|
|
216
|
+
(socklen_t *)&paddrlen)) {
|
|
217
|
+
fprintf(stderr, "getsockname failed\n");
|
|
218
|
+
goto errno_cleanup;
|
|
219
|
+
}
|
|
220
|
+
inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr);
|
|
221
|
+
|
|
222
|
+
if (connect(fd[1], (struct sockaddr *)&serv_addr, paddrlen)) {
|
|
223
|
+
fprintf(stderr, "connect failed\n");
|
|
224
|
+
goto errno_cleanup;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (!stream) {
|
|
228
|
+
/* connect the other udp side */
|
|
229
|
+
if (getsockname(fd[1], (struct sockaddr *)&serv_addr,
|
|
230
|
+
(socklen_t *)&paddrlen)) {
|
|
231
|
+
fprintf(stderr, "getsockname failed\n");
|
|
232
|
+
goto errno_cleanup;
|
|
233
|
+
}
|
|
234
|
+
inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr);
|
|
235
|
+
|
|
236
|
+
if (connect(fd[0], (struct sockaddr *)&serv_addr, paddrlen)) {
|
|
237
|
+
fprintf(stderr, "connect failed\n");
|
|
238
|
+
goto errno_cleanup;
|
|
239
|
+
}
|
|
240
|
+
return 0;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/* for stream case we must accept and cleanup the listen socket */
|
|
244
|
+
|
|
245
|
+
ret = accept(fd[0], NULL, NULL);
|
|
246
|
+
if (ret < 0)
|
|
247
|
+
goto errno_cleanup;
|
|
248
|
+
|
|
249
|
+
close(fd[0]);
|
|
250
|
+
fd[0] = ret;
|
|
251
|
+
|
|
252
|
+
return 0;
|
|
253
|
+
|
|
254
|
+
errno_cleanup:
|
|
255
|
+
ret = errno;
|
|
256
|
+
close(fd[0]);
|
|
257
|
+
close(fd[1]);
|
|
258
|
+
return ret;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
bool t_probe_defer_taskrun(void)
|
|
262
|
+
{
|
|
263
|
+
struct io_uring ring;
|
|
264
|
+
int ret;
|
|
265
|
+
|
|
266
|
+
ret = io_uring_queue_init(1, &ring, IORING_SETUP_SINGLE_ISSUER |
|
|
267
|
+
IORING_SETUP_DEFER_TASKRUN);
|
|
268
|
+
if (ret < 0)
|
|
269
|
+
return false;
|
|
270
|
+
io_uring_queue_exit(&ring);
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/*
|
|
275
|
+
* Sync internal state with kernel ring state on the SQ side. Returns the
|
|
276
|
+
* number of pending items in the SQ ring, for the shared ring.
|
|
277
|
+
*/
|
|
278
|
+
unsigned __io_uring_flush_sq(struct io_uring *ring)
|
|
279
|
+
{
|
|
280
|
+
struct io_uring_sq *sq = &ring->sq;
|
|
281
|
+
unsigned tail = sq->sqe_tail;
|
|
282
|
+
|
|
283
|
+
if (sq->sqe_head != tail) {
|
|
284
|
+
sq->sqe_head = tail;
|
|
285
|
+
/*
|
|
286
|
+
* Ensure kernel sees the SQE updates before the tail update.
|
|
287
|
+
*/
|
|
288
|
+
if (!(ring->flags & IORING_SETUP_SQPOLL))
|
|
289
|
+
*sq->ktail = tail;
|
|
290
|
+
else
|
|
291
|
+
io_uring_smp_store_release(sq->ktail, tail);
|
|
292
|
+
}
|
|
293
|
+
/*
|
|
294
|
+
* This load needs to be atomic, since sq->khead is written concurrently
|
|
295
|
+
* by the kernel, but it doesn't need to be load_acquire, since the
|
|
296
|
+
* kernel doesn't store to the submission queue; it advances khead just
|
|
297
|
+
* to indicate that it's finished reading the submission queue entries
|
|
298
|
+
* so they're available for us to write to.
|
|
299
|
+
*/
|
|
300
|
+
return tail - IO_URING_READ_ONCE(*sq->khead);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/*
|
|
304
|
+
* Implementation of error(3), prints an error message and exits.
|
|
305
|
+
*/
|
|
306
|
+
void t_error(int status, int errnum, const char *format, ...)
|
|
307
|
+
{
|
|
308
|
+
va_list args;
|
|
309
|
+
va_start(args, format);
|
|
310
|
+
|
|
311
|
+
vfprintf(stderr, format, args);
|
|
312
|
+
if (errnum)
|
|
313
|
+
fprintf(stderr, ": %s", strerror(errnum));
|
|
314
|
+
|
|
315
|
+
fprintf(stderr, "\n");
|
|
316
|
+
va_end(args);
|
|
317
|
+
exit(status);
|
|
318
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
/*
|
|
3
|
+
* Description: Helpers for tests.
|
|
4
|
+
*/
|
|
5
|
+
#ifndef LIBURING_HELPERS_H
|
|
6
|
+
#define LIBURING_HELPERS_H
|
|
7
|
+
|
|
8
|
+
#ifdef __cplusplus
|
|
9
|
+
extern "C" {
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
#include "liburing.h"
|
|
13
|
+
#include "../src/setup.h"
|
|
14
|
+
#include <arpa/inet.h>
|
|
15
|
+
|
|
16
|
+
enum t_setup_ret {
|
|
17
|
+
T_SETUP_OK = 0,
|
|
18
|
+
T_SETUP_SKIP,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
enum t_test_result {
|
|
22
|
+
T_EXIT_PASS = 0,
|
|
23
|
+
T_EXIT_FAIL = 1,
|
|
24
|
+
T_EXIT_SKIP = 77,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
* Helper for binding socket to an ephemeral port.
|
|
29
|
+
* The port number to be bound is returned in @addr->sin_port.
|
|
30
|
+
*/
|
|
31
|
+
int t_bind_ephemeral_port(int fd, struct sockaddr_in *addr);
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* Helper for allocating memory in tests.
|
|
36
|
+
*/
|
|
37
|
+
void *t_malloc(size_t size);
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/*
|
|
41
|
+
* Helper for allocating size bytes aligned on a boundary.
|
|
42
|
+
*/
|
|
43
|
+
void t_posix_memalign(void **memptr, size_t alignment, size_t size);
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
/*
|
|
47
|
+
* Helper for allocating space for an array of nmemb elements
|
|
48
|
+
* with size bytes for each element.
|
|
49
|
+
*/
|
|
50
|
+
void *t_calloc(size_t nmemb, size_t size);
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
/*
|
|
54
|
+
* Helper for creating file and write @size byte buf with 0xaa value in the file.
|
|
55
|
+
*/
|
|
56
|
+
void t_create_file(const char *file, size_t size);
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
* Helper for creating file and write @size byte buf with @pattern value in
|
|
60
|
+
* the file.
|
|
61
|
+
*/
|
|
62
|
+
void t_create_file_pattern(const char *file, size_t size, char pattern);
|
|
63
|
+
|
|
64
|
+
/*
|
|
65
|
+
* Helper for creating @buf_num number of iovec
|
|
66
|
+
* with @buf_size bytes buffer of each iovec.
|
|
67
|
+
*/
|
|
68
|
+
struct iovec *t_create_buffers(size_t buf_num, size_t buf_size);
|
|
69
|
+
|
|
70
|
+
/*
|
|
71
|
+
* Helper for creating connected socket pairs
|
|
72
|
+
*/
|
|
73
|
+
int t_create_socket_pair(int fd[2], bool stream);
|
|
74
|
+
|
|
75
|
+
/*
|
|
76
|
+
* Helper for setting up a ring and checking for user privs
|
|
77
|
+
*/
|
|
78
|
+
enum t_setup_ret t_create_ring_params(int depth, struct io_uring *ring,
|
|
79
|
+
struct io_uring_params *p);
|
|
80
|
+
enum t_setup_ret t_create_ring(int depth, struct io_uring *ring,
|
|
81
|
+
unsigned int flags);
|
|
82
|
+
|
|
83
|
+
enum t_setup_ret t_register_buffers(struct io_uring *ring,
|
|
84
|
+
const struct iovec *iovecs,
|
|
85
|
+
unsigned nr_iovecs);
|
|
86
|
+
|
|
87
|
+
bool t_probe_defer_taskrun(void);
|
|
88
|
+
|
|
89
|
+
unsigned __io_uring_flush_sq(struct io_uring *ring);
|
|
90
|
+
|
|
91
|
+
static inline int t_io_uring_init_sqarray(unsigned entries, struct io_uring *ring,
|
|
92
|
+
struct io_uring_params *p)
|
|
93
|
+
{
|
|
94
|
+
int ret;
|
|
95
|
+
|
|
96
|
+
ret = __io_uring_queue_init_params(entries, ring, p, NULL, 0);
|
|
97
|
+
return ret >= 0 ? 0 : ret;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
|
101
|
+
|
|
102
|
+
void t_error(int status, int errnum, const char *format, ...);
|
|
103
|
+
|
|
104
|
+
#ifdef __cplusplus
|
|
105
|
+
}
|
|
106
|
+
#endif
|
|
107
|
+
|
|
108
|
+
#endif
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
/*
|
|
3
|
+
* 6.10-rc merge window had a bug where the rewritten mmap support caused
|
|
4
|
+
* rings allocated with > 1 page, but asking for smaller mappings, would
|
|
5
|
+
* cause -EFAULT to be returned rather than a successful map. This hit
|
|
6
|
+
* applications either using an ancient liburing with IORING_FEAT_SINGLE_MMAP
|
|
7
|
+
* support, or application just ignoring that feature flag and still doing
|
|
8
|
+
* 3 mmap operations to map the ring.
|
|
9
|
+
*/
|
|
10
|
+
#include <stdio.h>
|
|
11
|
+
#include <stdlib.h>
|
|
12
|
+
#include <unistd.h>
|
|
13
|
+
|
|
14
|
+
#include "../src/syscall.h"
|
|
15
|
+
#include "liburing.h"
|
|
16
|
+
#include "helpers.h"
|
|
17
|
+
|
|
18
|
+
#define ENTRIES 128
|
|
19
|
+
|
|
20
|
+
int main(int argc, char *argv[])
|
|
21
|
+
{
|
|
22
|
+
struct io_uring_params p = { };
|
|
23
|
+
void *ptr;
|
|
24
|
+
int fd;
|
|
25
|
+
|
|
26
|
+
if (argc > 1)
|
|
27
|
+
return T_EXIT_SKIP;
|
|
28
|
+
|
|
29
|
+
fd = __sys_io_uring_setup(ENTRIES, &p);
|
|
30
|
+
if (fd < 0)
|
|
31
|
+
return T_EXIT_SKIP;
|
|
32
|
+
|
|
33
|
+
if (!(p.features & IORING_FEAT_SINGLE_MMAP)) {
|
|
34
|
+
close(fd);
|
|
35
|
+
return T_EXIT_SKIP;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
ptr = __sys_mmap(0, ENTRIES * sizeof(unsigned), PROT_READ | PROT_WRITE,
|
|
39
|
+
MAP_SHARED | MAP_POPULATE, fd,
|
|
40
|
+
IORING_OFF_SQ_RING);
|
|
41
|
+
if (!IS_ERR(ptr)) {
|
|
42
|
+
close(fd);
|
|
43
|
+
return T_EXIT_PASS;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
fprintf(stderr, "ring sqe array mmap: %d\n", PTR_ERR(ptr));
|
|
47
|
+
return T_EXIT_FAIL;
|
|
48
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
/*
|
|
3
|
+
* Description: Check that io_uring_queue_init_mem() doesn't underestimate
|
|
4
|
+
* the memory required for various size rings.
|
|
5
|
+
*/
|
|
6
|
+
#include <stdio.h>
|
|
7
|
+
#include <unistd.h>
|
|
8
|
+
#include <errno.h>
|
|
9
|
+
#include <sys/mman.h>
|
|
10
|
+
#include <linux/mman.h>
|
|
11
|
+
#include <stdlib.h>
|
|
12
|
+
#include <string.h>
|
|
13
|
+
#include <netinet/udp.h>
|
|
14
|
+
#include <arpa/inet.h>
|
|
15
|
+
#include <net/if.h>
|
|
16
|
+
#include <error.h>
|
|
17
|
+
|
|
18
|
+
#include "liburing.h"
|
|
19
|
+
#include "helpers.h"
|
|
20
|
+
|
|
21
|
+
#define PRE_RED 0x5aa55aa55aa55aa5ULL
|
|
22
|
+
#define POST_RED 0xa55aa55aa55aa55aULL
|
|
23
|
+
|
|
24
|
+
struct ctx {
|
|
25
|
+
struct io_uring ring;
|
|
26
|
+
void *ring_mem;
|
|
27
|
+
void *mem;
|
|
28
|
+
unsigned long long *pre;
|
|
29
|
+
unsigned long long *post;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
struct q_entries {
|
|
33
|
+
unsigned int sqes;
|
|
34
|
+
unsigned int cqes;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
static int setup_ctx(struct ctx *ctx, struct q_entries *q)
|
|
38
|
+
{
|
|
39
|
+
struct io_uring_params p = { };
|
|
40
|
+
int ret;
|
|
41
|
+
|
|
42
|
+
if (posix_memalign(&ctx->mem, 4096, 2*1024*1024))
|
|
43
|
+
return T_EXIT_FAIL;
|
|
44
|
+
|
|
45
|
+
ctx->pre = ctx->mem + 4096 - sizeof(unsigned long long);
|
|
46
|
+
*ctx->pre = PRE_RED;
|
|
47
|
+
|
|
48
|
+
ctx->ring_mem = ctx->mem + 4096;
|
|
49
|
+
p.flags |= IORING_SETUP_CQSIZE | IORING_SETUP_NO_SQARRAY;
|
|
50
|
+
p.sq_entries = q->sqes;
|
|
51
|
+
p.cq_entries = q->cqes;
|
|
52
|
+
|
|
53
|
+
ret = io_uring_queue_init_mem(q->sqes, &ctx->ring, &p,
|
|
54
|
+
ctx->ring_mem, 2*1024*1024);
|
|
55
|
+
|
|
56
|
+
if (ret < 0) {
|
|
57
|
+
if (ret == -EINVAL)
|
|
58
|
+
return T_EXIT_SKIP;
|
|
59
|
+
fprintf(stderr, "queue init: %d\n", ret);
|
|
60
|
+
return T_EXIT_FAIL;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
ctx->post = ctx->ring_mem + ret;
|
|
64
|
+
*ctx->post = POST_RED;
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static void clean_ctx(struct ctx *ctx)
|
|
69
|
+
{
|
|
70
|
+
io_uring_queue_exit(&ctx->ring);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static int check_red(struct ctx *ctx, unsigned long i)
|
|
74
|
+
{
|
|
75
|
+
int fail = 0;
|
|
76
|
+
|
|
77
|
+
if (*ctx->pre != PRE_RED) {
|
|
78
|
+
printf("pre redzone=%llx at i=%lu\n", *ctx->pre, i);
|
|
79
|
+
fail = 1;
|
|
80
|
+
}
|
|
81
|
+
if (*ctx->post != POST_RED) {
|
|
82
|
+
printf("post redzone=%llx at i=%lu\n", *ctx->post, i);
|
|
83
|
+
fail = 1;
|
|
84
|
+
}
|
|
85
|
+
return fail;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static int test(struct q_entries *q)
|
|
89
|
+
{
|
|
90
|
+
struct io_uring_sqe *sqe;
|
|
91
|
+
struct io_uring_cqe *cqe;
|
|
92
|
+
struct ctx ctx = { };
|
|
93
|
+
unsigned long i, ud;
|
|
94
|
+
int j, ret, batch;
|
|
95
|
+
|
|
96
|
+
ret = setup_ctx(&ctx, q);
|
|
97
|
+
if (ret == T_EXIT_SKIP)
|
|
98
|
+
return T_EXIT_SKIP;
|
|
99
|
+
else if (ret != T_EXIT_PASS)
|
|
100
|
+
return ret;
|
|
101
|
+
|
|
102
|
+
batch = 64;
|
|
103
|
+
if (batch > q->sqes)
|
|
104
|
+
batch = q->sqes;
|
|
105
|
+
|
|
106
|
+
i = ud = 0;
|
|
107
|
+
while (i < q->cqes * 2) {
|
|
108
|
+
if (check_red(&ctx, i))
|
|
109
|
+
return T_EXIT_FAIL;
|
|
110
|
+
for (j = 0; j < batch; j++) {
|
|
111
|
+
sqe = io_uring_get_sqe(&ctx.ring);
|
|
112
|
+
io_uring_prep_nop(sqe);
|
|
113
|
+
sqe->user_data = j + (unsigned long) i;
|
|
114
|
+
}
|
|
115
|
+
io_uring_submit(&ctx.ring);
|
|
116
|
+
for (j = 0; j < batch; j++) {
|
|
117
|
+
ret = io_uring_wait_cqe(&ctx.ring, &cqe);
|
|
118
|
+
if (ret)
|
|
119
|
+
goto err;
|
|
120
|
+
if (cqe->user_data != ud) {
|
|
121
|
+
fprintf(stderr, "ud=%lu, wanted %lu\n", (unsigned long) cqe->user_data, ud);
|
|
122
|
+
goto err;
|
|
123
|
+
}
|
|
124
|
+
ud++;
|
|
125
|
+
io_uring_cqe_seen(&ctx.ring, cqe);
|
|
126
|
+
}
|
|
127
|
+
i += batch;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
clean_ctx(&ctx);
|
|
131
|
+
return T_EXIT_PASS;
|
|
132
|
+
err:
|
|
133
|
+
clean_ctx(&ctx);
|
|
134
|
+
return T_EXIT_FAIL;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
int main(int argc, char *argv[])
|
|
138
|
+
{
|
|
139
|
+
struct q_entries q_entries[] = {
|
|
140
|
+
{ 256, 16384 },
|
|
141
|
+
{ 32, 4096 },
|
|
142
|
+
{ 128, 8192 },
|
|
143
|
+
{ 4096, 32768 },
|
|
144
|
+
{ 1, 8 },
|
|
145
|
+
{ 2, 1024 },
|
|
146
|
+
};
|
|
147
|
+
int i, ret;
|
|
148
|
+
|
|
149
|
+
if (argc > 1)
|
|
150
|
+
return T_EXIT_SKIP;
|
|
151
|
+
|
|
152
|
+
for (i = 0; i < ARRAY_SIZE(q_entries); i++) {
|
|
153
|
+
ret = test(&q_entries[i]);
|
|
154
|
+
if (ret == T_EXIT_SKIP) {
|
|
155
|
+
return T_EXIT_SKIP;
|
|
156
|
+
} else if (ret != T_EXIT_PASS) {
|
|
157
|
+
fprintf(stderr, "Failed at %d/%d\n", q_entries[i].sqes,
|
|
158
|
+
q_entries[i].cqes);
|
|
159
|
+
return T_EXIT_FAIL;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return T_EXIT_PASS;
|
|
164
|
+
}
|