Skip to content

Commit 53d69bd

Browse files
Olivier Langloisaxboe
authored andcommitted
io_uring/sqpoll: do the napi busy poll outside the submission block
there are many small reasons justifying this change. 1. busy poll must be performed even on rings that have no iopoll and no new sqe. It is quite possible that a ring configured for inbound traffic with multishot be several hours without receiving new request submissions 2. NAPI busy poll does not perform any credential validation 3. If the thread is awaken by task work, processing the task work is prioritary over NAPI busy loop. This is why a second loop has been created after the io_sq_tw() call instead of doing the busy loop in __io_sq_thread() outside its credential acquisition block. Signed-off-by: Olivier Langlois <[email protected]> Link: https://lore.kernel.org/r/de7679adf1249446bd47426db01d82b9603b7224.1726161831.git.olivier@trillion01.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 2f6a55e commit 53d69bd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

io_uring/sqpoll.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,6 @@ static int __io_sq_thread(struct io_ring_ctx *ctx, bool cap_entries)
196196
ret = io_submit_sqes(ctx, to_submit);
197197
mutex_unlock(&ctx->uring_lock);
198198

199-
if (io_napi(ctx))
200-
ret += io_napi_sqpoll_busy_poll(ctx);
201-
202199
if (to_submit && wq_has_sleeper(&ctx->sqo_sq_wait))
203200
wake_up(&ctx->sqo_sq_wait);
204201
if (creds)
@@ -323,6 +320,10 @@ static int io_sq_thread(void *data)
323320
if (io_sq_tw(&retry_list, IORING_TW_CAP_ENTRIES_VALUE))
324321
sqt_spin = true;
325322

323+
list_for_each_entry(ctx, &sqd->ctx_list, sqd_list)
324+
if (io_napi(ctx))
325+
io_napi_sqpoll_busy_poll(ctx);
326+
326327
if (sqt_spin || !time_after(jiffies, timeout)) {
327328
if (sqt_spin) {
328329
io_sq_update_worktime(sqd, &start);

0 commit comments

Comments
 (0)