Linux-Block Archive mirror
 help / color / mirror / Atom feed
* [PATCH] blk-mq: fix two misuses on RQF_USE_SCHED
@ 2023-06-24 13:01 Ming Lei
  2023-06-25  8:31 ` Guangwu Zhang
  2023-06-25 14:01 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Ming Lei @ 2023-06-24 13:01 UTC (permalink / raw
  To: Jens Axboe; +Cc: linux-block, Ming Lei, Guangwu Zhang, Christoph Hellwig

Request allocated from sched tags can't be issued via ->queue_rqs()
directly, since driver tag isn't allocated yet. This is the 1st misuse
of RQF_USE_SCHED for figuring out plug->has_elevator.

Request allocated from sched tags can't be ended by
blk_mq_end_request_batch() too, fix the 2nd RQF_USE_SCHED misuse
in blk_mq_add_to_batch().

Without this patch, NVMe uring cmd passthrough IO workload can run into
hang easily with real io scheduler.

Fixes: dd6216bb16e8 ("blk-mq: make sure elevator callbacks aren't called for passthrough request")
Reported-by: Guangwu Zhang <guazhang@redhat.com>
Closes: https://lore.kernel.org/linux-block/CAGS2=YrBjpLPOKa-gzcKuuOG60AGth5794PNCDwatdnnscB9ug@mail.gmail.com/
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/blk-mq.c         | 6 +++++-
 include/linux/blk-mq.h | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 1628873d7587..0aba08a9ded6 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1302,7 +1302,11 @@ static void blk_add_rq_to_plug(struct blk_plug *plug, struct request *rq)
 
 	if (!plug->multiple_queues && last && last->q != rq->q)
 		plug->multiple_queues = true;
-	if (!plug->has_elevator && (rq->rq_flags & RQF_USE_SCHED))
+	/*
+	 * Any request allocated from sched tags can't be issued to
+	 * ->queue_rqs() directly
+	 */
+	if (!plug->has_elevator && (rq->rq_flags & RQF_SCHED_TAGS))
 		plug->has_elevator = true;
 	rq->rq_next = NULL;
 	rq_list_add(&plug->mq_list, rq);
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index fa265e85d753..12103d5654f5 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -852,7 +852,11 @@ static inline bool blk_mq_add_to_batch(struct request *req,
 				       struct io_comp_batch *iob, int ioerror,
 				       void (*complete)(struct io_comp_batch *))
 {
-	if (!iob || (req->rq_flags & RQF_USE_SCHED) || ioerror ||
+	/*
+	 * blk_mq_end_request_batch() can't end request allocated from
+	 * sched tags
+	 */
+	if (!iob || (req->rq_flags & RQF_SCHED_TAGS) || ioerror ||
 			(req->end_io && !blk_rq_is_passthrough(req)))
 		return false;
 
-- 
2.40.1


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

* Re: [PATCH] blk-mq: fix two misuses on RQF_USE_SCHED
  2023-06-24 13:01 [PATCH] blk-mq: fix two misuses on RQF_USE_SCHED Ming Lei
@ 2023-06-25  8:31 ` Guangwu Zhang
  2023-06-25 14:01 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Guangwu Zhang @ 2023-06-25  8:31 UTC (permalink / raw
  To: Ming Lei; +Cc: Jens Axboe, linux-block, Christoph Hellwig

Hi, Ming
Could not hit the error after apply your patch. good job!

Ming Lei <ming.lei@redhat.com> 于2023年6月24日周六 21:01写道:

>
> Request allocated from sched tags can't be issued via ->queue_rqs()
> directly, since driver tag isn't allocated yet. This is the 1st misuse
> of RQF_USE_SCHED for figuring out plug->has_elevator.
>
> Request allocated from sched tags can't be ended by
> blk_mq_end_request_batch() too, fix the 2nd RQF_USE_SCHED misuse
> in blk_mq_add_to_batch().
>
> Without this patch, NVMe uring cmd passthrough IO workload can run into
> hang easily with real io scheduler.
>
> Fixes: dd6216bb16e8 ("blk-mq: make sure elevator callbacks aren't called for passthrough request")
> Reported-by: Guangwu Zhang <guazhang@redhat.com>
> Closes: https://lore.kernel.org/linux-block/CAGS2=YrBjpLPOKa-gzcKuuOG60AGth5794PNCDwatdnnscB9ug@mail.gmail.com/
> Cc: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
>  block/blk-mq.c         | 6 +++++-
>  include/linux/blk-mq.h | 6 +++++-
>  2 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 1628873d7587..0aba08a9ded6 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -1302,7 +1302,11 @@ static void blk_add_rq_to_plug(struct blk_plug *plug, struct request *rq)
>
>         if (!plug->multiple_queues && last && last->q != rq->q)
>                 plug->multiple_queues = true;
> -       if (!plug->has_elevator && (rq->rq_flags & RQF_USE_SCHED))
> +       /*
> +        * Any request allocated from sched tags can't be issued to
> +        * ->queue_rqs() directly
> +        */
> +       if (!plug->has_elevator && (rq->rq_flags & RQF_SCHED_TAGS))
>                 plug->has_elevator = true;
>         rq->rq_next = NULL;
>         rq_list_add(&plug->mq_list, rq);
> diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
> index fa265e85d753..12103d5654f5 100644
> --- a/include/linux/blk-mq.h
> +++ b/include/linux/blk-mq.h
> @@ -852,7 +852,11 @@ static inline bool blk_mq_add_to_batch(struct request *req,
>                                        struct io_comp_batch *iob, int ioerror,
>                                        void (*complete)(struct io_comp_batch *))
>  {
> -       if (!iob || (req->rq_flags & RQF_USE_SCHED) || ioerror ||
> +       /*
> +        * blk_mq_end_request_batch() can't end request allocated from
> +        * sched tags
> +        */
> +       if (!iob || (req->rq_flags & RQF_SCHED_TAGS) || ioerror ||
>                         (req->end_io && !blk_rq_is_passthrough(req)))
>                 return false;
>
> --
> 2.40.1
>


--
Guangwu Zhang
Thanks


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

* Re: [PATCH] blk-mq: fix two misuses on RQF_USE_SCHED
  2023-06-24 13:01 [PATCH] blk-mq: fix two misuses on RQF_USE_SCHED Ming Lei
  2023-06-25  8:31 ` Guangwu Zhang
@ 2023-06-25 14:01 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2023-06-25 14:01 UTC (permalink / raw
  To: Ming Lei; +Cc: linux-block, Guangwu Zhang, Christoph Hellwig


On Sat, 24 Jun 2023 21:01:05 +0800, Ming Lei wrote:
> Request allocated from sched tags can't be issued via ->queue_rqs()
> directly, since driver tag isn't allocated yet. This is the 1st misuse
> of RQF_USE_SCHED for figuring out plug->has_elevator.
> 
> Request allocated from sched tags can't be ended by
> blk_mq_end_request_batch() too, fix the 2nd RQF_USE_SCHED misuse
> in blk_mq_add_to_batch().
> 
> [...]

Applied, thanks!

[1/1] blk-mq: fix two misuses on RQF_USE_SCHED
      commit: c6b7a3a26e809c9d2a51ae303764c1d2994f31cf

Best regards,
-- 
Jens Axboe




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

end of thread, other threads:[~2023-06-25 14:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-24 13:01 [PATCH] blk-mq: fix two misuses on RQF_USE_SCHED Ming Lei
2023-06-25  8:31 ` Guangwu Zhang
2023-06-25 14:01 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).