io_uring: add support for multishot timeouts
PATCH v3 1/1 io_uring: add support for multishot timeouts
A multishot timeout submission will repeatedly generate completions with the IORING_CQE_F_MORE cflag set. Depending on the value of the off' field in the submission, these timeouts can either repeat indefinitely until cancelled (off' = 0) or for a fixed number of times (`off' > 0).
Only noseq timeouts (i.e. not dependent on the number of I/O completions) are supported.
An indefinite timer will be cancelled with EOVERFLOW if the CQ ever overflows.
--- include/uapi/linux/io_uring.h | 1 + io_uring/timeout.c | 57 +++++++++++++++++++++++++++++++++-- 2 files changed, 55 insertions(+), 3 deletions(-)
include/uapi/linux/io_uring.h +1 -0
@@ -250,6 +250,7 @@ enum io_uring_op {#define IORING_TIMEOUT_REALTIME (1U << 3)#define IORING_LINK_TIMEOUT_UPDATE (1U << 4)#define IORING_TIMEOUT_ETIME_SUCCESS (1U << 5) +#define IORING_TIMEOUT_MULTISHOT (1U << 6)#define IORING_TIMEOUT_CLOCK_MASK (IORING_TIMEOUT_BOOTTIME | IORING_TIMEOUT_REALTIME)#define IORING_TIMEOUT_UPDATE_MASK (IORING_TIMEOUT_UPDATE | IORING_LINK_TIMEOUT_UPDATE)/*
io_uring/timeout.c +54 -3
97 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 13 lines · David Wei
A multishot timeout submission will repeatedly generate completions with the
IORING_CQE_F_MOREcflag set. Depending on the value of theoff' field in the submission, these timeouts can either repeat indefinitely until cancelled (off' = 0) or for a fixed number of times (`off' > 0).Only noseq timeouts (i.e. not dependent on the number of I/O completions) are supported.
An indefinite timer will be cancelled with EOVERFLOW if the CQ ever overflows.
Signed-off-by David Wei <[email protected]>
...
io_uring/timeout.c static inline void io_put_req(struct io_kiocb *req) · line 77
Quoted 10 lines
io_uring/timeout.c +10
-0+static void io_timeout_complete (struct io_kiocb *req,struct io_tw_state *ts) +{ + struct io_timeout *timeout = io_kiocb_to_cmd(req, struct io_timeout); +struct io_timeout_data *data = req->async_data; +struct io_ring_ctx *ctx = req->ctx; + +if (!io_timeout_finish (timeout, data)) { +bool filled; + filled =io_aux_cqe (ctx, false, req->cqe.user_data, -ETIME , +IORING_CQE_F_MORE , false);
I think that the defer parameter (the first false) might want to be ts->locked.
Hi Dylan! Good to see you :D
Quoted 18 lines · Dylan Yudaken
Quoted 1 line
Quoted 13 lines · David Wei
A multishot timeout submission will repeatedly generate completions with the
IORING_CQE_F_MOREcflag set. Depending on the value of theoff' field in the submission, these timeouts can either repeat indefinitely until cancelled (off' = 0) or for a fixed number of times (`off' > 0).Only noseq timeouts (i.e. not dependent on the number of I/O completions) are supported.
An indefinite timer will be cancelled with EOVERFLOW if the CQ ever overflows.
Signed-off-by David Wei <[email protected]>...
Quoted 12 lines
io_uring/timeout.c static inline void io_put_req(struct io_kiocb *req) · line 77
Quoted 10 lines
io_uring/timeout.c +10
-0+static void io_timeout_complete (struct io_kiocb *req,struct io_tw_state *ts) +{ + struct io_timeout *timeout = io_kiocb_to_cmd(req, struct io_timeout); +struct io_timeout_data *data = req->async_data; +struct io_ring_ctx *ctx = req->ctx; + +if (!io_timeout_finish (timeout, data)) { +bool filled; + filled =io_aux_cqe (ctx, false, req->cqe.user_data, -ETIME , +IORING_CQE_F_MORE , false);I think that the defer parameter (the first false) might want to be
ts->locked.
Ah you're right, thanks, will change!