public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jens Axboe <[email protected]>
To: Xuan Zhuo <[email protected]>,
	io-uring <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] io_uring: fix io_sq_thread no schedule when busy
Date: Mon, 22 Jun 2020 08:43:46 -0600	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <a932f437e5337cbfb42db660473fa55fa7aff9f6.1592805001.git.xuanzhuo@linux.alibaba.com>

On 6/21/20 11:50 PM, Xuan Zhuo wrote:
> 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 adds a check after io_submit_sqes. If io_sq_thread does not call
> cond_resched or schedule for more than HZ/2, it will call them.

This looks reasonable. It'd be easier if we could just cond_resched() after
the call unconditionally, but that would not drop the mm.

But maybe we can just drop the timeout and just rely on need_resched()
for this, ala the below?

diff --git a/fs/io_uring.c b/fs/io_uring.c
index c686061c3762..955d0765f302 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -6248,7 +6248,7 @@ static int io_sq_thread(void *data)
 		 * If submit got -EBUSY, flag us as needing the application
 		 * 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
 			 * long periods (or over schedule()). Do this before
@@ -6264,7 +6264,7 @@ static int io_sq_thread(void *data)
 			 * more IO, we should wait for the application to
 			 * 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 &&
 			    !percpu_ref_is_dying(&ctx->refs))) {
 				if (current->task_works)

-- 
Jens Axboe


      reply	other threads:[~2020-06-22 14:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-22  5:50 [PATCH] io_uring: fix io_sq_thread no schedule when busy Xuan Zhuo
2020-06-22 14:43 ` Jens Axboe [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox