From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Yu Kuai <yukuai3@huawei.com>,
Ming Lei <ming.lei@redhat.com>
Subject: [PATCH 5/6] blk-mq: add helper of blk_mq_get_hctx to retrieve hctx via its index
Date: Mon, 28 Feb 2022 17:04:29 +0800 [thread overview]
Message-ID: <20220228090430.1064267-6-ming.lei@redhat.com> (raw)
In-Reply-To: <20220228090430.1064267-1-ming.lei@redhat.com>
Prepare for managing hctx mapping via xarray by adding one helper of
blk_mq_get_hctx().
No functional change.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
block/blk-mq-sysfs.c | 2 +-
block/blk-mq.c | 4 ++--
block/blk-mq.h | 2 +-
include/linux/blk-mq.h | 8 +++++++-
4 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
index 674786574075..22950e764536 100644
--- a/block/blk-mq-sysfs.c
+++ b/block/blk-mq-sysfs.c
@@ -279,7 +279,7 @@ int __blk_mq_register_dev(struct device *dev, struct request_queue *q)
unreg:
while (--i >= 0)
- blk_mq_unregister_hctx(q->queue_hw_ctx[i]);
+ blk_mq_unregister_hctx(blk_mq_get_hctx(q, i));
kobject_uevent(q->mq_kobj, KOBJ_REMOVE);
kobject_del(q->mq_kobj);
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 5ce6a8289cff..d01c1693a3d4 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -71,7 +71,7 @@ static int blk_mq_poll_stats_bkt(const struct request *rq)
static inline struct blk_mq_hw_ctx *blk_qc_to_hctx(struct request_queue *q,
blk_qc_t qc)
{
- return q->queue_hw_ctx[(qc & ~BLK_QC_T_INTERNAL) >> BLK_QC_T_SHIFT];
+ return blk_mq_get_hctx(q, (qc & ~BLK_QC_T_INTERNAL) >> BLK_QC_T_SHIFT);
}
static inline struct request *blk_qc_to_rq(struct blk_mq_hw_ctx *hctx,
@@ -573,7 +573,7 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q,
* If not tell the caller that it should skip this queue.
*/
ret = -EXDEV;
- data.hctx = q->queue_hw_ctx[hctx_idx];
+ data.hctx = blk_mq_get_hctx(q, hctx_idx);
if (!blk_mq_hw_queue_mapped(data.hctx))
goto out_queue_exit;
cpu = cpumask_first_and(data.hctx->cpumask, cpu_online_mask);
diff --git a/block/blk-mq.h b/block/blk-mq.h
index 948791ea2a3e..804668457f88 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -83,7 +83,7 @@ static inline struct blk_mq_hw_ctx *blk_mq_map_queue_type(struct request_queue *
enum hctx_type type,
unsigned int cpu)
{
- return q->queue_hw_ctx[q->tag_set->map[type].mq_map[cpu]];
+ return blk_mq_get_hctx(q, q->tag_set->map[type].mq_map[cpu]);
}
static inline enum hctx_type blk_mq_get_hctx_type(unsigned int flags)
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 3a41d50b85d3..3d949b1968f3 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -916,9 +916,15 @@ static inline void *blk_mq_rq_to_pdu(struct request *rq)
return rq + 1;
}
+static inline struct blk_mq_hw_ctx *blk_mq_get_hctx(struct request_queue *q,
+ unsigned int hctx_idx)
+{
+ return q->queue_hw_ctx[hctx_idx];
+}
+
#define queue_for_each_hw_ctx(q, hctx, i) \
for ((i) = 0; (i) < (q)->nr_hw_queues && \
- ({ hctx = (q)->queue_hw_ctx[i]; 1; }); (i)++)
+ ({ hctx = blk_mq_get_hctx((q), (i)); 1; }); (i)++)
#define hctx_for_each_ctx(hctx, ctx, i) \
for ((i) = 0; (i) < (hctx)->nr_ctx && \
--
2.31.1
next prev parent reply other threads:[~2022-02-28 9:05 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-28 9:04 [PATCH 0/6] blk-mq: update_nr_hw_queues related improvement & bugfix Ming Lei
2022-02-28 9:04 ` [PATCH 1/6] blk-mq: figure out correct numa node for hw queue Ming Lei
2022-03-01 13:30 ` Christoph Hellwig
2022-03-01 19:19 ` John Garry
2022-03-02 1:47 ` Ming Lei
2022-03-02 9:02 ` John Garry
2022-03-02 9:22 ` Ming Lei
2022-03-02 10:11 ` John Garry
2022-02-28 9:04 ` [PATCH 2/6] blk-mq: simplify reallocation of hw ctxs a bit Ming Lei
2022-03-01 13:30 ` Christoph Hellwig
2022-02-28 9:04 ` [PATCH 3/6] blk-mq: re-config poll after queue map is changed Ming Lei
2022-03-01 13:31 ` Christoph Hellwig
2022-02-28 9:04 ` [PATCH 4/6] block: mtip32xx: don't touch q->queue_hw_ctx Ming Lei
2022-03-01 13:32 ` Christoph Hellwig
2022-02-28 9:04 ` Ming Lei [this message]
2022-03-01 13:33 ` [PATCH 5/6] blk-mq: add helper of blk_mq_get_hctx to retrieve hctx via its index Christoph Hellwig
2022-02-28 9:04 ` [PATCH 6/6] blk-mq: manage hctx map via xarray Ming Lei
2022-02-28 17:36 ` kernel test robot
2022-02-28 17:57 ` kernel test robot
2022-03-01 9:08 ` Ming Lei
2022-03-01 9:08 ` Ming Lei
2022-03-01 13:37 ` Christoph Hellwig
2022-03-02 2:06 ` Ming Lei
2022-03-02 8:24 ` Christoph Hellwig
2022-03-02 9:53 ` Ming Lei
2022-03-02 9:59 ` 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=20220228090430.1064267-6-ming.lei@redhat.com \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=yukuai3@huawei.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.