public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH 5.14] io_uring: use right task for exiting checks
@ 2021-07-10  1:45 Pavel Begunkov
  2021-07-10 13:40 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Pavel Begunkov @ 2021-07-10  1:45 UTC (permalink / raw)
  To: Jens Axboe, io-uring; +Cc: asml.silence

When we use delayed_work for fallback execution of requests, current
will be not of the submitter task, and so checks in io_req_task_submit()
may not behave as expected. Currently, it leaves inline completions not
flushed, so making io_ring_exit_work() to hang. Use the submitter task
for all those checks.

Cc: [email protected]
Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 7167c61c6d1b..770fdcd7d3e4 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2016,7 +2016,7 @@ static void io_req_task_submit(struct io_kiocb *req)
 
 	/* ctx stays valid until unlock, even if we drop all ours ctx->refs */
 	mutex_lock(&ctx->uring_lock);
-	if (!(current->flags & PF_EXITING) && !current->in_execve)
+	if (!(req->task->flags & PF_EXITING) && !req->task->in_execve)
 		__io_queue_sqe(req);
 	else
 		io_req_complete_failed(req, -EFAULT);
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 5.14] io_uring: use right task for exiting checks
  2021-07-10  1:45 [PATCH 5.14] io_uring: use right task for exiting checks Pavel Begunkov
@ 2021-07-10 13:40 ` Jens Axboe
  2021-07-10 14:07   ` Pavel Begunkov
  0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2021-07-10 13:40 UTC (permalink / raw)
  To: Pavel Begunkov; +Cc: io-uring, Pavel Begunkov (Silence)

On Fri, Jul 9, 2021 at 7:46 PM Pavel Begunkov <[email protected]> wrote:
>
> When we use delayed_work for fallback execution of requests, current
> will be not of the submitter task, and so checks in io_req_task_submit()
> may not behave as expected. Currently, it leaves inline completions not
> flushed, so making io_ring_exit_work() to hang. Use the submitter task
> for all those checks.
>
> Cc: [email protected]
> Signed-off-by: Pavel Begunkov <[email protected]>
> ---
>  fs/io_uring.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 7167c61c6d1b..770fdcd7d3e4 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -2016,7 +2016,7 @@ static void io_req_task_submit(struct io_kiocb *req)
>
>         /* ctx stays valid until unlock, even if we drop all ours ctx->refs */
>         mutex_lock(&ctx->uring_lock);
> -       if (!(current->flags & PF_EXITING) && !current->in_execve)
> +       if (!(req->task->flags & PF_EXITING) && !req->task->in_execve)
>                 __io_queue_sqe(req);
>         else
>                 io_req_complete_failed(req, -EFAULT);

I don't think that ->in_execve check is useful anymore now that we don't
have weak references to the files table, so it should probably just go
away.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 5.14] io_uring: use right task for exiting checks
  2021-07-10 13:40 ` Jens Axboe
@ 2021-07-10 14:07   ` Pavel Begunkov
  2021-07-10 15:36     ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Pavel Begunkov @ 2021-07-10 14:07 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring

On 7/10/21 2:40 PM, Jens Axboe wrote:
> On Fri, Jul 9, 2021 at 7:46 PM Pavel Begunkov <[email protected]> wrote:
>> When we use delayed_work for fallback execution of requests, current
>> will be not of the submitter task, and so checks in io_req_task_submit()
>> may not behave as expected. Currently, it leaves inline completions not
>> flushed, so making io_ring_exit_work() to hang. Use the submitter task
>> for all those checks.
>>
>> Cc: [email protected]
>> Signed-off-by: Pavel Begunkov <[email protected]>
>> ---
>>  fs/io_uring.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>> index 7167c61c6d1b..770fdcd7d3e4 100644
>> --- a/fs/io_uring.c
>> +++ b/fs/io_uring.c
>> @@ -2016,7 +2016,7 @@ static void io_req_task_submit(struct io_kiocb *req)
>>
>>         /* ctx stays valid until unlock, even if we drop all ours ctx->refs */
>>         mutex_lock(&ctx->uring_lock);
>> -       if (!(current->flags & PF_EXITING) && !current->in_execve)
>> +       if (!(req->task->flags & PF_EXITING) && !req->task->in_execve)
>>                 __io_queue_sqe(req);
>>         else
>>                 io_req_complete_failed(req, -EFAULT);
> 
> I don't think that ->in_execve check is useful anymore now that we don't
> have weak references to the files table, so it should probably just go
> away.

Had such a thought but from the premise that on exec we wait / cancel
all requests. But I'd rather to leave it to a separate commit for-next,
don't you think so?

-- 
Pavel Begunkov

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 5.14] io_uring: use right task for exiting checks
  2021-07-10 14:07   ` Pavel Begunkov
@ 2021-07-10 15:36     ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2021-07-10 15:36 UTC (permalink / raw)
  To: Pavel Begunkov; +Cc: io-uring

On 7/10/21 8:07 AM, Pavel Begunkov wrote:
> On 7/10/21 2:40 PM, Jens Axboe wrote:
>> On Fri, Jul 9, 2021 at 7:46 PM Pavel Begunkov <[email protected]> wrote:
>>> When we use delayed_work for fallback execution of requests, current
>>> will be not of the submitter task, and so checks in io_req_task_submit()
>>> may not behave as expected. Currently, it leaves inline completions not
>>> flushed, so making io_ring_exit_work() to hang. Use the submitter task
>>> for all those checks.
>>>
>>> Cc: [email protected]
>>> Signed-off-by: Pavel Begunkov <[email protected]>
>>> ---
>>>  fs/io_uring.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>>> index 7167c61c6d1b..770fdcd7d3e4 100644
>>> --- a/fs/io_uring.c
>>> +++ b/fs/io_uring.c
>>> @@ -2016,7 +2016,7 @@ static void io_req_task_submit(struct io_kiocb *req)
>>>
>>>         /* ctx stays valid until unlock, even if we drop all ours ctx->refs */
>>>         mutex_lock(&ctx->uring_lock);
>>> -       if (!(current->flags & PF_EXITING) && !current->in_execve)
>>> +       if (!(req->task->flags & PF_EXITING) && !req->task->in_execve)
>>>                 __io_queue_sqe(req);
>>>         else
>>>                 io_req_complete_failed(req, -EFAULT);
>>
>> I don't think that ->in_execve check is useful anymore now that we don't
>> have weak references to the files table, so it should probably just go
>> away.
> 
> Had such a thought but from the premise that on exec we wait / cancel
> all requests. But I'd rather to leave it to a separate commit for-next,
> don't you think so?

Yes, probably best left for for-next. I'll apply this one as-is, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-10 15:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-10  1:45 [PATCH 5.14] io_uring: use right task for exiting checks Pavel Begunkov
2021-07-10 13:40 ` Jens Axboe
2021-07-10 14:07   ` Pavel Begunkov
2021-07-10 15:36     ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox