aboutsummaryrefslogtreecommitdiff
path: root/io_uring/io_uring.h
diff options
context:
space:
mode:
authorGravatar Jens Axboe <axboe@kernel.dk> 2024-02-14 12:59:36 -0700
committerGravatar Jens Axboe <axboe@kernel.dk> 2024-02-14 13:01:25 -0700
commit428f13826855e3eea44bf13cedbf33f382ef8794 (patch)
treef6d779f7ed0c23be2cf59ff90387b68f204be8c7 /io_uring/io_uring.h
parentio_uring: Don't include af_unix.h. (diff)
downloadlinux-428f13826855e3eea44bf13cedbf33f382ef8794.tar.gz
linux-428f13826855e3eea44bf13cedbf33f382ef8794.tar.bz2
linux-428f13826855e3eea44bf13cedbf33f382ef8794.zip
io_uring/napi: ensure napi polling is aborted when work is available
While testing io_uring NAPI with DEFER_TASKRUN, I ran into slowdowns and stalls in packet delivery. Turns out that while io_napi_busy_loop_should_end() aborts appropriately on regular task_work, it does not abort if we have local task_work pending. Move io_has_work() into the private io_uring.h header, and gate whether we should continue polling on that as well. This makes NAPI polling on send/receive work as designed with IORING_SETUP_DEFER_TASKRUN as well. Fixes: 8d0c12a80cde ("io-uring: add napi busy poll support") Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/io_uring.h')
-rw-r--r--io_uring/io_uring.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h
index 1ca99522811b..6426ee382276 100644
--- a/io_uring/io_uring.h
+++ b/io_uring/io_uring.h
@@ -448,4 +448,15 @@ static inline bool io_file_can_poll(struct io_kiocb *req)
}
return false;
}
+
+enum {
+ IO_CHECK_CQ_OVERFLOW_BIT,
+ IO_CHECK_CQ_DROPPED_BIT,
+};
+
+static inline bool io_has_work(struct io_ring_ctx *ctx)
+{
+ return test_bit(IO_CHECK_CQ_OVERFLOW_BIT, &ctx->check_cq) ||
+ !llist_empty(&ctx->work_llist);
+}
#endif