polyphony 0.93 → 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/examples/pipes/echo_server.rb +1 -1
- data/examples/pipes/http_server.rb +33 -0
- data/ext/polyphony/backend_common.c +53 -8
- data/ext/polyphony/backend_common.h +21 -13
- data/ext/polyphony/backend_io_uring.c +85 -147
- data/ext/polyphony/backend_libev.c +58 -89
- data/ext/polyphony/event.c +1 -1
- data/ext/polyphony/extconf.rb +7 -5
- data/ext/polyphony/fiber.c +5 -13
- data/ext/polyphony/io_extensions.c +68 -68
- data/ext/polyphony/pipe.c +1 -1
- data/ext/polyphony/polyphony.c +23 -23
- data/ext/polyphony/polyphony.h +0 -9
- 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_global_api.rb +1 -1
- 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 +148 -26
- data/Gemfile.lock +0 -82
data/vendor/liburing/src/lib.h
CHANGED
|
@@ -6,33 +6,37 @@
|
|
|
6
6
|
#include <string.h>
|
|
7
7
|
#include <unistd.h>
|
|
8
8
|
|
|
9
|
-
#define __INTERNAL__LIBURING_LIB_H
|
|
10
9
|
#if defined(__x86_64__) || defined(__i386__)
|
|
11
|
-
|
|
10
|
+
#include "arch/x86/lib.h"
|
|
11
|
+
#elif defined(__aarch64__)
|
|
12
|
+
#include "arch/aarch64/lib.h"
|
|
12
13
|
#else
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
/*
|
|
15
|
+
* We don't have nolibc support for this arch. Must use libc!
|
|
16
|
+
*/
|
|
17
|
+
#ifdef CONFIG_NOLIBC
|
|
18
|
+
#error "This arch doesn't support building liburing without libc"
|
|
19
|
+
#endif
|
|
20
|
+
/* libc wrappers. */
|
|
21
|
+
#include "arch/generic/lib.h"
|
|
21
22
|
#endif
|
|
22
|
-
#undef __INTERNAL__LIBURING_LIB_H
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
#ifndef offsetof
|
|
26
|
-
|
|
26
|
+
#define offsetof(TYPE, FIELD) ((size_t) &((TYPE *)0)->FIELD)
|
|
27
27
|
#endif
|
|
28
28
|
|
|
29
29
|
#ifndef container_of
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
#define container_of(PTR, TYPE, FIELD) ({ \
|
|
31
|
+
__typeof__(((TYPE *)0)->FIELD) *__FIELD_PTR = (PTR); \
|
|
32
|
+
(TYPE *)((char *) __FIELD_PTR - offsetof(TYPE, FIELD)); \
|
|
33
|
+
})
|
|
34
34
|
#endif
|
|
35
35
|
|
|
36
|
+
#define __maybe_unused __attribute__((__unused__))
|
|
37
|
+
#define __hot __attribute__((__hot__))
|
|
38
|
+
#define __cold __attribute__((__cold__))
|
|
39
|
+
|
|
36
40
|
void *__uring_malloc(size_t len);
|
|
37
41
|
void __uring_free(void *p);
|
|
38
42
|
|
|
@@ -50,4 +50,20 @@ LIBURING_2.2 {
|
|
|
50
50
|
io_uring_submit_and_wait_timeout;
|
|
51
51
|
io_uring_register_ring_fd;
|
|
52
52
|
io_uring_unregister_ring_fd;
|
|
53
|
+
io_uring_register_files_sparse;
|
|
54
|
+
io_uring_register_buffers_sparse;
|
|
55
|
+
io_uring_register_buf_ring;
|
|
56
|
+
io_uring_unregister_buf_ring;
|
|
53
57
|
} LIBURING_2.1;
|
|
58
|
+
|
|
59
|
+
LIBURING_2.3 {
|
|
60
|
+
global:
|
|
61
|
+
io_uring_register_sync_cancel;
|
|
62
|
+
io_uring_register_file_alloc_range;
|
|
63
|
+
io_uring_enter;
|
|
64
|
+
io_uring_enter2;
|
|
65
|
+
io_uring_setup;
|
|
66
|
+
io_uring_register;
|
|
67
|
+
io_uring_get_events;
|
|
68
|
+
io_uring_submit_and_get_events;
|
|
69
|
+
} LIBURING_2.2;
|
data/vendor/liburing/src/queue.c
CHANGED
|
@@ -12,9 +12,15 @@
|
|
|
12
12
|
* Returns true if we're not using SQ thread (thus nobody submits but us)
|
|
13
13
|
* or if IORING_SQ_NEED_WAKEUP is set, so submit thread must be explicitly
|
|
14
14
|
* awakened. For the latter case, we set the thread wakeup flag.
|
|
15
|
+
* If no SQEs are ready for submission, returns false.
|
|
15
16
|
*/
|
|
16
|
-
static inline bool sq_ring_needs_enter(struct io_uring *ring,
|
|
17
|
+
static inline bool sq_ring_needs_enter(struct io_uring *ring,
|
|
18
|
+
unsigned submit,
|
|
19
|
+
unsigned *flags)
|
|
17
20
|
{
|
|
21
|
+
if (!submit)
|
|
22
|
+
return false;
|
|
23
|
+
|
|
18
24
|
if (!(ring->flags & IORING_SETUP_SQPOLL))
|
|
19
25
|
return true;
|
|
20
26
|
|
|
@@ -35,7 +41,8 @@ static inline bool sq_ring_needs_enter(struct io_uring *ring, unsigned *flags)
|
|
|
35
41
|
|
|
36
42
|
static inline bool cq_ring_needs_flush(struct io_uring *ring)
|
|
37
43
|
{
|
|
38
|
-
return IO_URING_READ_ONCE(*ring->sq.kflags) &
|
|
44
|
+
return IO_URING_READ_ONCE(*ring->sq.kflags) &
|
|
45
|
+
(IORING_SQ_CQ_OVERFLOW | IORING_SQ_TASKRUN);
|
|
39
46
|
}
|
|
40
47
|
|
|
41
48
|
static inline bool cq_ring_needs_enter(struct io_uring *ring)
|
|
@@ -48,15 +55,17 @@ struct get_data {
|
|
|
48
55
|
unsigned wait_nr;
|
|
49
56
|
unsigned get_flags;
|
|
50
57
|
int sz;
|
|
58
|
+
int has_ts;
|
|
51
59
|
void *arg;
|
|
52
60
|
};
|
|
53
61
|
|
|
54
|
-
static int _io_uring_get_cqe(struct io_uring *ring,
|
|
62
|
+
static int _io_uring_get_cqe(struct io_uring *ring,
|
|
63
|
+
struct io_uring_cqe **cqe_ptr,
|
|
55
64
|
struct get_data *data)
|
|
56
65
|
{
|
|
57
66
|
struct io_uring_cqe *cqe = NULL;
|
|
58
67
|
bool looped = false;
|
|
59
|
-
int err;
|
|
68
|
+
int err = 0;
|
|
60
69
|
|
|
61
70
|
do {
|
|
62
71
|
bool need_enter = false;
|
|
@@ -64,9 +73,12 @@ static int _io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_pt
|
|
|
64
73
|
unsigned nr_available;
|
|
65
74
|
int ret;
|
|
66
75
|
|
|
67
|
-
|
|
68
|
-
if (
|
|
76
|
+
ret = __io_uring_peek_cqe(ring, &cqe, &nr_available);
|
|
77
|
+
if (ret) {
|
|
78
|
+
if (!err)
|
|
79
|
+
err = ret;
|
|
69
80
|
break;
|
|
81
|
+
}
|
|
70
82
|
if (!cqe && !data->wait_nr && !data->submit) {
|
|
71
83
|
/*
|
|
72
84
|
* If we already looped once, we already entererd
|
|
@@ -74,7 +86,8 @@ static int _io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_pt
|
|
|
74
86
|
* wait for, don't keep retrying.
|
|
75
87
|
*/
|
|
76
88
|
if (looped || !cq_ring_needs_enter(ring)) {
|
|
77
|
-
err
|
|
89
|
+
if (!err)
|
|
90
|
+
err = -EAGAIN;
|
|
78
91
|
break;
|
|
79
92
|
}
|
|
80
93
|
need_enter = true;
|
|
@@ -83,25 +96,36 @@ static int _io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_pt
|
|
|
83
96
|
flags = IORING_ENTER_GETEVENTS | data->get_flags;
|
|
84
97
|
need_enter = true;
|
|
85
98
|
}
|
|
86
|
-
if (
|
|
99
|
+
if (sq_ring_needs_enter(ring, data->submit, &flags))
|
|
87
100
|
need_enter = true;
|
|
88
101
|
if (!need_enter)
|
|
89
102
|
break;
|
|
103
|
+
if (looped && data->has_ts) {
|
|
104
|
+
struct io_uring_getevents_arg *arg = data->arg;
|
|
105
|
+
|
|
106
|
+
if (!cqe && arg->ts && !err)
|
|
107
|
+
err = -ETIME;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
90
110
|
|
|
91
111
|
if (ring->int_flags & INT_FLAG_REG_RING)
|
|
92
112
|
flags |= IORING_ENTER_REGISTERED_RING;
|
|
93
|
-
ret =
|
|
94
|
-
|
|
95
|
-
|
|
113
|
+
ret = __sys_io_uring_enter2(ring->enter_ring_fd, data->submit,
|
|
114
|
+
data->wait_nr, flags, data->arg,
|
|
115
|
+
data->sz);
|
|
96
116
|
if (ret < 0) {
|
|
97
|
-
err
|
|
117
|
+
if (!err)
|
|
118
|
+
err = ret;
|
|
98
119
|
break;
|
|
99
120
|
}
|
|
100
121
|
|
|
101
122
|
data->submit -= ret;
|
|
102
123
|
if (cqe)
|
|
103
124
|
break;
|
|
104
|
-
looped
|
|
125
|
+
if (!looped) {
|
|
126
|
+
looped = true;
|
|
127
|
+
err = ret;
|
|
128
|
+
}
|
|
105
129
|
} while (1);
|
|
106
130
|
|
|
107
131
|
*cqe_ptr = cqe;
|
|
@@ -122,6 +146,15 @@ int __io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr,
|
|
|
122
146
|
return _io_uring_get_cqe(ring, cqe_ptr, &data);
|
|
123
147
|
}
|
|
124
148
|
|
|
149
|
+
int io_uring_get_events(struct io_uring *ring)
|
|
150
|
+
{
|
|
151
|
+
int flags = IORING_ENTER_GETEVENTS;
|
|
152
|
+
|
|
153
|
+
if (ring->int_flags & INT_FLAG_REG_RING)
|
|
154
|
+
flags |= IORING_ENTER_REGISTERED_RING;
|
|
155
|
+
return __sys_io_uring_enter(ring->enter_ring_fd, 0, 0, flags, NULL);
|
|
156
|
+
}
|
|
157
|
+
|
|
125
158
|
/*
|
|
126
159
|
* Fill in an array of IO completions up to count, if any are available.
|
|
127
160
|
* Returns the amount of IO completions filled.
|
|
@@ -131,37 +164,36 @@ unsigned io_uring_peek_batch_cqe(struct io_uring *ring,
|
|
|
131
164
|
{
|
|
132
165
|
unsigned ready;
|
|
133
166
|
bool overflow_checked = false;
|
|
167
|
+
int shift = 0;
|
|
168
|
+
|
|
169
|
+
if (ring->flags & IORING_SETUP_CQE32)
|
|
170
|
+
shift = 1;
|
|
134
171
|
|
|
135
172
|
again:
|
|
136
173
|
ready = io_uring_cq_ready(ring);
|
|
137
174
|
if (ready) {
|
|
138
175
|
unsigned head = *ring->cq.khead;
|
|
139
|
-
unsigned mask =
|
|
176
|
+
unsigned mask = ring->cq.ring_mask;
|
|
140
177
|
unsigned last;
|
|
141
178
|
int i = 0;
|
|
142
179
|
|
|
143
180
|
count = count > ready ? ready : count;
|
|
144
181
|
last = head + count;
|
|
145
182
|
for (;head != last; head++, i++)
|
|
146
|
-
cqes[i] = &ring->cq.cqes[head & mask];
|
|
183
|
+
cqes[i] = &ring->cq.cqes[(head & mask) << shift];
|
|
147
184
|
|
|
148
185
|
return count;
|
|
149
186
|
}
|
|
150
187
|
|
|
151
188
|
if (overflow_checked)
|
|
152
|
-
|
|
189
|
+
return 0;
|
|
153
190
|
|
|
154
191
|
if (cq_ring_needs_flush(ring)) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (ring->int_flags & INT_FLAG_REG_RING)
|
|
158
|
-
flags |= IORING_ENTER_REGISTERED_RING;
|
|
159
|
-
____sys_io_uring_enter(ring->enter_ring_fd, 0, 0, flags, NULL);
|
|
192
|
+
io_uring_get_events(ring);
|
|
160
193
|
overflow_checked = true;
|
|
161
194
|
goto again;
|
|
162
195
|
}
|
|
163
196
|
|
|
164
|
-
done:
|
|
165
197
|
return 0;
|
|
166
198
|
}
|
|
167
199
|
|
|
@@ -169,31 +201,21 @@ done:
|
|
|
169
201
|
* Sync internal state with kernel ring state on the SQ side. Returns the
|
|
170
202
|
* number of pending items in the SQ ring, for the shared ring.
|
|
171
203
|
*/
|
|
172
|
-
|
|
204
|
+
unsigned __io_uring_flush_sq(struct io_uring *ring)
|
|
173
205
|
{
|
|
174
206
|
struct io_uring_sq *sq = &ring->sq;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
ktail++;
|
|
188
|
-
sq->sqe_head++;
|
|
189
|
-
} while (--to_submit);
|
|
190
|
-
|
|
191
|
-
/*
|
|
192
|
-
* Ensure that the kernel sees the SQE updates before it sees the tail
|
|
193
|
-
* update.
|
|
194
|
-
*/
|
|
195
|
-
io_uring_smp_store_release(sq->ktail, ktail);
|
|
196
|
-
out:
|
|
207
|
+
unsigned tail = sq->sqe_tail;
|
|
208
|
+
|
|
209
|
+
if (sq->sqe_head != tail) {
|
|
210
|
+
sq->sqe_head = tail;
|
|
211
|
+
/*
|
|
212
|
+
* Ensure kernel sees the SQE updates before the tail update.
|
|
213
|
+
*/
|
|
214
|
+
if (!(ring->flags & IORING_SETUP_SQPOLL))
|
|
215
|
+
IO_URING_WRITE_ONCE(*sq->ktail, tail);
|
|
216
|
+
else
|
|
217
|
+
io_uring_smp_store_release(sq->ktail, tail);
|
|
218
|
+
}
|
|
197
219
|
/*
|
|
198
220
|
* This _may_ look problematic, as we're not supposed to be reading
|
|
199
221
|
* SQ->head without acquire semantics. When we're in SQPOLL mode, the
|
|
@@ -205,7 +227,7 @@ out:
|
|
|
205
227
|
* we can submit. The point is, we need to be able to deal with this
|
|
206
228
|
* situation regardless of any perceived atomicity.
|
|
207
229
|
*/
|
|
208
|
-
return
|
|
230
|
+
return tail - *sq->khead;
|
|
209
231
|
}
|
|
210
232
|
|
|
211
233
|
/*
|
|
@@ -214,7 +236,8 @@ out:
|
|
|
214
236
|
*/
|
|
215
237
|
static int io_uring_wait_cqes_new(struct io_uring *ring,
|
|
216
238
|
struct io_uring_cqe **cqe_ptr,
|
|
217
|
-
unsigned wait_nr,
|
|
239
|
+
unsigned wait_nr,
|
|
240
|
+
struct __kernel_timespec *ts,
|
|
218
241
|
sigset_t *sigmask)
|
|
219
242
|
{
|
|
220
243
|
struct io_uring_getevents_arg arg = {
|
|
@@ -226,6 +249,7 @@ static int io_uring_wait_cqes_new(struct io_uring *ring,
|
|
|
226
249
|
.wait_nr = wait_nr,
|
|
227
250
|
.get_flags = IORING_ENTER_EXT_ARG,
|
|
228
251
|
.sz = sizeof(arg),
|
|
252
|
+
.has_ts = ts != NULL,
|
|
229
253
|
.arg = &arg
|
|
230
254
|
};
|
|
231
255
|
|
|
@@ -249,7 +273,6 @@ static int io_uring_wait_cqes_new(struct io_uring *ring,
|
|
|
249
273
|
* hence this function is safe to use for applications that split SQ and CQ
|
|
250
274
|
* handling between two threads.
|
|
251
275
|
*/
|
|
252
|
-
|
|
253
276
|
static int __io_uring_submit_timeout(struct io_uring *ring, unsigned wait_nr,
|
|
254
277
|
struct __kernel_timespec *ts)
|
|
255
278
|
{
|
|
@@ -311,6 +334,7 @@ int io_uring_submit_and_wait_timeout(struct io_uring *ring,
|
|
|
311
334
|
.wait_nr = wait_nr,
|
|
312
335
|
.get_flags = IORING_ENTER_EXT_ARG,
|
|
313
336
|
.sz = sizeof(arg),
|
|
337
|
+
.has_ts = ts != NULL,
|
|
314
338
|
.arg = &arg
|
|
315
339
|
};
|
|
316
340
|
|
|
@@ -342,20 +366,21 @@ int io_uring_wait_cqe_timeout(struct io_uring *ring,
|
|
|
342
366
|
* Returns number of sqes submitted
|
|
343
367
|
*/
|
|
344
368
|
static int __io_uring_submit(struct io_uring *ring, unsigned submitted,
|
|
345
|
-
unsigned wait_nr)
|
|
369
|
+
unsigned wait_nr, bool getevents)
|
|
346
370
|
{
|
|
371
|
+
bool cq_needs_enter = getevents || wait_nr || cq_ring_needs_enter(ring);
|
|
347
372
|
unsigned flags;
|
|
348
373
|
int ret;
|
|
349
374
|
|
|
350
375
|
flags = 0;
|
|
351
|
-
if (sq_ring_needs_enter(ring, &flags) ||
|
|
352
|
-
if (
|
|
376
|
+
if (sq_ring_needs_enter(ring, submitted, &flags) || cq_needs_enter) {
|
|
377
|
+
if (cq_needs_enter)
|
|
353
378
|
flags |= IORING_ENTER_GETEVENTS;
|
|
354
379
|
if (ring->int_flags & INT_FLAG_REG_RING)
|
|
355
380
|
flags |= IORING_ENTER_REGISTERED_RING;
|
|
356
381
|
|
|
357
|
-
ret =
|
|
358
|
-
|
|
382
|
+
ret = __sys_io_uring_enter(ring->enter_ring_fd, submitted,
|
|
383
|
+
wait_nr, flags, NULL);
|
|
359
384
|
} else
|
|
360
385
|
ret = submitted;
|
|
361
386
|
|
|
@@ -364,7 +389,7 @@ static int __io_uring_submit(struct io_uring *ring, unsigned submitted,
|
|
|
364
389
|
|
|
365
390
|
static int __io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr)
|
|
366
391
|
{
|
|
367
|
-
return __io_uring_submit(ring, __io_uring_flush_sq(ring), wait_nr);
|
|
392
|
+
return __io_uring_submit(ring, __io_uring_flush_sq(ring), wait_nr, false);
|
|
368
393
|
}
|
|
369
394
|
|
|
370
395
|
/*
|
|
@@ -387,10 +412,17 @@ int io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr)
|
|
|
387
412
|
return __io_uring_submit_and_wait(ring, wait_nr);
|
|
388
413
|
}
|
|
389
414
|
|
|
415
|
+
int io_uring_submit_and_get_events(struct io_uring *ring)
|
|
416
|
+
{
|
|
417
|
+
return __io_uring_submit(ring, __io_uring_flush_sq(ring), 0, true);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
#ifdef LIBURING_INTERNAL
|
|
390
421
|
struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring)
|
|
391
422
|
{
|
|
392
423
|
return _io_uring_get_sqe(ring);
|
|
393
424
|
}
|
|
425
|
+
#endif
|
|
394
426
|
|
|
395
427
|
int __io_uring_sqring_wait(struct io_uring *ring)
|
|
396
428
|
{
|
|
@@ -399,5 +431,5 @@ int __io_uring_sqring_wait(struct io_uring *ring)
|
|
|
399
431
|
if (ring->int_flags & INT_FLAG_REG_RING)
|
|
400
432
|
flags |= IORING_ENTER_REGISTERED_RING;
|
|
401
433
|
|
|
402
|
-
return
|
|
434
|
+
return __sys_io_uring_enter(ring->enter_ring_fd, 0, 0, flags, NULL);
|
|
403
435
|
}
|