io_uring/napi: refactor __io_napi_busy_loop()
authorPavel Begunkov <asml.silence@gmail.com>
Wed, 7 Aug 2024 14:18:11 +0000 (15:18 +0100)
committerJens Axboe <axboe@kernel.dk>
Sun, 25 Aug 2024 14:27:01 +0000 (08:27 -0600)
we don't need to set ->napi_prefer_busy_poll if we're not going to poll,
do the checks first and all polling preparation after.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/2ad7ede8cc7905328fc62e8c3805fdb11635ae0b.1723039801.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/napi.c

index 1de1d4d629254c13af841d96c6019c0545ab53f8..64fbbceba980081dbe3727dddcce2f6e0bddc259 100644 (file)
@@ -299,10 +299,11 @@ void __io_napi_adjust_timeout(struct io_ring_ctx *ctx, struct io_wait_queue *iow
  */
 void __io_napi_busy_loop(struct io_ring_ctx *ctx, struct io_wait_queue *iowq)
 {
-       iowq->napi_prefer_busy_poll = READ_ONCE(ctx->napi_prefer_busy_poll);
+       if (ctx->flags & IORING_SETUP_SQPOLL)
+               return;
 
-       if (!(ctx->flags & IORING_SETUP_SQPOLL))
-               io_napi_blocking_busy_loop(ctx, iowq);
+       iowq->napi_prefer_busy_poll = READ_ONCE(ctx->napi_prefer_busy_poll);
+       io_napi_blocking_busy_loop(ctx, iowq);
 }
 
 /*