Linux block layer
 help / color / mirror / Atom feed
* [PATCH] blk-mq: don't queue passthrough request into scheduler
@ 2023-05-12 15:03 Ming Lei
  2023-05-12 15:08 ` Jens Axboe
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Ming Lei @ 2023-05-12 15:03 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Ming Lei, Guangwu Zhang, Yu Kuai

Passthrough(pt) request shouldn't be queued to scheduler, especially some
schedulers(such as bfq) supposes that req->bio is always available and
blk-cgroup can be retrieved via bio.

Sometimes pt request could be part of error handling, so it is better to always
queue it into hctx->dispatch directly.

Fix this issue by queuing pt request from plug list to hctx->dispatch
directly.

Reported-by: Guangwu Zhang <guazhang@redhat.com>
Investigated-by: Yu Kuai <yukuai1@huaweicloud.com>
Fixes: 1c2d2fff6dc0 ("block: wire-up support for passthrough plugging")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
Guang Wu, please test this patch and provide us the result.

 block/blk-mq.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index f6dad0886a2f..11efaefa26c3 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2711,6 +2711,7 @@ static void blk_mq_dispatch_plug_list(struct blk_plug *plug, bool from_sched)
 	struct request *requeue_list = NULL;
 	struct request **requeue_lastp = &requeue_list;
 	unsigned int depth = 0;
+	bool pt = false;
 	LIST_HEAD(list);
 
 	do {
@@ -2719,7 +2720,9 @@ static void blk_mq_dispatch_plug_list(struct blk_plug *plug, bool from_sched)
 		if (!this_hctx) {
 			this_hctx = rq->mq_hctx;
 			this_ctx = rq->mq_ctx;
-		} else if (this_hctx != rq->mq_hctx || this_ctx != rq->mq_ctx) {
+			pt = blk_rq_is_passthrough(rq);
+		} else if (this_hctx != rq->mq_hctx || this_ctx != rq->mq_ctx ||
+				pt != blk_rq_is_passthrough(rq)) {
 			rq_list_add_tail(&requeue_lastp, rq);
 			continue;
 		}
@@ -2731,10 +2734,15 @@ static void blk_mq_dispatch_plug_list(struct blk_plug *plug, bool from_sched)
 	trace_block_unplug(this_hctx->queue, depth, !from_sched);
 
 	percpu_ref_get(&this_hctx->queue->q_usage_counter);
-	if (this_hctx->queue->elevator) {
+	if (this_hctx->queue->elevator && !pt) {
 		this_hctx->queue->elevator->type->ops.insert_requests(this_hctx,
 				&list, 0);
 		blk_mq_run_hw_queue(this_hctx, from_sched);
+	} else if (pt) {
+		spin_lock(&this_hctx->lock);
+		list_splice_tail_init(&list, &this_hctx->dispatch);
+		spin_unlock(&this_hctx->lock);
+		blk_mq_run_hw_queue(this_hctx, from_sched);
 	} else {
 		blk_mq_insert_requests(this_hctx, this_ctx, &list, from_sched);
 	}
-- 
2.38.1


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

end of thread, other threads:[~2023-05-15 14:34 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-12 15:03 [PATCH] blk-mq: don't queue passthrough request into scheduler Ming Lei
2023-05-12 15:08 ` Jens Axboe
2023-05-12 15:19   ` Ming Lei
2023-05-12 15:25     ` Jens Axboe
2023-05-12 15:34       ` Ming Lei
2023-05-12 15:43         ` Jens Axboe
2023-05-12 15:55           ` Ming Lei
2023-05-12 16:10             ` Jens Axboe
2023-05-13 10:55               ` Ming Lei
2023-05-12 20:21           ` Christoph Hellwig
2023-05-12 21:31             ` Jens Axboe
2023-05-12 23:12               ` Christoph Hellwig
2023-05-12 23:14                 ` Christoph Hellwig
2023-05-12 20:20   ` Christoph Hellwig
2023-05-13 11:15     ` Ming Lei
2023-05-13 16:50 ` Jens Axboe
2023-05-14 12:11 ` Guangwu Zhang
2023-05-14 12:24   ` Ming Lei
2023-05-15 14:33 ` Guangwu Zhang

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