io_uring_sub..._min_timeout(3)
β¨ NAME β¨
io_uring_submit_and_wait_min_timeout β bestie, this one submits requests to the submission queue and then waits for the completion, and it's got both a batch timeout and a normal timeout. Two timeouts. Iconic.
π SYNOPSIS π
#include <liburing.h>
int io_uring_submit_and_wait_min_timeout(struct io_uring *ring,
struct io_uring_cqe **cqe_ptr,
unsigned wait_nr,
struct __kernel_timespec *ts,
unsigned int min_wait_usec,
sigset_t *sigmask);
π DESCRIPTION π
okay so. The io_uring_submit_and_wait_min_timeout(3) function submits the next requests from the submission queue belonging to the ring, and then it waits for wait_nr completion events, or until the timeout ts expires β whichever comes first, bestie. The completion events get stashed in the cqe_ptr array. And if min_wait_usec is non-zero, that's a timeout for the wait_nr batch. π
The sigmask specifies the set of signals to block. If it's set, it's equivalent to atomically executing these calls right here:
sigset_t origmask;
pthread_sigmask(SIG_SETMASK, &sigmask, &origmask);
ret = io_uring_submit_and_wait_min_timeout(ring, cqe, wait_nr, ts, min_wait, NULL);
pthread_sigmask(SIG_SETMASK, &origmask, NULL);
So here's the twist, and it's giving main character energy: this works like io_uring_submit_and_wait_timeout(3), except it applies a minimum timeout for the requested batch size of requests to wait for. Let me break it down fr fr.
io_uring_submit_and_wait_timeout(3) waits for as long as ts says, or until wait_nr request completions have been received. But if min_wait_usec is set, then that is the timeout for the wait_nr number of requests. Here's the whole vibe check:
- If the requested number of completions have been received within
min_wait_usecnumber of microseconds β the function returns successfully. π - If that isn't the case β once
min_wait_usectime has passed, control is returned if any completions have been posted. - If no completions have been posted β the kernel switches to a normal wait of up to
tsspecified amount of time, subtracting the time already waited. - If any completions are posted after this happens β control is returned immediately to the application. π«Ά
This differs from the normal timeout waiting in that waiting continues post the initial timeout, if and only if no completions have been posted. It's meant to be used to optimize batch waiting for requests, where the application allots a budget of min_wait_usec amount of time to receive wait_nr number of completions, but if none are received, then waiting can continue without incurring extra context switches or extra kernel/user transitions. no cap, that's the whole point. π₯
Can be used with any ring, as long as the kernel supports it. Support is indicated by checking the IORING_FEAT_MIN_TIMEOUT feature flag after the ring has been setup. Ideally used with a ring setup with IORING_SETUP_SINGLE_ISSUER|IORING_SETUP_DEFER_TASKRUN, because that will greatly reduce the number of context switches that an application will see waiting on multiple requests. π
Available since 6.12. π¦
β RETURN VALUE β
On success, io_uring_submit_and_wait_min_timeout(3) returns the number of submitted submission queue entries. On failure it returns -errno. If the kernel doesn't support this functionality, -EINVAL will be returned β see the note on the feature flag, bestie. π
The most common failure case is not receiving a completion within the specified timeout, and -ETIME is returned in this case. π
πΈ SEE ALSO πΈ
io_uring_queue_init_params(3)io_uring_get_sqe(3)io_uring_submit(3)io_uring_submit_and_wait(3)io_uring_submit_and_wait_timeout(3)io_uring_wait_cqe(3)
and that's the whole page, bestie π this lil beauty lives in liburing-2.8, dated Jan 11, 2024, and it's a total slay. go forth and wait on your completions responsibly. β¨ππ¦
π¦ where this page comes from
- alpine 3.22: liburing-doc 2.9-r0 Β· LGPL-2.1-or-later OR MIT
- alpine 3.23: liburing-doc 2.12-r0 Β· LGPL-2.1-or-later OR MIT
- alpine 3.24: liburing-doc 2.14-r0 Β· LGPL-2.1-or-later OR MIT
- arch rolling: liburing 2.15-1 Β· GPL-2.0-only WITH Linux-syscall-note OR MIT AND LGPL-2.0-or-later AND MIT
- centos-stream 10: liburing-devel 2.12-1.el10 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- centos-stream 9: liburing-devel 2.12-1.el9 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- centos-stream 9: liburing-devel 2.12-1.el9 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- debian trixie: liburing-dev 2.9-1
- fedora 43: liburing-devel 2.9-2.fc43 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 43: liburing-devel 2.9-2.fc43 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 44: liburing-devel 2.13-2.fc44 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 44: liburing-devel 2.13-2.fc44 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- nixpkgs unstable: liburing 2.14
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- ubuntu questing: liburing-dev 2.11-1
- ubuntu resolute: liburing-dev 2.14-1
- ubuntu stonking: liburing-dev 2.15-1
- π the page's license: LGPL-2.0-or-later
- Copyright (C) 2024 Jens Axboe <axboe@kernel.dk>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms