Skip to content

Commit 3f0cedc

Browse files
Ming Leiaxboe
authored andcommitted
blk-mq: use list_splice_tail_init() to insert requests
list_splice_tail_init() is much more faster than inserting each request one by one, given all requets in 'list' belong to same sw queue and ctx->lock is required to insert requests. Cc: Laurence Oberman <loberman@redhat.com> Cc: Omar Sandoval <osandov@fb.com> Cc: Bart Van Assche <bart.vanassche@wdc.com> Tested-by: Kashyap Desai <kashyap.desai@broadcom.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent c018c84 commit 3f0cedc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

block/blk-mq.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,19 +1545,19 @@ void blk_mq_insert_requests(struct blk_mq_hw_ctx *hctx, struct blk_mq_ctx *ctx,
15451545
struct list_head *list)
15461546

15471547
{
1548+
struct request *rq;
1549+
15481550
/*
15491551
* preemption doesn't flush plug list, so it's possible ctx->cpu is
15501552
* offline now
15511553
*/
1552-
spin_lock(&ctx->lock);
1553-
while (!list_empty(list)) {
1554-
struct request *rq;
1555-
1556-
rq = list_first_entry(list, struct request, queuelist);
1554+
list_for_each_entry(rq, list, queuelist) {
15571555
BUG_ON(rq->mq_ctx != ctx);
1558-
list_del_init(&rq->queuelist);
1559-
__blk_mq_insert_req_list(hctx, rq, false);
1556+
trace_block_rq_insert(hctx->queue, rq);
15601557
}
1558+
1559+
spin_lock(&ctx->lock);
1560+
list_splice_tail_init(list, &ctx->rq_list);
15611561
blk_mq_hctx_mark_pending(hctx, ctx);
15621562
spin_unlock(&ctx->lock);
15631563
}

0 commit comments

Comments
 (0)