Commit 3f0cedc7 authored by Ming Lei's avatar Ming Lei Committed by Jens Axboe

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: default avatarKashyap Desai <kashyap.desai@broadcom.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent c018c84f
...@@ -1545,19 +1545,19 @@ void blk_mq_insert_requests(struct blk_mq_hw_ctx *hctx, struct blk_mq_ctx *ctx, ...@@ -1545,19 +1545,19 @@ void blk_mq_insert_requests(struct blk_mq_hw_ctx *hctx, struct blk_mq_ctx *ctx,
struct list_head *list) struct list_head *list)
{ {
struct request *rq;
/* /*
* preemption doesn't flush plug list, so it's possible ctx->cpu is * preemption doesn't flush plug list, so it's possible ctx->cpu is
* offline now * offline now
*/ */
spin_lock(&ctx->lock); list_for_each_entry(rq, list, queuelist) {
while (!list_empty(list)) {
struct request *rq;
rq = list_first_entry(list, struct request, queuelist);
BUG_ON(rq->mq_ctx != ctx); BUG_ON(rq->mq_ctx != ctx);
list_del_init(&rq->queuelist); trace_block_rq_insert(hctx->queue, rq);
__blk_mq_insert_req_list(hctx, rq, false);
} }
spin_lock(&ctx->lock);
list_splice_tail_init(list, &ctx->rq_list);
blk_mq_hctx_mark_pending(hctx, ctx); blk_mq_hctx_mark_pending(hctx, ctx);
spin_unlock(&ctx->lock); spin_unlock(&ctx->lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment