polyphony 0.94 → 0.95
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/.github/workflows/test.yml +2 -2
- data/.gitignore +3 -3
- data/CHANGELOG.md +14 -0
- data/docs/api-reference/fiber.md +2 -2
- data/docs/api-reference/object.md +3 -3
- data/docs/main-concepts/exception-handling.md +2 -2
- data/ext/polyphony/backend_common.c +3 -3
- data/ext/polyphony/backend_io_uring.c +18 -16
- data/ext/polyphony/event.c +1 -1
- data/ext/polyphony/extconf.rb +5 -3
- data/ext/polyphony/fiber.c +5 -13
- data/ext/polyphony/io_extensions.c +1 -1
- data/ext/polyphony/pipe.c +1 -1
- data/ext/polyphony/polyphony.c +1 -1
- data/ext/polyphony/polyphony_ext.c +1 -1
- data/ext/polyphony/queue.c +1 -1
- data/ext/polyphony/ring_buffer.c +1 -0
- data/ext/polyphony/socket_extensions.c +1 -1
- data/ext/polyphony/thread.c +1 -1
- data/lib/polyphony/extensions/enumerator.rb +16 -0
- data/lib/polyphony/extensions/socket.rb +2 -0
- data/lib/polyphony/extensions.rb +1 -0
- data/lib/polyphony/version.rb +1 -1
- data/polyphony.gemspec +2 -2
- data/test/test_backend.rb +5 -1
- data/test/test_enumerator.rb +46 -0
- data/test/test_io.rb +241 -216
- data/test/test_socket.rb +1 -1
- data/test/test_thread_pool.rb +3 -3
- data/vendor/liburing/.github/workflows/build.yml +51 -5
- data/vendor/liburing/.github/workflows/shellcheck.yml +1 -1
- data/vendor/liburing/.gitignore +6 -123
- data/vendor/liburing/CHANGELOG +35 -0
- data/vendor/liburing/CITATION.cff +11 -0
- data/vendor/liburing/LICENSE +16 -3
- data/vendor/liburing/Makefile +3 -1
- data/vendor/liburing/Makefile.common +1 -0
- data/vendor/liburing/README +14 -2
- data/vendor/liburing/SECURITY.md +6 -0
- data/vendor/liburing/configure +16 -15
- data/vendor/liburing/examples/Makefile +4 -1
- data/vendor/liburing/examples/io_uring-udp.c +395 -0
- data/vendor/liburing/examples/poll-bench.c +101 -0
- data/vendor/liburing/examples/send-zerocopy.c +339 -0
- data/vendor/liburing/liburing.spec +1 -1
- data/vendor/liburing/man/io_uring.7 +38 -11
- data/vendor/liburing/man/io_uring_buf_ring_add.3 +53 -0
- data/vendor/liburing/man/io_uring_buf_ring_advance.3 +31 -0
- data/vendor/liburing/man/io_uring_buf_ring_cq_advance.3 +41 -0
- data/vendor/liburing/man/io_uring_buf_ring_init.3 +30 -0
- data/vendor/liburing/man/io_uring_buf_ring_mask.3 +27 -0
- data/vendor/liburing/man/io_uring_cq_advance.3 +29 -15
- data/vendor/liburing/man/io_uring_cq_has_overflow.3 +25 -0
- data/vendor/liburing/man/io_uring_cq_ready.3 +9 -8
- data/vendor/liburing/man/io_uring_cqe_get_data.3 +32 -13
- data/vendor/liburing/man/io_uring_cqe_get_data64.3 +1 -0
- data/vendor/liburing/man/io_uring_cqe_seen.3 +22 -12
- data/vendor/liburing/man/io_uring_enter.2 +249 -32
- data/vendor/liburing/man/io_uring_enter2.2 +1 -0
- data/vendor/liburing/man/io_uring_free_probe.3 +11 -8
- data/vendor/liburing/man/io_uring_get_events.3 +33 -0
- data/vendor/liburing/man/io_uring_get_probe.3 +9 -8
- data/vendor/liburing/man/io_uring_get_sqe.3 +29 -10
- data/vendor/liburing/man/io_uring_opcode_supported.3 +11 -10
- data/vendor/liburing/man/io_uring_peek_cqe.3 +38 -0
- data/vendor/liburing/man/io_uring_prep_accept.3 +197 -0
- data/vendor/liburing/man/io_uring_prep_accept_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_cancel.3 +118 -0
- data/vendor/liburing/man/io_uring_prep_cancel64.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_close.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_close_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_connect.3 +66 -0
- data/vendor/liburing/man/io_uring_prep_fadvise.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_fallocate.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_files_update.3 +92 -0
- data/vendor/liburing/man/io_uring_prep_fsync.3 +70 -0
- data/vendor/liburing/man/io_uring_prep_link.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_linkat.3 +91 -0
- data/vendor/liburing/man/io_uring_prep_madvise.3 +56 -0
- data/vendor/liburing/man/io_uring_prep_mkdir.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_mkdirat.3 +83 -0
- data/vendor/liburing/man/io_uring_prep_msg_ring.3 +39 -25
- data/vendor/liburing/man/io_uring_prep_multishot_accept.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_multishot_accept_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_nop.3 +28 -0
- data/vendor/liburing/man/io_uring_prep_openat.3 +117 -0
- data/vendor/liburing/man/io_uring_prep_openat2.3 +117 -0
- data/vendor/liburing/man/io_uring_prep_openat2_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_openat_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_poll_add.3 +72 -0
- data/vendor/liburing/man/io_uring_prep_poll_multishot.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_poll_remove.3 +55 -0
- data/vendor/liburing/man/io_uring_prep_poll_update.3 +89 -0
- data/vendor/liburing/man/io_uring_prep_provide_buffers.3 +131 -0
- data/vendor/liburing/man/io_uring_prep_read.3 +33 -14
- data/vendor/liburing/man/io_uring_prep_read_fixed.3 +39 -21
- data/vendor/liburing/man/io_uring_prep_readv.3 +49 -15
- data/vendor/liburing/man/io_uring_prep_readv2.3 +49 -17
- data/vendor/liburing/man/io_uring_prep_recv.3 +105 -0
- data/vendor/liburing/man/io_uring_prep_recv_multishot.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_recvmsg.3 +124 -0
- data/vendor/liburing/man/io_uring_prep_recvmsg_multishot.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_remove_buffers.3 +52 -0
- data/vendor/liburing/man/io_uring_prep_rename.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_renameat.3 +96 -0
- data/vendor/liburing/man/io_uring_prep_send.3 +57 -0
- data/vendor/liburing/man/io_uring_prep_send_zc.3 +64 -0
- data/vendor/liburing/man/io_uring_prep_sendmsg.3 +69 -0
- data/vendor/liburing/man/io_uring_prep_shutdown.3 +53 -0
- data/vendor/liburing/man/io_uring_prep_socket.3 +118 -0
- data/vendor/liburing/man/io_uring_prep_socket_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_socket_direct_alloc.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_splice.3 +80 -0
- data/vendor/liburing/man/io_uring_prep_statx.3 +74 -0
- data/vendor/liburing/man/io_uring_prep_symlink.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_symlinkat.3 +85 -0
- data/vendor/liburing/man/io_uring_prep_sync_file_range.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_tee.3 +74 -0
- data/vendor/liburing/man/io_uring_prep_timeout.3 +95 -0
- data/vendor/liburing/man/io_uring_prep_timeout_remove.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_timeout_update.3 +98 -0
- data/vendor/liburing/man/io_uring_prep_unlink.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_unlinkat.3 +82 -0
- data/vendor/liburing/man/io_uring_prep_write.3 +32 -15
- data/vendor/liburing/man/io_uring_prep_write_fixed.3 +39 -21
- data/vendor/liburing/man/io_uring_prep_writev.3 +50 -16
- data/vendor/liburing/man/io_uring_prep_writev2.3 +50 -17
- data/vendor/liburing/man/io_uring_queue_exit.3 +3 -4
- data/vendor/liburing/man/io_uring_queue_init.3 +58 -13
- data/vendor/liburing/man/io_uring_queue_init_params.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_cmsg_firsthdr.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_cmsg_nexthdr.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_name.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_out.3 +78 -0
- data/vendor/liburing/man/io_uring_recvmsg_payload.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_payload_length.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_validate.3 +1 -0
- data/vendor/liburing/man/io_uring_register.2 +153 -13
- data/vendor/liburing/man/io_uring_register_buf_ring.3 +140 -0
- data/vendor/liburing/man/io_uring_register_buffers.3 +32 -12
- data/vendor/liburing/man/io_uring_register_eventfd.3 +51 -0
- data/vendor/liburing/man/io_uring_register_eventfd_async.3 +1 -0
- data/vendor/liburing/man/io_uring_register_file_alloc_range.3 +52 -0
- data/vendor/liburing/man/io_uring_register_files.3 +33 -11
- data/vendor/liburing/man/io_uring_register_files_sparse.3 +1 -0
- data/vendor/liburing/man/io_uring_register_iowq_aff.3 +61 -0
- data/vendor/liburing/man/io_uring_register_iowq_max_workers.3 +71 -0
- data/vendor/liburing/man/io_uring_register_ring_fd.3 +49 -0
- data/vendor/liburing/man/io_uring_register_sync_cancel.3 +71 -0
- data/vendor/liburing/man/io_uring_setup.2 +119 -13
- data/vendor/liburing/man/io_uring_sq_ready.3 +14 -8
- data/vendor/liburing/man/io_uring_sq_space_left.3 +9 -9
- data/vendor/liburing/man/io_uring_sqe_set_data.3 +29 -11
- data/vendor/liburing/man/io_uring_sqe_set_data64.3 +1 -0
- data/vendor/liburing/man/io_uring_sqe_set_flags.3 +38 -11
- data/vendor/liburing/man/io_uring_sqring_wait.3 +13 -9
- data/vendor/liburing/man/io_uring_submit.3 +29 -12
- data/vendor/liburing/man/io_uring_submit_and_get_events.3 +31 -0
- data/vendor/liburing/man/io_uring_submit_and_wait.3 +16 -12
- data/vendor/liburing/man/io_uring_submit_and_wait_timeout.3 +30 -23
- data/vendor/liburing/man/io_uring_unregister_buf_ring.3 +30 -0
- data/vendor/liburing/man/io_uring_unregister_buffers.3 +11 -10
- data/vendor/liburing/man/io_uring_unregister_eventfd.3 +1 -0
- data/vendor/liburing/man/io_uring_unregister_files.3 +11 -10
- data/vendor/liburing/man/io_uring_unregister_iowq_aff.3 +1 -0
- data/vendor/liburing/man/io_uring_unregister_ring_fd.3 +32 -0
- data/vendor/liburing/man/io_uring_wait_cqe.3 +19 -12
- data/vendor/liburing/man/io_uring_wait_cqe_nr.3 +21 -14
- data/vendor/liburing/man/io_uring_wait_cqe_timeout.3 +27 -13
- data/vendor/liburing/man/io_uring_wait_cqes.3 +24 -14
- data/vendor/liburing/src/Makefile +8 -7
- data/vendor/liburing/src/arch/aarch64/lib.h +48 -0
- data/vendor/liburing/src/arch/aarch64/syscall.h +0 -4
- data/vendor/liburing/src/arch/generic/lib.h +0 -4
- data/vendor/liburing/src/arch/generic/syscall.h +29 -16
- data/vendor/liburing/src/arch/syscall-defs.h +41 -14
- data/vendor/liburing/src/arch/x86/lib.h +0 -21
- data/vendor/liburing/src/arch/x86/syscall.h +146 -10
- data/vendor/liburing/src/include/liburing/io_uring.h +245 -5
- data/vendor/liburing/src/include/liburing.h +468 -35
- data/vendor/liburing/src/int_flags.h +1 -0
- data/vendor/liburing/src/lib.h +20 -16
- data/vendor/liburing/src/liburing.map +16 -0
- data/vendor/liburing/src/nolibc.c +1 -1
- data/vendor/liburing/src/queue.c +87 -55
- data/vendor/liburing/src/register.c +129 -53
- data/vendor/liburing/src/setup.c +65 -28
- data/vendor/liburing/src/syscall.c +14 -32
- data/vendor/liburing/src/syscall.h +12 -64
- data/vendor/liburing/test/{232c93d07b74-test.c → 232c93d07b74.c} +8 -9
- data/vendor/liburing/test/{35fa71a030ca-test.c → 35fa71a030ca.c} +4 -4
- data/vendor/liburing/test/{500f9fbadef8-test.c → 500f9fbadef8.c} +7 -7
- data/vendor/liburing/test/{7ad0e4b2f83c-test.c → 7ad0e4b2f83c.c} +8 -7
- data/vendor/liburing/test/{8a9973408177-test.c → 8a9973408177.c} +4 -3
- data/vendor/liburing/test/{917257daa0fe-test.c → 917257daa0fe.c} +3 -2
- data/vendor/liburing/test/Makefile +60 -62
- data/vendor/liburing/test/{a0908ae19763-test.c → a0908ae19763.c} +3 -2
- data/vendor/liburing/test/{a4c0b3decb33-test.c → a4c0b3decb33.c} +3 -2
- data/vendor/liburing/test/accept-link.c +5 -4
- data/vendor/liburing/test/accept-reuse.c +17 -16
- data/vendor/liburing/test/accept-test.c +14 -10
- data/vendor/liburing/test/accept.c +529 -107
- data/vendor/liburing/test/across-fork.c +7 -6
- data/vendor/liburing/test/{b19062a56726-test.c → b19062a56726.c} +3 -2
- data/vendor/liburing/test/{b5837bd5311d-test.c → b5837bd5311d.c} +10 -9
- data/vendor/liburing/test/buf-ring.c +420 -0
- data/vendor/liburing/test/{ce593a6c480a-test.c → ce593a6c480a.c} +15 -12
- data/vendor/liburing/test/connect.c +8 -7
- data/vendor/liburing/test/cq-full.c +5 -4
- data/vendor/liburing/test/cq-overflow.c +242 -12
- data/vendor/liburing/test/cq-peek-batch.c +5 -4
- data/vendor/liburing/test/cq-ready.c +5 -4
- data/vendor/liburing/test/cq-size.c +5 -4
- data/vendor/liburing/test/{d4ae271dfaae-test.c → d4ae271dfaae.c} +2 -2
- data/vendor/liburing/test/{d77a67ed5f27-test.c → d77a67ed5f27.c} +6 -6
- data/vendor/liburing/test/defer-taskrun.c +336 -0
- data/vendor/liburing/test/defer.c +26 -14
- data/vendor/liburing/test/double-poll-crash.c +15 -5
- data/vendor/liburing/test/drop-submit.c +5 -3
- data/vendor/liburing/test/{eeed8b54e0df-test.c → eeed8b54e0df.c} +7 -6
- data/vendor/liburing/test/empty-eownerdead.c +4 -4
- data/vendor/liburing/test/eventfd-disable.c +48 -20
- data/vendor/liburing/test/eventfd-reg.c +10 -9
- data/vendor/liburing/test/eventfd-ring.c +13 -12
- data/vendor/liburing/test/eventfd.c +13 -12
- data/vendor/liburing/test/exit-no-cleanup.c +1 -1
- data/vendor/liburing/test/fadvise.c +3 -3
- data/vendor/liburing/test/fallocate.c +16 -9
- data/vendor/liburing/test/{fc2a85cb02ef-test.c → fc2a85cb02ef.c} +4 -3
- data/vendor/liburing/test/fd-pass.c +187 -0
- data/vendor/liburing/test/file-register.c +302 -36
- data/vendor/liburing/test/file-update.c +62 -4
- data/vendor/liburing/test/file-verify.c +6 -2
- data/vendor/liburing/test/files-exit-hang-poll.c +11 -25
- data/vendor/liburing/test/files-exit-hang-timeout.c +13 -10
- data/vendor/liburing/test/fixed-buf-iter.c +115 -0
- data/vendor/liburing/test/fixed-link.c +10 -10
- data/vendor/liburing/test/fixed-reuse.c +160 -0
- data/vendor/liburing/test/fpos.c +6 -3
- data/vendor/liburing/test/fsync.c +3 -3
- data/vendor/liburing/test/hardlink.c +10 -6
- data/vendor/liburing/test/helpers.c +137 -4
- data/vendor/liburing/test/helpers.h +27 -0
- data/vendor/liburing/test/io-cancel.c +16 -11
- data/vendor/liburing/test/io_uring_enter.c +46 -81
- data/vendor/liburing/test/io_uring_passthrough.c +451 -0
- data/vendor/liburing/test/io_uring_register.c +59 -229
- data/vendor/liburing/test/io_uring_setup.c +24 -29
- data/vendor/liburing/test/iopoll-leak.c +85 -0
- data/vendor/liburing/test/iopoll.c +16 -9
- data/vendor/liburing/test/lfs-openat-write.c +3 -1
- data/vendor/liburing/test/link-timeout.c +4 -3
- data/vendor/liburing/test/link.c +8 -7
- data/vendor/liburing/test/madvise.c +2 -2
- data/vendor/liburing/test/mkdir.c +9 -5
- data/vendor/liburing/test/msg-ring.c +46 -20
- data/vendor/liburing/test/multicqes_drain.c +51 -12
- data/vendor/liburing/test/nolibc.c +60 -0
- data/vendor/liburing/test/nop.c +78 -16
- data/vendor/liburing/test/nvme.h +168 -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 +3 -3
- data/vendor/liburing/test/poll-cancel-all.c +472 -0
- data/vendor/liburing/test/poll-link.c +9 -18
- data/vendor/liburing/test/poll-mshot-overflow.c +162 -0
- data/vendor/liburing/test/poll-mshot-update.c +83 -33
- data/vendor/liburing/test/pollfree.c +2 -2
- data/vendor/liburing/test/read-before-exit.c +112 -0
- data/vendor/liburing/test/read-write.c +83 -1
- data/vendor/liburing/test/recv-msgall-stream.c +398 -0
- data/vendor/liburing/test/recv-msgall.c +265 -0
- data/vendor/liburing/test/recv-multishot.c +505 -0
- data/vendor/liburing/test/rename.c +2 -5
- data/vendor/liburing/test/ring-leak.c +97 -0
- data/vendor/liburing/test/ringbuf-read.c +200 -0
- data/vendor/liburing/test/rsrc_tags.c +25 -13
- data/vendor/liburing/test/runtests-quiet.sh +11 -0
- data/vendor/liburing/test/runtests.sh +18 -20
- data/vendor/liburing/test/rw_merge_test.c +3 -2
- data/vendor/liburing/test/send-zerocopy.c +684 -0
- data/vendor/liburing/test/send_recv.c +49 -2
- data/vendor/liburing/test/send_recvmsg.c +165 -55
- data/vendor/liburing/test/shutdown.c +3 -4
- data/vendor/liburing/test/sigfd-deadlock.c +22 -8
- data/vendor/liburing/test/single-issuer.c +171 -0
- data/vendor/liburing/test/socket-rw-eagain.c +2 -12
- data/vendor/liburing/test/socket-rw-offset.c +2 -11
- data/vendor/liburing/test/socket-rw.c +2 -11
- data/vendor/liburing/test/socket.c +409 -0
- data/vendor/liburing/test/sq-poll-dup.c +1 -1
- data/vendor/liburing/test/sq-poll-share.c +1 -1
- data/vendor/liburing/test/statx.c +2 -2
- data/vendor/liburing/test/submit-and-wait.c +108 -0
- data/vendor/liburing/test/submit-link-fail.c +5 -3
- data/vendor/liburing/test/submit-reuse.c +0 -2
- data/vendor/liburing/test/sync-cancel.c +235 -0
- data/vendor/liburing/test/test.h +35 -0
- data/vendor/liburing/test/timeout-overflow.c +11 -11
- data/vendor/liburing/test/timeout.c +7 -7
- data/vendor/liburing/test/tty-write-dpoll.c +60 -0
- data/vendor/liburing/test/unlink.c +1 -1
- data/vendor/liburing/test/xattr.c +425 -0
- metadata +143 -22
- data/Gemfile.lock +0 -78
|
@@ -31,57 +31,42 @@ static int pagesize;
|
|
|
31
31
|
static rlim_t mlock_limit;
|
|
32
32
|
static int devnull;
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
#include <sys/syscall.h>
|
|
36
|
-
#include <linux/memfd.h>
|
|
37
|
-
|
|
38
|
-
static int memfd_create(const char *name, unsigned int flags)
|
|
39
|
-
{
|
|
40
|
-
return (int)syscall(SYS_memfd_create, name, flags);
|
|
41
|
-
}
|
|
42
|
-
#endif
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
int
|
|
46
|
-
expect_fail(int fd, unsigned int opcode, void *arg,
|
|
34
|
+
static int expect_fail(int fd, unsigned int opcode, void *arg,
|
|
47
35
|
unsigned int nr_args, int error)
|
|
48
36
|
{
|
|
49
37
|
int ret;
|
|
50
38
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
ret = __sys_io_uring_register(fd, opcode, arg, nr_args);
|
|
54
|
-
if (ret != -1) {
|
|
39
|
+
ret = io_uring_register(fd, opcode, arg, nr_args);
|
|
40
|
+
if (ret >= 0) {
|
|
55
41
|
int ret2 = 0;
|
|
56
42
|
|
|
57
|
-
|
|
43
|
+
fprintf(stderr, "expected %s, but call succeeded\n", strerror(error));
|
|
58
44
|
if (opcode == IORING_REGISTER_BUFFERS) {
|
|
59
|
-
ret2 =
|
|
60
|
-
|
|
45
|
+
ret2 = io_uring_register(fd, IORING_UNREGISTER_BUFFERS,
|
|
46
|
+
0, 0);
|
|
61
47
|
} else if (opcode == IORING_REGISTER_FILES) {
|
|
62
|
-
ret2 =
|
|
63
|
-
|
|
48
|
+
ret2 = io_uring_register(fd, IORING_UNREGISTER_FILES, 0,
|
|
49
|
+
0);
|
|
64
50
|
}
|
|
65
51
|
if (ret2) {
|
|
66
|
-
|
|
52
|
+
fprintf(stderr, "internal error: failed to unregister\n");
|
|
67
53
|
exit(1);
|
|
68
54
|
}
|
|
69
55
|
return 1;
|
|
70
56
|
}
|
|
71
57
|
|
|
72
|
-
if (
|
|
73
|
-
|
|
58
|
+
if (ret != error) {
|
|
59
|
+
fprintf(stderr, "expected %d, got %d\n", error, ret);
|
|
74
60
|
return 1;
|
|
75
61
|
}
|
|
76
62
|
return 0;
|
|
77
63
|
}
|
|
78
64
|
|
|
79
|
-
int
|
|
80
|
-
new_io_uring(int entries, struct io_uring_params *p)
|
|
65
|
+
static int new_io_uring(int entries, struct io_uring_params *p)
|
|
81
66
|
{
|
|
82
67
|
int fd;
|
|
83
68
|
|
|
84
|
-
fd =
|
|
69
|
+
fd = io_uring_setup(entries, p);
|
|
85
70
|
if (fd < 0) {
|
|
86
71
|
perror("io_uring_setup");
|
|
87
72
|
exit(1);
|
|
@@ -91,8 +76,7 @@ new_io_uring(int entries, struct io_uring_params *p)
|
|
|
91
76
|
|
|
92
77
|
#define MAXFDS (UINT_MAX * sizeof(int))
|
|
93
78
|
|
|
94
|
-
void *
|
|
95
|
-
map_filebacked(size_t size)
|
|
79
|
+
static void *map_filebacked(size_t size)
|
|
96
80
|
{
|
|
97
81
|
int fd, ret;
|
|
98
82
|
void *addr;
|
|
@@ -127,8 +111,7 @@ map_filebacked(size_t size)
|
|
|
127
111
|
* NOTE: this is now limited by SCM_MAX_FD (253). Keep the code for now,
|
|
128
112
|
* but probably should augment it to test 253 and 254, specifically.
|
|
129
113
|
*/
|
|
130
|
-
int
|
|
131
|
-
test_max_fds(int uring_fd)
|
|
114
|
+
static int test_max_fds(int uring_fd)
|
|
132
115
|
{
|
|
133
116
|
int status = 1;
|
|
134
117
|
int ret;
|
|
@@ -148,14 +131,11 @@ test_max_fds(int uring_fd)
|
|
|
148
131
|
fd_as = mmap(NULL, UINT_MAX * sizeof(int), PROT_READ|PROT_WRITE,
|
|
149
132
|
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
|
|
150
133
|
if (fd_as == MAP_FAILED) {
|
|
151
|
-
if (errno == ENOMEM)
|
|
152
|
-
printf("Not enough memory for this test, skipping\n");
|
|
134
|
+
if (errno == ENOMEM)
|
|
153
135
|
return 0;
|
|
154
|
-
}
|
|
155
136
|
perror("mmap fd_as");
|
|
156
137
|
exit(1);
|
|
157
138
|
}
|
|
158
|
-
printf("allocated %zu bytes of address space\n", UINT_MAX * sizeof(int));
|
|
159
139
|
|
|
160
140
|
fdtable_fd = mkstemp(template);
|
|
161
141
|
if (fdtable_fd < 0) {
|
|
@@ -193,7 +173,7 @@ test_max_fds(int uring_fd)
|
|
|
193
173
|
fds = mmap(fds, 128*1024*1024, PROT_READ|PROT_WRITE,
|
|
194
174
|
MAP_SHARED|MAP_FIXED, fdtable_fd, 0);
|
|
195
175
|
if (fds == MAP_FAILED) {
|
|
196
|
-
|
|
176
|
+
fprintf(stderr, "mmap failed at offset %lu\n",
|
|
197
177
|
(unsigned long)((char *)fd_as - (char *)fds));
|
|
198
178
|
exit(1);
|
|
199
179
|
}
|
|
@@ -206,27 +186,20 @@ test_max_fds(int uring_fd)
|
|
|
206
186
|
*/
|
|
207
187
|
nr_fds = UINT_MAX;
|
|
208
188
|
while (nr_fds) {
|
|
209
|
-
ret =
|
|
210
|
-
|
|
189
|
+
ret = io_uring_register(uring_fd, IORING_REGISTER_FILES, fd_as,
|
|
190
|
+
nr_fds);
|
|
211
191
|
if (ret != 0) {
|
|
212
192
|
nr_fds /= 2;
|
|
213
193
|
continue;
|
|
214
194
|
}
|
|
215
|
-
printf("io_uring_register(%d, IORING_REGISTER_FILES, %p, %llu)"
|
|
216
|
-
"...succeeded\n", uring_fd, fd_as, nr_fds);
|
|
217
195
|
status = 0;
|
|
218
|
-
|
|
219
|
-
uring_fd);
|
|
220
|
-
ret = __sys_io_uring_register(uring_fd, IORING_UNREGISTER_FILES,
|
|
221
|
-
0, 0);
|
|
196
|
+
ret = io_uring_register(uring_fd, IORING_UNREGISTER_FILES, 0, 0);
|
|
222
197
|
if (ret < 0) {
|
|
223
198
|
ret = errno;
|
|
224
|
-
printf("failed\n");
|
|
225
199
|
errno = ret;
|
|
226
200
|
perror("io_uring_register UNREGISTER_FILES");
|
|
227
201
|
exit(1);
|
|
228
202
|
}
|
|
229
|
-
printf("succeeded\n");
|
|
230
203
|
break;
|
|
231
204
|
}
|
|
232
205
|
|
|
@@ -234,15 +207,14 @@ test_max_fds(int uring_fd)
|
|
|
234
207
|
close(fdtable_fd);
|
|
235
208
|
ret = munmap(fd_as, UINT_MAX * sizeof(int));
|
|
236
209
|
if (ret != 0) {
|
|
237
|
-
|
|
210
|
+
fprintf(stderr, "munmap(%zu) failed\n", UINT_MAX * sizeof(int));
|
|
238
211
|
exit(1);
|
|
239
212
|
}
|
|
240
213
|
|
|
241
214
|
return status;
|
|
242
215
|
}
|
|
243
216
|
|
|
244
|
-
int
|
|
245
|
-
test_memlock_exceeded(int fd)
|
|
217
|
+
static int test_memlock_exceeded(int fd)
|
|
246
218
|
{
|
|
247
219
|
int ret;
|
|
248
220
|
void *buf;
|
|
@@ -257,11 +229,9 @@ test_memlock_exceeded(int fd)
|
|
|
257
229
|
iov.iov_base = buf;
|
|
258
230
|
|
|
259
231
|
while (iov.iov_len) {
|
|
260
|
-
ret =
|
|
232
|
+
ret = io_uring_register(fd, IORING_REGISTER_BUFFERS, &iov, 1);
|
|
261
233
|
if (ret < 0) {
|
|
262
234
|
if (errno == ENOMEM) {
|
|
263
|
-
printf("io_uring_register of %zu bytes failed "
|
|
264
|
-
"with ENOMEM (expected).\n", iov.iov_len);
|
|
265
235
|
iov.iov_len /= 2;
|
|
266
236
|
continue;
|
|
267
237
|
}
|
|
@@ -269,16 +239,13 @@ test_memlock_exceeded(int fd)
|
|
|
269
239
|
free(buf);
|
|
270
240
|
return 0;
|
|
271
241
|
}
|
|
272
|
-
|
|
242
|
+
fprintf(stderr, "expected success or EFAULT, got %d\n", errno);
|
|
273
243
|
free(buf);
|
|
274
244
|
return 1;
|
|
275
245
|
}
|
|
276
|
-
|
|
277
|
-
iov.iov_len, ret);
|
|
278
|
-
ret = __sys_io_uring_register(fd, IORING_UNREGISTER_BUFFERS,
|
|
279
|
-
NULL, 0);
|
|
246
|
+
ret = io_uring_register(fd, IORING_UNREGISTER_BUFFERS, NULL, 0);
|
|
280
247
|
if (ret != 0) {
|
|
281
|
-
|
|
248
|
+
fprintf(stderr, "error: unregister failed with %d\n", errno);
|
|
282
249
|
free(buf);
|
|
283
250
|
return 1;
|
|
284
251
|
}
|
|
@@ -291,8 +258,7 @@ test_memlock_exceeded(int fd)
|
|
|
291
258
|
return 0;
|
|
292
259
|
}
|
|
293
260
|
|
|
294
|
-
int
|
|
295
|
-
test_iovec_nr(int fd)
|
|
261
|
+
static int test_iovec_nr(int fd)
|
|
296
262
|
{
|
|
297
263
|
int i, ret, status = 0;
|
|
298
264
|
unsigned int nr = 1000000;
|
|
@@ -311,20 +277,18 @@ test_iovec_nr(int fd)
|
|
|
311
277
|
iovs[i].iov_len = pagesize;
|
|
312
278
|
}
|
|
313
279
|
|
|
314
|
-
status |= expect_fail(fd, IORING_REGISTER_BUFFERS, iovs, nr, EINVAL);
|
|
280
|
+
status |= expect_fail(fd, IORING_REGISTER_BUFFERS, iovs, nr, -EINVAL);
|
|
315
281
|
|
|
316
282
|
/* reduce to UIO_MAXIOV */
|
|
317
283
|
nr = UIO_MAXIOV;
|
|
318
|
-
|
|
319
|
-
fd, IORING_REGISTER_BUFFERS, iovs, nr);
|
|
320
|
-
ret = __sys_io_uring_register(fd, IORING_REGISTER_BUFFERS, iovs, nr);
|
|
284
|
+
ret = io_uring_register(fd, IORING_REGISTER_BUFFERS, iovs, nr);
|
|
321
285
|
if (ret && (errno == ENOMEM || errno == EPERM) && geteuid()) {
|
|
322
|
-
|
|
286
|
+
fprintf(stderr, "can't register large iovec for regular users, skip\n");
|
|
323
287
|
} else if (ret != 0) {
|
|
324
|
-
|
|
288
|
+
fprintf(stderr, "expected success, got %d\n", errno);
|
|
325
289
|
status = 1;
|
|
326
290
|
} else {
|
|
327
|
-
|
|
291
|
+
io_uring_register(fd, IORING_UNREGISTER_BUFFERS, 0, 0);
|
|
328
292
|
}
|
|
329
293
|
free(buf);
|
|
330
294
|
free(iovs);
|
|
@@ -334,8 +298,7 @@ test_iovec_nr(int fd)
|
|
|
334
298
|
/*
|
|
335
299
|
* io_uring limit is 1G. iov_len limit is ~OUL, I think
|
|
336
300
|
*/
|
|
337
|
-
int
|
|
338
|
-
test_iovec_size(int fd)
|
|
301
|
+
static int test_iovec_size(int fd)
|
|
339
302
|
{
|
|
340
303
|
unsigned int status = 0;
|
|
341
304
|
int ret;
|
|
@@ -345,12 +308,12 @@ test_iovec_size(int fd)
|
|
|
345
308
|
/* NULL pointer for base */
|
|
346
309
|
iov.iov_base = 0;
|
|
347
310
|
iov.iov_len = 4096;
|
|
348
|
-
status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, EFAULT);
|
|
311
|
+
status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, -EFAULT);
|
|
349
312
|
|
|
350
313
|
/* valid base, 0 length */
|
|
351
314
|
iov.iov_base = &buf;
|
|
352
315
|
iov.iov_len = 0;
|
|
353
|
-
status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, EFAULT);
|
|
316
|
+
status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, -EFAULT);
|
|
354
317
|
|
|
355
318
|
/* valid base, length exceeds size */
|
|
356
319
|
/* this requires an unampped page directly after buf */
|
|
@@ -361,7 +324,7 @@ test_iovec_size(int fd)
|
|
|
361
324
|
assert(ret == 0);
|
|
362
325
|
iov.iov_base = buf;
|
|
363
326
|
iov.iov_len = 2 * pagesize;
|
|
364
|
-
status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, EFAULT);
|
|
327
|
+
status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, -EFAULT);
|
|
365
328
|
munmap(buf, pagesize);
|
|
366
329
|
|
|
367
330
|
/* huge page */
|
|
@@ -379,23 +342,23 @@ test_iovec_size(int fd)
|
|
|
379
342
|
*/
|
|
380
343
|
iov.iov_base = buf;
|
|
381
344
|
iov.iov_len = 2*1024*1024;
|
|
382
|
-
ret =
|
|
345
|
+
ret = io_uring_register(fd, IORING_REGISTER_BUFFERS, &iov, 1);
|
|
383
346
|
if (ret < 0) {
|
|
384
|
-
if (
|
|
347
|
+
if (ret == -ENOMEM)
|
|
385
348
|
printf("Unable to test registering of a huge "
|
|
386
349
|
"page. Try increasing the "
|
|
387
350
|
"RLIMIT_MEMLOCK resource limit by at "
|
|
388
351
|
"least 2MB.");
|
|
389
352
|
else {
|
|
390
|
-
|
|
353
|
+
fprintf(stderr, "expected success, got %d\n", ret);
|
|
391
354
|
status = 1;
|
|
392
355
|
}
|
|
393
356
|
} else {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
IORING_UNREGISTER_BUFFERS, 0, 0);
|
|
357
|
+
ret = io_uring_register(fd, IORING_UNREGISTER_BUFFERS,
|
|
358
|
+
0, 0);
|
|
397
359
|
if (ret < 0) {
|
|
398
|
-
|
|
360
|
+
fprintf(stderr, "io_uring_unregister: %s\n",
|
|
361
|
+
strerror(-ret));
|
|
399
362
|
status = 1;
|
|
400
363
|
}
|
|
401
364
|
}
|
|
@@ -409,8 +372,7 @@ test_iovec_size(int fd)
|
|
|
409
372
|
status = 1;
|
|
410
373
|
iov.iov_base = buf;
|
|
411
374
|
iov.iov_len = 2*1024*1024;
|
|
412
|
-
|
|
413
|
-
status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, EOPNOTSUPP);
|
|
375
|
+
status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, -EOPNOTSUPP);
|
|
414
376
|
munmap(buf, 2*1024*1024);
|
|
415
377
|
|
|
416
378
|
/* bump up against the soft limit and make sure we get EFAULT
|
|
@@ -422,18 +384,7 @@ test_iovec_size(int fd)
|
|
|
422
384
|
return status;
|
|
423
385
|
}
|
|
424
386
|
|
|
425
|
-
|
|
426
|
-
dump_sqe(struct io_uring_sqe *sqe)
|
|
427
|
-
{
|
|
428
|
-
printf("\topcode: %d\n", sqe->opcode);
|
|
429
|
-
printf("\tflags: 0x%.8x\n", sqe->flags);
|
|
430
|
-
printf("\tfd: %d\n", sqe->fd);
|
|
431
|
-
if (sqe->opcode == IORING_OP_POLL_ADD)
|
|
432
|
-
printf("\tpoll_events: 0x%.8x\n", sqe->poll_events);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
int
|
|
436
|
-
ioring_poll(struct io_uring *ring, int fd, int fixed)
|
|
387
|
+
static int ioring_poll(struct io_uring *ring, int fd, int fixed)
|
|
437
388
|
{
|
|
438
389
|
int ret;
|
|
439
390
|
struct io_uring_sqe *sqe;
|
|
@@ -447,22 +398,20 @@ ioring_poll(struct io_uring *ring, int fd, int fixed)
|
|
|
447
398
|
sqe->fd = fd;
|
|
448
399
|
sqe->poll_events = POLLIN|POLLOUT;
|
|
449
400
|
|
|
450
|
-
printf("io_uring_submit:\n");
|
|
451
|
-
dump_sqe(sqe);
|
|
452
401
|
ret = io_uring_submit(ring);
|
|
453
402
|
if (ret != 1) {
|
|
454
|
-
|
|
403
|
+
fprintf(stderr, "failed to submit poll sqe: %d.\n", ret);
|
|
455
404
|
return 1;
|
|
456
405
|
}
|
|
457
406
|
|
|
458
407
|
ret = io_uring_wait_cqe(ring, &cqe);
|
|
459
408
|
if (ret < 0) {
|
|
460
|
-
|
|
409
|
+
fprintf(stderr, "io_uring_wait_cqe failed with %d\n", ret);
|
|
461
410
|
return 1;
|
|
462
411
|
}
|
|
463
412
|
ret = 0;
|
|
464
413
|
if (cqe->res != POLLOUT) {
|
|
465
|
-
|
|
414
|
+
fprintf(stderr, "io_uring_wait_cqe: expected 0x%.8x, got 0x%.8x\n",
|
|
466
415
|
POLLOUT, cqe->res);
|
|
467
416
|
ret = 1;
|
|
468
417
|
}
|
|
@@ -471,8 +420,7 @@ ioring_poll(struct io_uring *ring, int fd, int fixed)
|
|
|
471
420
|
return ret;
|
|
472
421
|
}
|
|
473
422
|
|
|
474
|
-
int
|
|
475
|
-
test_poll_ringfd(void)
|
|
423
|
+
static int test_poll_ringfd(void)
|
|
476
424
|
{
|
|
477
425
|
int status = 0;
|
|
478
426
|
int ret;
|
|
@@ -494,7 +442,7 @@ test_poll_ringfd(void)
|
|
|
494
442
|
* fail, because the kernel does not allow registering of the
|
|
495
443
|
* ring_fd.
|
|
496
444
|
*/
|
|
497
|
-
status |= expect_fail(fd, IORING_REGISTER_FILES, &fd, 1, EBADF);
|
|
445
|
+
status |= expect_fail(fd, IORING_REGISTER_FILES, &fd, 1, -EBADF);
|
|
498
446
|
|
|
499
447
|
/* tear down queue */
|
|
500
448
|
io_uring_queue_exit(&ring);
|
|
@@ -502,115 +450,7 @@ test_poll_ringfd(void)
|
|
|
502
450
|
return status;
|
|
503
451
|
}
|
|
504
452
|
|
|
505
|
-
|
|
506
|
-
{
|
|
507
|
-
const char pattern = 0xEA;
|
|
508
|
-
const int len = 4096;
|
|
509
|
-
struct io_uring_sqe *sqe;
|
|
510
|
-
struct io_uring_cqe *cqe;
|
|
511
|
-
struct io_uring ring;
|
|
512
|
-
struct iovec iov;
|
|
513
|
-
int memfd, ret, i;
|
|
514
|
-
char *mem;
|
|
515
|
-
int pipefd[2] = {-1, -1};
|
|
516
|
-
|
|
517
|
-
ret = io_uring_queue_init(8, &ring, 0);
|
|
518
|
-
if (ret)
|
|
519
|
-
return 1;
|
|
520
|
-
|
|
521
|
-
if (pipe(pipefd)) {
|
|
522
|
-
perror("pipe");
|
|
523
|
-
return 1;
|
|
524
|
-
}
|
|
525
|
-
memfd = memfd_create("uring-shmem-test", 0);
|
|
526
|
-
if (memfd < 0) {
|
|
527
|
-
fprintf(stderr, "memfd_create() failed %i\n", -errno);
|
|
528
|
-
return 1;
|
|
529
|
-
}
|
|
530
|
-
if (ftruncate(memfd, len)) {
|
|
531
|
-
fprintf(stderr, "can't truncate memfd\n");
|
|
532
|
-
return 1;
|
|
533
|
-
}
|
|
534
|
-
mem = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, memfd, 0);
|
|
535
|
-
if (!mem) {
|
|
536
|
-
fprintf(stderr, "mmap failed\n");
|
|
537
|
-
return 1;
|
|
538
|
-
}
|
|
539
|
-
for (i = 0; i < len; i++)
|
|
540
|
-
mem[i] = pattern;
|
|
541
|
-
|
|
542
|
-
iov.iov_base = mem;
|
|
543
|
-
iov.iov_len = len;
|
|
544
|
-
ret = io_uring_register_buffers(&ring, &iov, 1);
|
|
545
|
-
if (ret) {
|
|
546
|
-
if (ret == -EOPNOTSUPP) {
|
|
547
|
-
fprintf(stdout, "memfd registration isn't supported, "
|
|
548
|
-
"skip\n");
|
|
549
|
-
goto out;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
fprintf(stderr, "buffer reg failed: %d\n", ret);
|
|
553
|
-
return 1;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
/* check that we can read and write from/to shmem reg buffer */
|
|
557
|
-
sqe = io_uring_get_sqe(&ring);
|
|
558
|
-
io_uring_prep_write_fixed(sqe, pipefd[1], mem, 512, 0, 0);
|
|
559
|
-
sqe->user_data = 1;
|
|
560
|
-
|
|
561
|
-
ret = io_uring_submit(&ring);
|
|
562
|
-
if (ret != 1) {
|
|
563
|
-
fprintf(stderr, "submit write failed\n");
|
|
564
|
-
return 1;
|
|
565
|
-
}
|
|
566
|
-
ret = io_uring_wait_cqe(&ring, &cqe);
|
|
567
|
-
if (ret < 0 || cqe->user_data != 1 || cqe->res != 512) {
|
|
568
|
-
fprintf(stderr, "reading from shmem failed\n");
|
|
569
|
-
return 1;
|
|
570
|
-
}
|
|
571
|
-
io_uring_cqe_seen(&ring, cqe);
|
|
572
|
-
|
|
573
|
-
/* clean it, should be populated with the pattern back from the pipe */
|
|
574
|
-
memset(mem, 0, 512);
|
|
575
|
-
sqe = io_uring_get_sqe(&ring);
|
|
576
|
-
io_uring_prep_read_fixed(sqe, pipefd[0], mem, 512, 0, 0);
|
|
577
|
-
sqe->user_data = 2;
|
|
578
|
-
|
|
579
|
-
ret = io_uring_submit(&ring);
|
|
580
|
-
if (ret != 1) {
|
|
581
|
-
fprintf(stderr, "submit write failed\n");
|
|
582
|
-
return 1;
|
|
583
|
-
}
|
|
584
|
-
ret = io_uring_wait_cqe(&ring, &cqe);
|
|
585
|
-
if (ret < 0 || cqe->user_data != 2 || cqe->res != 512) {
|
|
586
|
-
fprintf(stderr, "reading from shmem failed\n");
|
|
587
|
-
return 1;
|
|
588
|
-
}
|
|
589
|
-
io_uring_cqe_seen(&ring, cqe);
|
|
590
|
-
|
|
591
|
-
for (i = 0; i < 512; i++) {
|
|
592
|
-
if (mem[i] != pattern) {
|
|
593
|
-
fprintf(stderr, "data integrity fail\n");
|
|
594
|
-
return 1;
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
ret = io_uring_unregister_buffers(&ring);
|
|
599
|
-
if (ret) {
|
|
600
|
-
fprintf(stderr, "buffer unreg failed: %d\n", ret);
|
|
601
|
-
return 1;
|
|
602
|
-
}
|
|
603
|
-
out:
|
|
604
|
-
io_uring_queue_exit(&ring);
|
|
605
|
-
close(pipefd[0]);
|
|
606
|
-
close(pipefd[1]);
|
|
607
|
-
munmap(mem, len);
|
|
608
|
-
close(memfd);
|
|
609
|
-
return 0;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
int
|
|
613
|
-
main(int argc, char **argv)
|
|
453
|
+
int main(int argc, char **argv)
|
|
614
454
|
{
|
|
615
455
|
int fd, ret;
|
|
616
456
|
unsigned int status = 0;
|
|
@@ -618,33 +458,31 @@ main(int argc, char **argv)
|
|
|
618
458
|
struct rlimit rlim;
|
|
619
459
|
|
|
620
460
|
if (argc > 1)
|
|
621
|
-
return
|
|
461
|
+
return T_EXIT_SKIP;
|
|
622
462
|
|
|
623
463
|
/* setup globals */
|
|
624
464
|
pagesize = getpagesize();
|
|
625
465
|
ret = getrlimit(RLIMIT_MEMLOCK, &rlim);
|
|
626
466
|
if (ret < 0) {
|
|
627
467
|
perror("getrlimit");
|
|
628
|
-
return
|
|
468
|
+
return T_EXIT_PASS;
|
|
629
469
|
}
|
|
630
470
|
mlock_limit = rlim.rlim_cur;
|
|
631
|
-
printf("RELIMIT_MEMLOCK: %llu (%llu)\n", (unsigned long long) rlim.rlim_cur,
|
|
632
|
-
(unsigned long long) rlim.rlim_max);
|
|
633
471
|
devnull = open("/dev/null", O_RDWR);
|
|
634
472
|
if (devnull < 0) {
|
|
635
473
|
perror("open /dev/null");
|
|
636
|
-
exit(
|
|
474
|
+
exit(T_EXIT_FAIL);
|
|
637
475
|
}
|
|
638
476
|
|
|
639
477
|
/* invalid fd */
|
|
640
|
-
status |= expect_fail(-1, 0, NULL, 0, EBADF);
|
|
478
|
+
status |= expect_fail(-1, 0, NULL, 0, -EBADF);
|
|
641
479
|
/* valid fd that is not an io_uring fd */
|
|
642
|
-
status |= expect_fail(devnull, 0, NULL, 0, EOPNOTSUPP);
|
|
480
|
+
status |= expect_fail(devnull, 0, NULL, 0, -EOPNOTSUPP);
|
|
643
481
|
|
|
644
482
|
/* invalid opcode */
|
|
645
483
|
memset(&p, 0, sizeof(p));
|
|
646
484
|
fd = new_io_uring(1, &p);
|
|
647
|
-
ret = expect_fail(fd, ~0U, NULL, 0, EINVAL);
|
|
485
|
+
ret = expect_fail(fd, ~0U, NULL, 0, -EINVAL);
|
|
648
486
|
if (ret) {
|
|
649
487
|
/* if this succeeds, tear down the io_uring instance
|
|
650
488
|
* and start clean for the next test. */
|
|
@@ -661,16 +499,8 @@ main(int argc, char **argv)
|
|
|
661
499
|
/* uring poll on the uring fd */
|
|
662
500
|
status |= test_poll_ringfd();
|
|
663
501
|
|
|
664
|
-
if (
|
|
665
|
-
|
|
666
|
-
else
|
|
667
|
-
printf("FAIL\n");
|
|
668
|
-
|
|
669
|
-
ret = test_shmem();
|
|
670
|
-
if (ret) {
|
|
671
|
-
fprintf(stderr, "test_shmem() failed\n");
|
|
672
|
-
status |= 1;
|
|
673
|
-
}
|
|
502
|
+
if (status)
|
|
503
|
+
fprintf(stderr, "FAIL\n");
|
|
674
504
|
|
|
675
505
|
return status;
|
|
676
506
|
}
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
#include <errno.h>
|
|
16
16
|
#include <sys/sysinfo.h>
|
|
17
17
|
#include "liburing.h"
|
|
18
|
+
#include "helpers.h"
|
|
18
19
|
|
|
19
20
|
#include "../syscall.h"
|
|
20
21
|
|
|
@@ -97,29 +98,25 @@ dump_resv(struct io_uring_params *p)
|
|
|
97
98
|
/* bogus: setup returns a valid fd on success... expect can't predict the
|
|
98
99
|
fd we'll get, so this really only takes 1 parameter: error */
|
|
99
100
|
int
|
|
100
|
-
try_io_uring_setup(unsigned entries, struct io_uring_params *p, int expect
|
|
101
|
+
try_io_uring_setup(unsigned entries, struct io_uring_params *p, int expect)
|
|
101
102
|
{
|
|
102
|
-
int ret
|
|
103
|
+
int ret;
|
|
103
104
|
|
|
104
|
-
|
|
105
|
-
entries, p, flags_string(p), features_string(p), dump_resv(p),
|
|
106
|
-
p ? p->sq_thread_cpu : 0);
|
|
107
|
-
|
|
108
|
-
ret = __sys_io_uring_setup(entries, p);
|
|
105
|
+
ret = io_uring_setup(entries, p);
|
|
109
106
|
if (ret != expect) {
|
|
110
|
-
|
|
107
|
+
fprintf(stderr, "expected %d, got %d\n", expect, ret);
|
|
111
108
|
/* if we got a valid uring, close it */
|
|
112
109
|
if (ret > 0)
|
|
113
110
|
close(ret);
|
|
114
111
|
return 1;
|
|
115
112
|
}
|
|
116
|
-
|
|
117
|
-
if (expect
|
|
118
|
-
if (
|
|
113
|
+
|
|
114
|
+
if (expect < 0 && expect != ret) {
|
|
115
|
+
if (ret == -EPERM && geteuid() != 0) {
|
|
119
116
|
printf("Needs root, not flagging as an error\n");
|
|
120
117
|
return 0;
|
|
121
118
|
}
|
|
122
|
-
|
|
119
|
+
fprintf(stderr, "expected errno %d, got %d\n", expect, ret);
|
|
123
120
|
return 1;
|
|
124
121
|
}
|
|
125
122
|
|
|
@@ -134,32 +131,32 @@ main(int argc, char **argv)
|
|
|
134
131
|
struct io_uring_params p;
|
|
135
132
|
|
|
136
133
|
if (argc > 1)
|
|
137
|
-
return
|
|
134
|
+
return T_EXIT_SKIP;
|
|
138
135
|
|
|
139
136
|
memset(&p, 0, sizeof(p));
|
|
140
|
-
status |= try_io_uring_setup(0, &p, -
|
|
141
|
-
status |= try_io_uring_setup(1, NULL, -
|
|
137
|
+
status |= try_io_uring_setup(0, &p, -EINVAL);
|
|
138
|
+
status |= try_io_uring_setup(1, NULL, -EFAULT);
|
|
142
139
|
|
|
143
140
|
/* resv array is non-zero */
|
|
144
141
|
memset(&p, 0, sizeof(p));
|
|
145
142
|
p.resv[0] = p.resv[1] = p.resv[2] = 1;
|
|
146
|
-
status |= try_io_uring_setup(1, &p, -
|
|
143
|
+
status |= try_io_uring_setup(1, &p, -EINVAL);
|
|
147
144
|
|
|
148
145
|
/* invalid flags */
|
|
149
146
|
memset(&p, 0, sizeof(p));
|
|
150
147
|
p.flags = ~0U;
|
|
151
|
-
status |= try_io_uring_setup(1, &p, -
|
|
148
|
+
status |= try_io_uring_setup(1, &p, -EINVAL);
|
|
152
149
|
|
|
153
150
|
/* IORING_SETUP_SQ_AFF set but not IORING_SETUP_SQPOLL */
|
|
154
151
|
memset(&p, 0, sizeof(p));
|
|
155
152
|
p.flags = IORING_SETUP_SQ_AFF;
|
|
156
|
-
status |= try_io_uring_setup(1, &p, -
|
|
153
|
+
status |= try_io_uring_setup(1, &p, -EINVAL);
|
|
157
154
|
|
|
158
155
|
/* attempt to bind to invalid cpu */
|
|
159
156
|
memset(&p, 0, sizeof(p));
|
|
160
157
|
p.flags = IORING_SETUP_SQPOLL | IORING_SETUP_SQ_AFF;
|
|
161
158
|
p.sq_thread_cpu = get_nprocs_conf();
|
|
162
|
-
status |= try_io_uring_setup(1, &p, -
|
|
159
|
+
status |= try_io_uring_setup(1, &p, -EINVAL);
|
|
163
160
|
|
|
164
161
|
/* I think we can limit a process to a set of cpus. I assume
|
|
165
162
|
* we shouldn't be able to setup a kernel thread outside of that.
|
|
@@ -167,26 +164,24 @@ main(int argc, char **argv)
|
|
|
167
164
|
|
|
168
165
|
/* read/write on io_uring_fd */
|
|
169
166
|
memset(&p, 0, sizeof(p));
|
|
170
|
-
fd =
|
|
167
|
+
fd = io_uring_setup(1, &p);
|
|
171
168
|
if (fd < 0) {
|
|
172
|
-
|
|
173
|
-
|
|
169
|
+
fprintf(stderr, "io_uring_setup failed with %d, expected success\n",
|
|
170
|
+
-fd);
|
|
174
171
|
status = 1;
|
|
175
172
|
} else {
|
|
176
173
|
char buf[4096];
|
|
177
174
|
int ret;
|
|
178
175
|
ret = read(fd, buf, 4096);
|
|
179
176
|
if (ret >= 0) {
|
|
180
|
-
|
|
177
|
+
fprintf(stderr, "read from io_uring fd succeeded. expected fail\n");
|
|
181
178
|
status = 1;
|
|
182
179
|
}
|
|
183
180
|
}
|
|
184
181
|
|
|
185
|
-
if (!status)
|
|
186
|
-
|
|
187
|
-
return 0;
|
|
188
|
-
}
|
|
182
|
+
if (!status)
|
|
183
|
+
return T_EXIT_PASS;
|
|
189
184
|
|
|
190
|
-
|
|
191
|
-
return
|
|
185
|
+
fprintf(stderr, "FAIL\n");
|
|
186
|
+
return T_EXIT_FAIL;
|
|
192
187
|
}
|