All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kanchan Joshi <joshi.k@samsung.com>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>, io-uring@vger.kernel.org
Subject: Re: [PATCH] io_uring: complete request via task work in case of DEFER_TASKRUN
Date: Fri, 14 Apr 2023 17:22:38 +0530	[thread overview]
Message-ID: <20230414115238.GB5049@green5> (raw)
In-Reply-To: <20230414075313.373263-1-ming.lei@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1902 bytes --]

On Fri, Apr 14, 2023 at 03:53:13PM +0800, Ming Lei wrote:
>So far io_req_complete_post() only covers DEFER_TASKRUN by completing
>request via task work when the request is completed from IOWQ.
>
>However, uring command could be completed from any context, and if io
>uring is setup with DEFER_TASKRUN, the command is required to be
>completed from current context, otherwise wait on IORING_ENTER_GETEVENTS
>can't be wakeup, and may hang forever.
>
>The issue can be observed on removing ublk device, but turns out it is
>one generic issue for uring command & DEFER_TASKRUN, so solve it in
>io_uring core code.

Thanks for sharing, this has been fine for nvme-passthrough side though.
We usually test with DEFER_TASKRUN option, as both fio and t/io_uring
set the option.

>Link: https://lore.kernel.org/linux-block/b3fc9991-4c53-9218-a8cc-5b4dd3952108@kernel.dk/
>Reported-by: Jens Axboe <axboe@kernel.dk>
>Cc: Kanchan Joshi <joshi.k@samsung.com>
>Signed-off-by: Ming Lei <ming.lei@redhat.com>
>---
> io_uring/io_uring.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
>index 9083a8466ebf..9f6f92ed60b2 100644
>--- a/io_uring/io_uring.c
>+++ b/io_uring/io_uring.c
>@@ -1012,7 +1012,7 @@ static void __io_req_complete_post(struct io_kiocb *req, unsigned issue_flags)
>
> void io_req_complete_post(struct io_kiocb *req, unsigned issue_flags)
> {
>-	if (req->ctx->task_complete && (issue_flags & IO_URING_F_IOWQ)) {
>+	if (req->ctx->task_complete && req->ctx->submitter_task != current) {
> 		req->io_task_work.func = io_req_task_complete;
> 		io_req_task_work_add(req);

In nvme-side, we always complete in task context, so this seems bit hard
to produce.
But this patch ensures that task-work is setup if it is needed, and
caller/driver did not get to set that explicitly. So looks fine to me.
FWIW, I do not see regression in nvme tests.

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



  reply	other threads:[~2023-04-14 11:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230414075422epcas5p3ae5de53e643a448f19df82a7a1d5cd1c@epcas5p3.samsung.com>
2023-04-14  7:53 ` [PATCH] io_uring: complete request via task work in case of DEFER_TASKRUN Ming Lei
2023-04-14 11:52   ` Kanchan Joshi [this message]
2023-04-14 12:39   ` Jens Axboe
2023-04-14 13:01   ` Pavel Begunkov
2023-04-14 13:53     ` Ming Lei
2023-04-14 14:13       ` Kanchan Joshi
2023-04-14 14:53         ` Ming Lei
2023-04-14 15:07       ` Pavel Begunkov
2023-04-14 15:42         ` Ming Lei
2023-04-15 23:15           ` Pavel Begunkov
2023-04-16 10:05             ` Ming Lei

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 \
    --in-reply-to=20230414115238.GB5049@green5 \
    --to=joshi.k@samsung.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.