public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Hao Xu <[email protected]>, Jens Axboe <[email protected]>
Cc: [email protected], Joseph Qi <[email protected]>
Subject: Re: [PATCH v3] io_uring: check kthread parked flag before sqthread goes to sleep
Date: Sun, 31 Jan 2021 15:45:53 +0000	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On 31/01/2021 14:39, Hao Xu wrote:
[...] 
> So check if sqthread gets park flag right before schedule().
> since ctx_list is always empty when this problem happens, here I put
> kthread_should_park() before setting the wakeup flag(ctx_list is empty
> so this for loop is fast), where is close enough to schedule(). The
> problem doesn't show again in my repro testing after this fix.
> 

Reviewed-by: Pavel Begunkov <[email protected]>

> Reported-by: Abaci <[email protected]>
> Signed-off-by: Hao Xu <[email protected]>
> ---
> 
> v1-->v2
> - tweak the commit message
> 
> v2-->v3
> - remove duplicate kthread_should_park() since thread parking is rare
> operation
> - put kthread_should_park() in if (needs_sched)
> 
> 
>  fs/io_uring.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index c07913ec0cca..d9019ce2bda0 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -7115,9 +7115,6 @@ static int io_sq_thread(void *data)
>  			continue;
>  		}
>  
> -		if (kthread_should_park())
> -			continue;
> -
>  		needs_sched = true;
>  		prepare_to_wait(&sqd->wait, &wait, TASK_INTERRUPTIBLE);
>  		list_for_each_entry(ctx, &sqd->ctx_list, sqd_list) {
> @@ -7132,7 +7129,7 @@ static int io_sq_thread(void *data)
>  			}
>  		}
>  
> -		if (needs_sched) {
> +		if (needs_sched && !kthread_should_park()) {
>  			list_for_each_entry(ctx, &sqd->ctx_list, sqd_list)
>  				io_ring_set_wakeup_flag(ctx);
>  
> 

-- 
Pavel Begunkov

       reply	other threads:[~2021-01-31 15:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <[email protected]>
2021-01-31 15:45 ` Pavel Begunkov [this message]
2021-01-31 21:46 ` [PATCH v3] io_uring: check kthread parked flag before sqthread goes to sleep Jens Axboe

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] \
    [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