Skip to content

Commit 07a252b

Browse files
Ming Leigregkh
authored andcommitted
blk-mq: only attempt to merge bio if there is rq in sw queue
[ Upstream commit b04f50a ] Only attempt to merge bio iff the ctx->rq_list isn't empty, because: 1) for high-performance SSD, most of times dispatch may succeed, then there may be nothing left in ctx->rq_list, so don't try to merge over sw queue if it is empty, then we can save one acquiring of ctx->lock 2) we can't expect good merge performance on per-cpu sw queue, and missing one merge on sw queue won't be a big deal since tasks can be scheduled from one CPU to another. Cc: Laurence Oberman <[email protected]> Cc: Omar Sandoval <[email protected]> Cc: Bart Van Assche <[email protected]> Tested-by: Kashyap Desai <[email protected]> Reported-by: Kashyap Desai <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Jens Axboe <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2f9cd85 commit 07a252b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

block/blk-mq-sched.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ bool __blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio)
236236
return e->type->ops.mq.bio_merge(hctx, bio);
237237
}
238238

239-
if (hctx->flags & BLK_MQ_F_SHOULD_MERGE) {
239+
if ((hctx->flags & BLK_MQ_F_SHOULD_MERGE) &&
240+
!list_empty_careful(&ctx->rq_list)) {
240241
/* default per sw-queue merge */
241242
spin_lock(&ctx->lock);
242243
ret = blk_mq_attempt_merge(q, ctx, bio);

0 commit comments

Comments
 (0)