Skip to content

Commit b772f07

Browse files
fengidriaxboe
authored andcommitted
io_uring: fix io_sq_thread no schedule when busy
When the user consumes and generates sqe at a fast rate, io_sqring_entries can always get sqe, and ret will not be equal to -EBUSY, so that io_sq_thread will never call cond_resched or schedule, and then we will get the following system error prompt: rcu: INFO: rcu_sched self-detected stall on CPU or watchdog: BUG: soft lockup-CPU#23 stuck for 112s! [io_uring-sq:1863] This patch checks whether need to call cond_resched() by checking the need_resched() function every cycle. Suggested-by: Jens Axboe <[email protected]> Signed-off-by: Xuan Zhuo <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 4877846 commit b772f07

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/io_uring.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6011,7 +6011,7 @@ static int io_sq_thread(void *data)
60116011
* If submit got -EBUSY, flag us as needing the application
60126012
* to enter the kernel to reap and flush events.
60136013
*/
6014-
if (!to_submit || ret == -EBUSY) {
6014+
if (!to_submit || ret == -EBUSY || need_resched()) {
60156015
/*
60166016
* Drop cur_mm before scheduling, we can't hold it for
60176017
* long periods (or over schedule()). Do this before
@@ -6027,7 +6027,7 @@ static int io_sq_thread(void *data)
60276027
* more IO, we should wait for the application to
60286028
* reap events and wake us up.
60296029
*/
6030-
if (!list_empty(&ctx->poll_list) ||
6030+
if (!list_empty(&ctx->poll_list) || need_resched() ||
60316031
(!time_after(jiffies, timeout) && ret != -EBUSY &&
60326032
!percpu_ref_is_dying(&ctx->refs))) {
60336033
if (current->task_works)

0 commit comments

Comments
 (0)