Skip to content

Commit 7c7f2f2

Browse files
committed
blk-mq: add blk_mq_free_hctx_request()
It's silly to use blk_mq_free_request() which in turn maps the request to the hardware queue, for places where we already know what the hardware queue is. This saves us an extra mapping of a hardware queue on request completion, if the caller knows this information already. Signed-off-by: Jens Axboe <[email protected]>
1 parent 1a3b595 commit 7c7f2f2

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

block/blk-mq.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,16 +269,23 @@ static void __blk_mq_free_request(struct blk_mq_hw_ctx *hctx,
269269
blk_mq_queue_exit(q);
270270
}
271271

272-
void blk_mq_free_request(struct request *rq)
272+
void blk_mq_free_hctx_request(struct blk_mq_hw_ctx *hctx, struct request *rq)
273273
{
274274
struct blk_mq_ctx *ctx = rq->mq_ctx;
275-
struct blk_mq_hw_ctx *hctx;
276-
struct request_queue *q = rq->q;
277275

278276
ctx->rq_completed[rq_is_sync(rq)]++;
279-
280-
hctx = q->mq_ops->map_queue(q, ctx->cpu);
281277
__blk_mq_free_request(hctx, ctx, rq);
278+
279+
}
280+
EXPORT_SYMBOL_GPL(blk_mq_free_hctx_request);
281+
282+
void blk_mq_free_request(struct request *rq)
283+
{
284+
struct blk_mq_hw_ctx *hctx;
285+
struct request_queue *q = rq->q;
286+
287+
hctx = q->mq_ops->map_queue(q, rq->mq_ctx->cpu);
288+
blk_mq_free_hctx_request(hctx, rq);
282289
}
283290
EXPORT_SYMBOL_GPL(blk_mq_free_request);
284291

include/linux/blk-mq.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule);
169169
void blk_mq_insert_request(struct request *, bool, bool, bool);
170170
void blk_mq_run_queues(struct request_queue *q, bool async);
171171
void blk_mq_free_request(struct request *rq);
172+
void blk_mq_free_hctx_request(struct blk_mq_hw_ctx *, struct request *rq);
172173
bool blk_mq_can_queue(struct blk_mq_hw_ctx *);
173174
struct request *blk_mq_alloc_request(struct request_queue *q, int rw,
174175
gfp_t gfp, bool reserved);

0 commit comments

Comments
 (0)