Skip to content

Commit 8f487ef

Browse files
isilenceaxboe
authored andcommitted
io_uring: mitigate unlikely iopoll lag
We have requests like IORING_OP_FILES_UPDATE that don't go through ->iopoll_list but get completed in place under ->uring_lock, and so after dropping the lock io_iopoll_check() should expect that some CQEs might have get completed in a meanwhile. Currently such events won't be accounted in @nr_events, and the loop will continue to poll even if there is enough of CQEs. It shouldn't be a problem as it's not likely to happen and so, but not nice either. Just return earlier in this case, it should be enough. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/66ef932cc66a34e3771bbae04b2953a8058e9d05.1625747741.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent c32aace commit 8f487ef

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

fs/io_uring.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2356,11 +2356,15 @@ static int io_iopoll_check(struct io_ring_ctx *ctx, long min)
23562356
* very same mutex.
23572357
*/
23582358
if (list_empty(&ctx->iopoll_list)) {
2359+
u32 tail = ctx->cached_cq_tail;
2360+
23592361
mutex_unlock(&ctx->uring_lock);
23602362
io_run_task_work();
23612363
mutex_lock(&ctx->uring_lock);
23622364

2363-
if (list_empty(&ctx->iopoll_list))
2365+
/* some requests don't go through iopoll_list */
2366+
if (tail != ctx->cached_cq_tail ||
2367+
list_empty(&ctx->iopoll_list))
23642368
break;
23652369
}
23662370
ret = io_do_iopoll(ctx, &nr_events, min);

0 commit comments

Comments
 (0)