Skip to content

Commit

Permalink
io_uring: reap poll completions while waiting for refs to drop on exit
Browse files Browse the repository at this point in the history
If we're doing polled IO and end up having requests being submitted
async, then completions can come in while we're waiting for refs to
drop. We need to reap these manually, as nobody else will be looking
for them.

Break the wait into 1/20th of a second time waits, and check for done
poll completions if we time out. Otherwise we can have done poll
completions sitting in ctx->poll_list, which needs us to reap them but
we're just waiting for them.

Cc: [email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Jun 17, 2020
1 parent 9d8426a commit 56952e9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -7363,7 +7363,17 @@ static void io_ring_exit_work(struct work_struct *work)
if (ctx->rings)
io_cqring_overflow_flush(ctx, true);

wait_for_completion(&ctx->ref_comp);
/*
* If we're doing polled IO and end up having requests being
* submitted async (out-of-line), then completions can come in while
* we're waiting for refs to drop. We need to reap these manually,
* as nobody else will be looking for them.
*/
while (!wait_for_completion_timeout(&ctx->ref_comp, HZ/20)) {
io_iopoll_reap_events(ctx);
if (ctx->rings)
io_cqring_overflow_flush(ctx, true);
}
io_ring_ctx_free(ctx);
}

Expand Down

0 comments on commit 56952e9

Please sign in to comment.