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.
Showing the changes to include/uapi (1 of 3 files). Show all
Unified · Split
| @@ -231,6 +231,7 @@ struct io_cqring_offsets { · 230 unmodified lines | ||
| 231 | 231 | #define IORING_ENTER_GETEVENTS (1U << 0) |
| 232 | 232 | #define IORING_ENTER_SQ_WAKEUP (1U << 1) |
| 233 | 233 | #define IORING_ENTER_SQ_WAIT (1U << 2) |
| 234 | +#define IORING_ENTER_EXT_ARG (1U << 3) | |
| 234 | 235 | |
| 235 | 236 | /* |
| 236 | 237 | * 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 | 260 | #define IORING_FEAT_FAST_POLL (1U << 5) |
| 260 | 261 | #define IORING_FEAT_POLL_32BITS (1U << 6) |
| 261 | 262 | #define IORING_FEAT_SQPOLL_NONFIXED (1U << 7) |
| 263 | +#define IORING_FEAT_EXT_ARG (1U << 8) | |
| 262 | 264 | |
| 263 | 265 | /* |
| 264 | 266 | * io_uring_register(2) opcodes and arguments |
| @@ -335,4 +337,11 @@ enum { · 70 unmodified lines | ||
| 335 | 337 | IORING_RESTRICTION_LAST |
| 336 | 338 | }; |
| 337 | 339 | |
| 340 | +struct io_uring_getevents_arg { | |
| 341 | + __u64 sigmask; | |
| 342 | + __u32 sigmask_sz; | |
| 343 | + __u32 pad; | |
| 344 | + __u64 ts; | |
| 345 | +}; | |
| 346 | + | |
| 338 | 347 | #endif |