| 1 | |
| 2 | #ifndef IOU_WAIT_H
|
| 3 | #define IOU_WAIT_H
|
| 4 |
|
| 5 | #include <linux/io_uring_types.h>
|
| 6 |
|
| 7 | |
| 8 | * ->cq_wait_nr is armed with the number of lazy task_work adds the waiter
|
| 9 | * still needs, and counted down by the add side, with the add reaching zero
|
| 10 | * issuing the (single) wake up for this wait cycle. Zero and below means no
|
| 11 | * wake up is to be issued: IO_CQ_WAKE_INIT when no task is waiting (also
|
| 12 | * what a forced wake up resets it to when claiming one), zero once the
|
| 13 | * countdown has fired.
|
| 14 |
|
| 15 | #define IO_CQ_WAKE_INIT (-1)
|
| 16 |
|
| 17 | struct ext_arg {
|
| 18 | size_t argsz;
|
| 19 | struct timespec64 ts;
|
| 20 | const sigset_t __user *sig;
|
| 21 | ktime_t min_time;
|
| 22 | bool ts_set;
|
| 23 | bool iowait;
|
| 24 | };
|
| 25 |
|
| 26 | int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, u32 flags,
|
| 27 | struct ext_arg *ext_arg);
|
| 28 | int io_run_task_work_sig(struct io_ring_ctx *ctx);
|
| 29 | void io_cqring_do_overflow_flush(struct io_ring_ctx *ctx);
|
| 30 | void io_cqring_overflow_flush_locked(struct io_ring_ctx *ctx);
|
| 31 |
|
| 32 | static inline unsigned int __io_cqring_events(struct io_ring_ctx *ctx)
|
| 33 | {
|
| 34 | struct io_rings *rings = io_get_rings(ctx);
|
| 35 | return ctx->cached_cq_tail - READ_ONCE(rings->cq.head);
|
| 36 | }
|
| 37 |
|
| 38 | static inline unsigned int __io_cqring_events_user(struct io_ring_ctx *ctx)
|
| 39 | {
|
| 40 | struct io_rings *rings = io_get_rings(ctx);
|
| 41 |
|
| 42 | return READ_ONCE(rings->cq.tail) - READ_ONCE(rings->cq.head);
|
| 43 | }
|
| 44 |
|
| 45 | |
| 46 | * Reads the tail/head of the CQ ring while providing an acquire ordering,
|
| 47 | * see comment at top of io_uring.c.
|
| 48 |
|
| 49 | static inline unsigned io_cqring_events(struct io_ring_ctx *ctx)
|
| 50 | {
|
| 51 | smp_rmb();
|
| 52 | return __io_cqring_events(ctx);
|
| 53 | }
|
| 54 |
|
| 55 | #endif
|