Skip to content

Commit f6d5425

Browse files
isilenceaxboe
authored andcommitted
io_uring: halt SQO submission on ctx exit
io_sq_thread_finish() is called in io_ring_ctx_free(), so SQPOLL task is potentially running submitting new requests. It's not a disaster because of using a "try" variant of percpu_ref_get, but is far from nice. Remove ctx from the sqd ctx list earlier, before cancellation loop, so SQPOLL can't find it and so won't submit new requests. Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 09a6f4e commit f6d5425

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/io_uring.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8564,6 +8564,14 @@ static void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx)
85648564
io_unregister_personality(ctx, index);
85658565
mutex_unlock(&ctx->uring_lock);
85668566

8567+
/* prevent SQPOLL from submitting new requests */
8568+
if (ctx->sq_data) {
8569+
io_sq_thread_park(ctx->sq_data);
8570+
list_del_init(&ctx->sqd_list);
8571+
io_sqd_update_thread_idle(ctx->sq_data);
8572+
io_sq_thread_unpark(ctx->sq_data);
8573+
}
8574+
85678575
io_kill_timeouts(ctx, NULL, NULL);
85688576
io_poll_remove_all(ctx, NULL, NULL);
85698577

0 commit comments

Comments
 (0)