aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Begunkov2021-10-18 21:37:28 +0100
committerJens Axboe2021-10-18 14:38:43 -0600
commit605f784e4f5faecf6c78070c6bf446e920104f9f (patch)
treee77af8a4e1ee350a3a05be6f1075c1e05eab8f48
parent4f266f2be822eacd70aca2a7a53c4a111be79acb (diff)
block: blk_mq_rq_ctx_init cache ctx/q/hctx
We should have enough of registers in blk_mq_rq_ctx_init(), store them in local vars, so we don't keep reloading them. note: keeping q->elevator may look unnecessary, but it's also used inside inlined blk_mq_tags_from_data(). Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/blk-mq.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 1d2e2fd4043e..fa4de25c3bcb 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -312,10 +312,14 @@ static inline bool blk_mq_need_time_stamp(struct request *rq)
static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,
unsigned int tag, u64 alloc_time_ns)
{
+ struct blk_mq_ctx *ctx = data->ctx;
+ struct blk_mq_hw_ctx *hctx = data->hctx;
+ struct request_queue *q = data->q;
+ struct elevator_queue *e = q->elevator;
struct blk_mq_tags *tags = blk_mq_tags_from_data(data);
struct request *rq = tags->static_rqs[tag];
- if (data->q->elevator) {
+ if (e) {
rq->rq_flags = RQF_ELV;
rq->tag = BLK_MQ_NO_TAG;
rq->internal_tag = tag;
@@ -330,13 +334,13 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,
else
rq->start_time_ns = 0;
/* csd/requeue_work/fifo_time is initialized before use */
- rq->q = data->q;
- rq->mq_ctx = data->ctx;
- rq->mq_hctx = data->hctx;
+ rq->q = q;
+ rq->mq_ctx = ctx;
+ rq->mq_hctx = hctx;
rq->cmd_flags = data->cmd_flags;
if (data->flags & BLK_MQ_REQ_PM)
rq->rq_flags |= RQF_PM;
- if (blk_queue_io_stat(data->q))
+ if (blk_queue_io_stat(q))
rq->rq_flags |= RQF_IO_STAT;
rq->rq_disk = NULL;
rq->part = NULL;