aboutsummaryrefslogtreecommitdiff
path: root/io_uring/napi.c
diff options
context:
space:
mode:
authorGravatar Stefan Roesch <shr@devkernel.io> 2023-06-08 09:38:37 -0700
committerGravatar Jens Axboe <axboe@kernel.dk> 2024-02-09 11:54:28 -0700
commitff183d427da0a733b0dbe11bd7acaf2dcb37b4cc (patch)
tree608885d59ca17fa553a9a9c9edfae6776b63545b /io_uring/napi.c
parentio-uring: add napi busy poll support (diff)
downloadlinux-ff183d427da0a733b0dbe11bd7acaf2dcb37b4cc.tar.gz
linux-ff183d427da0a733b0dbe11bd7acaf2dcb37b4cc.tar.bz2
linux-ff183d427da0a733b0dbe11bd7acaf2dcb37b4cc.zip
io-uring: add sqpoll support for napi busy poll
This adds the sqpoll support to the io-uring napi. Signed-off-by: Stefan Roesch <shr@devkernel.io> Suggested-by: Olivier Langlois <olivier@trillion01.com> Link: https://lore.kernel.org/r/20230608163839.2891748-6-shr@devkernel.io Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/napi.c')
-rw-r--r--io_uring/napi.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/io_uring/napi.c b/io_uring/napi.c
index 1112cc39153c..3e578df36cc5 100644
--- a/io_uring/napi.c
+++ b/io_uring/napi.c
@@ -252,4 +252,28 @@ void __io_napi_busy_loop(struct io_ring_ctx *ctx, struct io_wait_queue *iowq)
io_napi_blocking_busy_loop(ctx, iowq);
}
+/*
+ * io_napi_sqpoll_busy_poll() - busy poll loop for sqpoll
+ * @ctx: pointer to io-uring context structure
+ *
+ * Splice of the napi list and execute the napi busy poll loop.
+ */
+int io_napi_sqpoll_busy_poll(struct io_ring_ctx *ctx)
+{
+ LIST_HEAD(napi_list);
+ bool is_stale = false;
+
+ if (!READ_ONCE(ctx->napi_busy_poll_to))
+ return 0;
+ if (list_empty_careful(&ctx->napi_list))
+ return 0;
+
+ rcu_read_lock();
+ is_stale = __io_napi_do_busy_loop(ctx, NULL);
+ rcu_read_unlock();
+
+ io_napi_remove_stale(ctx, is_stale);
+ return 1;
+}
+
#endif