public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: Re: [PATCH] io_uring: fix skipping disabling sqo on exec
Date: Sun, 17 Jan 2021 02:32:03 +0000	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On 17/01/2021 02:13, Jens Axboe wrote:
> On 1/16/21 4:37 PM, Pavel Begunkov wrote:
>> If there are no requests at the time __io_uring_task_cancel() is called,
>> tctx_inflight() returns zero and and it terminates not getting a chance
>> to go through __io_uring_files_cancel() and do
>> io_disable_sqo_submit(). And we absolutely want them disabled by the
>> time cancellation ends.
>>
>> Also a fix potential false positive warning because of ctx->sq_data
>> check before io_disable_sqo_submit().
>>
>> Reported-by: Jens Axboe <[email protected]>
>> Signed-off-by: Pavel Begunkov <[email protected]>
>> ---
>>
>> To not grow diffstat now will be cleaned for-next
>>
>>  fs/io_uring.c | 8 +++++++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>> index d494c4269fc5..0d50845f1f3f 100644
>> --- a/fs/io_uring.c
>> +++ b/fs/io_uring.c
>> @@ -8937,10 +8937,12 @@ static void io_uring_cancel_task_requests(struct io_ring_ctx *ctx,
>>  {
>>  	struct task_struct *task = current;
>>  
>> -	if ((ctx->flags & IORING_SETUP_SQPOLL) && ctx->sq_data) {
>> +	if (ctx->flags & IORING_SETUP_SQPOLL) {
>>  		/* for SQPOLL only sqo_task has task notes */
>>  		WARN_ON_ONCE(ctx->sqo_task != current);
>>  		io_disable_sqo_submit(ctx);
>> +	}
>> +	if ((ctx->flags & IORING_SETUP_SQPOLL) && ctx->sq_data) {
>>  		task = ctx->sq_data->thread;
>>  		atomic_inc(&task->io_uring->in_idle);
>>  		io_sq_thread_park(ctx->sq_data);
> 
> Maybe just nest that inside?
> 
> 	if (ctx->flags & IORING_SETUP_SQPOLL) {
>   		/* for SQPOLL only sqo_task has task notes */
>   		WARN_ON_ONCE(ctx->sqo_task != current);
>   		io_disable_sqo_submit(ctx);
> 		if (ctx->sq_data) {
> 			...
> 		}
> 	}
> 
> That'd look a bit cleaner imho.

second thought, it can't even happen because if not set we failed
during creation, and it has its own disable hooks.
sent v2 without that part

-- 
Pavel Begunkov

      reply	other threads:[~2021-01-17  2:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-16 23:37 [PATCH] io_uring: fix skipping disabling sqo on exec Pavel Begunkov
2021-01-17  2:13 ` Jens Axboe
2021-01-17  2:32   ` Pavel Begunkov [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] \
    /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