Linux block layer
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Bart Van Assche <bvanassche@acm.org>,
	Damien Le Moal <dlemoal@kernel.org>,
	linux-block@vger.kernel.org
Subject: [PATCH 17/20] blk-mq: pass a flags argument to blk_mq_insert_request
Date: Thu, 13 Apr 2023 08:40:54 +0200	[thread overview]
Message-ID: <20230413064057.707578-18-hch@lst.de> (raw)
In-Reply-To: <20230413064057.707578-1-hch@lst.de>

Replace the at_head bool with a flags argument that so far only contains
a single BLK_MQ_INSERT_AT_HEAD value.  This makes it much easier to grep
for head insertions into the blk-mq dispatch queues.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
---
 block/blk-mq.c | 27 ++++++++++++++-------------
 block/blk-mq.h |  3 +++
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index db806c1a194c7b..ba64c4621e29d6 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -44,7 +44,7 @@
 
 static DEFINE_PER_CPU(struct llist_head, blk_cpu_done);
 
-static void blk_mq_insert_request(struct request *rq, bool at_head);
+static void blk_mq_insert_request(struct request *rq, blk_insert_t flags);
 static void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
 		struct list_head *list);
 
@@ -1308,7 +1308,7 @@ void blk_execute_rq_nowait(struct request *rq, bool at_head)
 		return;
 	}
 
-	blk_mq_insert_request(rq, at_head);
+	blk_mq_insert_request(rq, at_head ? BLK_MQ_INSERT_AT_HEAD : 0);
 	blk_mq_run_hw_queue(hctx, false);
 }
 EXPORT_SYMBOL_GPL(blk_execute_rq_nowait);
@@ -1371,7 +1371,7 @@ blk_status_t blk_execute_rq(struct request *rq, bool at_head)
 	rq->end_io = blk_end_sync_rq;
 
 	blk_account_io_start(rq);
-	blk_mq_insert_request(rq, at_head);
+	blk_mq_insert_request(rq, at_head ? BLK_MQ_INSERT_AT_HEAD : 0);
 	blk_mq_run_hw_queue(hctx, false);
 
 	if (blk_rq_is_poll(rq)) {
@@ -1451,14 +1451,14 @@ static void blk_mq_requeue_work(struct work_struct *work)
 		} else if (rq->rq_flags & RQF_SOFTBARRIER) {
 			rq->rq_flags &= ~RQF_SOFTBARRIER;
 			list_del_init(&rq->queuelist);
-			blk_mq_insert_request(rq, true);
+			blk_mq_insert_request(rq, BLK_MQ_INSERT_AT_HEAD);
 		}
 	}
 
 	while (!list_empty(&rq_list)) {
 		rq = list_entry(rq_list.next, struct request, queuelist);
 		list_del_init(&rq->queuelist);
-		blk_mq_insert_request(rq, false);
+		blk_mq_insert_request(rq, 0);
 	}
 
 	blk_mq_run_hw_queues(q, false);
@@ -2509,7 +2509,7 @@ static void blk_mq_insert_requests(struct blk_mq_hw_ctx *hctx,
 	blk_mq_run_hw_queue(hctx, run_queue_async);
 }
 
-static void blk_mq_insert_request(struct request *rq, bool at_head)
+static void blk_mq_insert_request(struct request *rq, blk_insert_t flags)
 {
 	struct request_queue *q = rq->q;
 	struct blk_mq_ctx *ctx = rq->mq_ctx;
@@ -2526,7 +2526,7 @@ static void blk_mq_insert_request(struct request *rq, bool at_head)
 		 * and it is added to the scheduler queue, there is no chance to
 		 * dispatch it given we prioritize requests in hctx->dispatch.
 		 */
-		blk_mq_request_bypass_insert(rq, at_head);
+		blk_mq_request_bypass_insert(rq, flags & BLK_MQ_INSERT_AT_HEAD);
 	} else if (rq->rq_flags & RQF_FLUSH_SEQ) {
 		/*
 		 * Firstly normal IO request is inserted to scheduler queue or
@@ -2556,12 +2556,13 @@ static void blk_mq_insert_request(struct request *rq, bool at_head)
 		WARN_ON_ONCE(rq->tag != BLK_MQ_NO_TAG);
 
 		list_add(&rq->queuelist, &list);
-		q->elevator->type->ops.insert_requests(hctx, &list, at_head);
+		q->elevator->type->ops.insert_requests(hctx, &list,
+				flags & BLK_MQ_INSERT_AT_HEAD);
 	} else {
 		trace_block_rq_insert(rq);
 
 		spin_lock(&ctx->lock);
-		if (at_head)
+		if (flags & BLK_MQ_INSERT_AT_HEAD)
 			list_add(&rq->queuelist, &ctx->rq_lists[hctx->type]);
 		else
 			list_add_tail(&rq->queuelist,
@@ -2653,12 +2654,12 @@ static void blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
 	blk_status_t ret;
 
 	if (blk_mq_hctx_stopped(hctx) || blk_queue_quiesced(rq->q)) {
-		blk_mq_insert_request(rq, false);
+		blk_mq_insert_request(rq, 0);
 		return;
 	}
 
 	if ((rq->rq_flags & RQF_ELV) || !blk_mq_get_budget_and_tag(rq)) {
-		blk_mq_insert_request(rq, false);
+		blk_mq_insert_request(rq, 0);
 		blk_mq_run_hw_queue(hctx, false);
 		return;
 	}
@@ -2683,7 +2684,7 @@ static blk_status_t blk_mq_request_issue_directly(struct request *rq, bool last)
 	struct blk_mq_hw_ctx *hctx = rq->mq_hctx;
 
 	if (blk_mq_hctx_stopped(hctx) || blk_queue_quiesced(rq->q)) {
-		blk_mq_insert_request(rq, false);
+		blk_mq_insert_request(rq, 0);
 		return BLK_STS_OK;
 	}
 
@@ -3018,7 +3019,7 @@ void blk_mq_submit_bio(struct bio *bio)
 	hctx = rq->mq_hctx;
 	if ((rq->rq_flags & RQF_ELV) ||
 	    (hctx->dispatch_busy && (q->nr_hw_queues == 1 || !is_sync))) {
-		blk_mq_insert_request(rq, false);
+		blk_mq_insert_request(rq, 0);
 		blk_mq_run_hw_queue(hctx, true);
 	} else {
 		blk_mq_run_dispatch_ops(q, blk_mq_try_issue_directly(hctx, rq));
diff --git a/block/blk-mq.h b/block/blk-mq.h
index 5d3761c5006346..273eee00524b98 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -36,6 +36,9 @@ enum {
 	BLK_MQ_TAG_MAX		= BLK_MQ_NO_TAG - 1,
 };
 
+typedef unsigned int __bitwise blk_insert_t;
+#define BLK_MQ_INSERT_AT_HEAD		((__force blk_insert_t)0x01)
+
 void blk_mq_submit_bio(struct bio *bio);
 int blk_mq_poll(struct request_queue *q, blk_qc_t cookie, struct io_comp_batch *iob,
 		unsigned int flags);
-- 
2.39.2


  parent reply	other threads:[~2023-04-13  6:42 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-13  6:40 cleanup request insertation parameters v3 Christoph Hellwig
2023-04-13  6:40 ` [PATCH 01/20] blk-mq: don't plug for head insertions in blk_execute_rq_nowait Christoph Hellwig
2023-04-13  6:40 ` [PATCH 02/20] blk-mq: remove blk-mq-tag.h Christoph Hellwig
2023-04-13  6:40 ` [PATCH 03/20] blk-mq: include <linux/blk-mq.h> in block/blk-mq.h Christoph Hellwig
2023-04-13  6:40 ` [PATCH 04/20] blk-mq: move more logic into blk_mq_insert_requests Christoph Hellwig
2023-04-13  6:40 ` [PATCH 05/20] blk-mq: fold blk_mq_sched_insert_requests into blk_mq_dispatch_plug_list Christoph Hellwig
2023-04-13  6:40 ` [PATCH 06/20] blk-mq: move blk_mq_sched_insert_request to blk-mq.c Christoph Hellwig
2023-04-13  6:40 ` [PATCH 07/20] blk-mq: fold __blk_mq_insert_request into blk_mq_insert_request Christoph Hellwig
2023-04-13  6:40 ` [PATCH 08/20] blk-mq: fold __blk_mq_insert_req_list " Christoph Hellwig
2023-04-13  6:40 ` [PATCH 09/20] blk-mq: remove blk_flush_queue_rq Christoph Hellwig
2023-04-13  6:40 ` [PATCH 10/20] blk-mq: refactor passthrough vs flush handling in blk_mq_insert_request Christoph Hellwig
2023-04-13  6:40 ` [PATCH 11/20] blk-mq: refactor the DONTPREP/SOFTBARRIER andling in blk_mq_requeue_work Christoph Hellwig
2023-04-13  6:40 ` [PATCH 12/20] blk-mq: factor out a blk_mq_get_budget_and_tag helper Christoph Hellwig
2023-04-13  6:40 ` [PATCH 13/20] blk-mq: fold __blk_mq_try_issue_directly into its two callers Christoph Hellwig
2023-04-13  6:40 ` [PATCH 14/20] blk-mq: don't run the hw_queue from blk_mq_insert_request Christoph Hellwig
2023-04-13  6:40 ` [PATCH 15/20] blk-mq: don't run the hw_queue from blk_mq_request_bypass_insert Christoph Hellwig
2023-04-13  6:40 ` [PATCH 16/20] blk-mq: don't kick the requeue_list in blk_mq_add_to_requeue_list Christoph Hellwig
2023-04-13  6:54   ` Damien Le Moal
2023-04-13  6:59     ` Christoph Hellwig
2023-04-13  7:47       ` Damien Le Moal
2023-04-13  6:40 ` Christoph Hellwig [this message]
2023-04-13  6:40 ` [PATCH 18/20] blk-mq: pass a flags argument to blk_mq_request_bypass_insert Christoph Hellwig
2023-04-13  6:40 ` [PATCH 19/20] blk-mq: pass a flags argument to elevator_type->insert_requests Christoph Hellwig
2023-04-13  6:40 ` [PATCH 20/20] blk-mq: pass a flags argument to blk_mq_add_to_requeue_list Christoph Hellwig
2023-04-13  6:55   ` Damien Le Moal
2023-04-13 13:11 ` cleanup request insertation parameters v3 Jens Axboe

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=20230413064057.707578-18-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=dlemoal@kernel.org \
    --cc=linux-block@vger.kernel.org \
    /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