提交 73cef744 编写于 作者: X Xuan Zhuo 提交者: Caspar Zhang

io_uring: fix io_sq_thread no schedule when busy

fix #27804498

commit b772f07add1c0b22e02c0f1e96f647560679d3a9 upstream

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: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NXuan Zhuo <xuanzhuo@linux.alibaba.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Reviewed-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
上级 711d6b90
...@@ -5999,7 +5999,7 @@ static int io_sq_thread(void *data) ...@@ -5999,7 +5999,7 @@ static int io_sq_thread(void *data)
* If submit got -EBUSY, flag us as needing the application * If submit got -EBUSY, flag us as needing the application
* to enter the kernel to reap and flush events. * to enter the kernel to reap and flush events.
*/ */
if (!to_submit || ret == -EBUSY) { if (!to_submit || ret == -EBUSY || need_resched()) {
/* /*
* Drop cur_mm before scheduling, we can't hold it for * Drop cur_mm before scheduling, we can't hold it for
* long periods (or over schedule()). Do this before * long periods (or over schedule()). Do this before
...@@ -6015,7 +6015,7 @@ static int io_sq_thread(void *data) ...@@ -6015,7 +6015,7 @@ static int io_sq_thread(void *data)
* more IO, we should wait for the application to * more IO, we should wait for the application to
* reap events and wake us up. * reap events and wake us up.
*/ */
if (!list_empty(&ctx->poll_list) || if (!list_empty(&ctx->poll_list) || need_resched() ||
(!time_after(jiffies, timeout) && ret != -EBUSY && (!time_after(jiffies, timeout) && ret != -EBUSY &&
!percpu_ref_is_dying(&ctx->refs))) { !percpu_ref_is_dying(&ctx->refs))) {
if (current->task_works) if (current->task_works)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册