Skip to content

Commit 3fd44c8

Browse files
Xiaoguang Wangaxboe
authored andcommitted
io_uring: use cond_resched() in io_ring_ctx_wait_and_kill()
While working on to make io_uring sqpoll mode support syscalls that need struct files_struct, I got cpu soft lockup in io_ring_ctx_wait_and_kill(), while (ctx->sqo_thread && !wq_has_sleeper(&ctx->sqo_wait)) cpu_relax(); above loop never has an chance to exit, it's because preempt isn't enabled in the kernel, and the context calling io_ring_ctx_wait_and_kill() and io_sq_thread() run in the same cpu, if io_sq_thread calls a cond_resched() yield cpu and another context enters above loop, then io_sq_thread() will always in runqueue and never exit. Use cond_resched() can fix this issue. Reported-by: [email protected] Signed-off-by: Xiaoguang Wang <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent dd461af commit 3fd44c8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/io_uring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7343,7 +7343,7 @@ static void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx)
73437343
* it could cause shutdown to hang.
73447344
*/
73457345
while (ctx->sqo_thread && !wq_has_sleeper(&ctx->sqo_wait))
7346-
cpu_relax();
7346+
cond_resched();
73477347

73487348
io_kill_timeouts(ctx);
73497349
io_poll_remove_all(ctx);

0 commit comments

Comments
 (0)