History

io_uring: add timeout support for io_uring_enter()

Now users who want to get woken when waiting for events should submit a timeout command first. It is not safe for applications that split SQ and CQ handling between two threads, such as mysql. Users should synchronize the two threads explicitly to protect SQ and that will impact the performance. This patch adds support for timeout to existing io_uring_enter(). To avoid overloading arguments, it introduces a new parameter structure which contains sigmask and timeout. I have tested the workloads with one thread submiting nop requests while the other reaping the cqe with timeout. It shows 1.8~2x faster when the iodepth is 16.

Hao Xu committed 6 years ago

Commit c73ebb61 parent 27926b63 files · +72 −8Browse files

Showing the changes to include/uapi (1 of 3 files). Show all

Unified · Split

include/uapi/linux/io_uring.h+9−0
@@ -231,6 +231,7 @@ struct io_cqring_offsets { · 230 unmodified lines
231#define IORING_ENTER_GETEVENTS (1U << 0)231#define IORING_ENTER_GETEVENTS (1U << 0)
232#define IORING_ENTER_SQ_WAKEUP (1U << 1)232#define IORING_ENTER_SQ_WAKEUP (1U << 1)
233#define IORING_ENTER_SQ_WAIT (1U << 2)233#define IORING_ENTER_SQ_WAIT (1U << 2)
234#define IORING_ENTER_EXT_ARG (1U << 3)
234 235
235/*236/*
236 * Passed in for io_uring_setup(2). Copied back with updated info on success237 * Passed in for io_uring_setup(2). Copied back with updated info on success
@@ -259,6 +260,7 @@ struct io_uring_params { · 22 unmodified lines
259#define IORING_FEAT_FAST_POLL (1U << 5)260#define IORING_FEAT_FAST_POLL (1U << 5)
260#define IORING_FEAT_POLL_32BITS (1U << 6)261#define IORING_FEAT_POLL_32BITS (1U << 6)
261#define IORING_FEAT_SQPOLL_NONFIXED (1U << 7)262#define IORING_FEAT_SQPOLL_NONFIXED (1U << 7)
263#define IORING_FEAT_EXT_ARG (1U << 8)
262 264
263/*265/*
264 * io_uring_register(2) opcodes and arguments266 * io_uring_register(2) opcodes and arguments
@@ -335,4 +337,11 @@ enum { · 70 unmodified lines
335 IORING_RESTRICTION_LAST337 IORING_RESTRICTION_LAST
336};338};
337 339
340struct io_uring_getevents_arg {
341 __u64 sigmask;
342 __u32 sigmask_sz;
343 __u32 pad;
344 __u64 ts;
345};
346
338#endif347#endif