All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: linux-block@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 10/14] block: move blk_mq_tag_to_rq() inline
Date: Sat, 16 Oct 2021 19:37:44 -0600	[thread overview]
Message-ID: <20211017013748.76461-11-axboe@kernel.dk> (raw)
In-Reply-To: <20211017013748.76461-1-axboe@kernel.dk>

This is in the fast path of driver issue or completion, and it's a single
array index operation. Move it inline to avoid a function call for it.

This does mean making struct blk_mq_tags block layer public, but there's
not really much in there.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/blk-mq-tag.h     | 23 -----------------------
 block/blk-mq.c         | 11 -----------
 include/linux/blk-mq.h | 35 ++++++++++++++++++++++++++++++++++-
 3 files changed, 34 insertions(+), 35 deletions(-)

diff --git a/block/blk-mq-tag.h b/block/blk-mq-tag.h
index 71c2f7d8e9b7..e617c7220626 100644
--- a/block/blk-mq-tag.h
+++ b/block/blk-mq-tag.h
@@ -4,29 +4,6 @@
 
 struct blk_mq_alloc_data;
 
-/*
- * Tag address space map.
- */
-struct blk_mq_tags {
-	unsigned int nr_tags;
-	unsigned int nr_reserved_tags;
-
-	atomic_t active_queues;
-
-	struct sbitmap_queue bitmap_tags;
-	struct sbitmap_queue breserved_tags;
-
-	struct request **rqs;
-	struct request **static_rqs;
-	struct list_head page_list;
-
-	/*
-	 * used to clear request reference in rqs[] before freeing one
-	 * request pool
-	 */
-	spinlock_t lock;
-};
-
 extern struct blk_mq_tags *blk_mq_init_tags(unsigned int nr_tags,
 					unsigned int reserved_tags,
 					int node, int alloc_policy);
diff --git a/block/blk-mq.c b/block/blk-mq.c
index cd1249284c1f..064fdeeb1be5 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1069,17 +1069,6 @@ void blk_mq_delay_kick_requeue_list(struct request_queue *q,
 }
 EXPORT_SYMBOL(blk_mq_delay_kick_requeue_list);
 
-struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag)
-{
-	if (tag < tags->nr_tags) {
-		prefetch(tags->rqs[tag]);
-		return tags->rqs[tag];
-	}
-
-	return NULL;
-}
-EXPORT_SYMBOL(blk_mq_tag_to_rq);
-
 static bool blk_mq_rq_inflight(struct blk_mq_hw_ctx *hctx, struct request *rq,
 			       void *priv, bool reserved)
 {
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 95c3bd3a008e..1dccea9505e5 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -685,7 +685,40 @@ struct request *blk_mq_alloc_request(struct request_queue *q, unsigned int op,
 struct request *blk_mq_alloc_request_hctx(struct request_queue *q,
 		unsigned int op, blk_mq_req_flags_t flags,
 		unsigned int hctx_idx);
-struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag);
+
+/*
+ * Tag address space map.
+ */
+struct blk_mq_tags {
+	unsigned int nr_tags;
+	unsigned int nr_reserved_tags;
+
+	atomic_t active_queues;
+
+	struct sbitmap_queue bitmap_tags;
+	struct sbitmap_queue breserved_tags;
+
+	struct request **rqs;
+	struct request **static_rqs;
+	struct list_head page_list;
+
+	/*
+	 * used to clear request reference in rqs[] before freeing one
+	 * request pool
+	 */
+	spinlock_t lock;
+};
+
+static inline struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags,
+					       unsigned int tag)
+{
+	if (tag < tags->nr_tags) {
+		prefetch(tags->rqs[tag]);
+		return tags->rqs[tag];
+	}
+
+	return NULL;
+}
 
 enum {
 	BLK_MQ_UNIQUE_TAG_BITS = 16,
-- 
2.33.1


  parent reply	other threads:[~2021-10-17  1:38 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-17  1:37 [PATCHSET 0/14] Various block layer optimizations Jens Axboe
2021-10-17  1:37 ` [PATCH 01/14] block: inline fast path of driver tag allocation Jens Axboe
2021-10-18  8:42   ` Christoph Hellwig
2021-10-18 14:38     ` Jens Axboe
2021-10-17  1:37 ` [PATCH 02/14] block: don't bother iter advancing a fully done bio Jens Axboe
2021-10-18  8:42   ` Christoph Hellwig
2021-10-17  1:37 ` [PATCH 03/14] block: remove useless caller argument to print_req_error() Jens Axboe
2021-10-18  8:42   ` Christoph Hellwig
2021-10-17  1:37 ` [PATCH 04/14] block: move update request helpers into blk-mq.c Jens Axboe
2021-10-18  8:43   ` Christoph Hellwig
2021-10-17  1:37 ` [PATCH 05/14] block: don't call blk_status_to_errno() for success status Jens Axboe
2021-10-18  8:53   ` Christoph Hellwig
2021-10-18 10:49   ` Pavel Begunkov
2021-10-17  1:37 ` [PATCH 06/14] block: store elevator state in request Jens Axboe
2021-10-18  8:58   ` Christoph Hellwig
2021-10-18 14:34     ` Jens Axboe
2021-10-19 22:21   ` Guillaume Tucker
2021-10-19 22:26     ` Jens Axboe
2021-10-17  1:37 ` [PATCH 07/14] block: change plugging to use a singly linked list Jens Axboe
2021-10-17  4:45   ` kernel test robot
2021-10-17  4:45     ` kernel test robot
2021-10-18  9:19   ` Christoph Hellwig
2021-10-18 16:10     ` Jens Axboe
2021-10-18 12:56   ` Pavel Begunkov
2021-10-18 13:34     ` Jens Axboe
2021-10-24 14:09   ` kernel test robot
2021-10-17  1:37 ` [PATCH 08/14] block: improve layout of struct request Jens Axboe
2021-10-18  9:19   ` Christoph Hellwig
2021-10-17  1:37 ` [PATCH 09/14] block: only mark bio as tracked if it really is tracked Jens Axboe
2021-10-18  9:19   ` Christoph Hellwig
2021-10-17  1:37 ` Jens Axboe [this message]
2021-10-17  1:37 ` [PATCH 11/14] block: optimize blk_mq_rq_ctx_init() Jens Axboe
2021-10-18  9:20   ` Christoph Hellwig
2021-10-17  1:37 ` [PATCH 12/14] block: align blkdev_dio inlined bio to a cacheline Jens Axboe
2021-10-18  9:21   ` Christoph Hellwig
2021-10-18 14:36     ` Jens Axboe
2021-10-17  1:37 ` [PATCH 13/14] block: remove debugfs blk_mq_ctx dispatched/merged/completed attributes Jens Axboe
2021-10-18  9:21   ` Christoph Hellwig
2021-10-17  1:37 ` [PATCH 14/14] block: remove some blk_mq_hw_ctx debugfs entries Jens Axboe
2021-10-18  9:22   ` Christoph Hellwig

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=20211017013748.76461-11-axboe@kernel.dk \
    --to=axboe@kernel.dk \
    --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 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.