Re: [PATCH 3/4] blk-mq: check bio_mergeable() early before merging

From: Ming Lei
Date: Thu Oct 15 2015 - 20:26:55 EST


On Thu, Oct 15, 2015 at 11:21 PM, Jeff Moyer <jmoyer@xxxxxxxxxx> wrote:
> Ming Lei <ming.lei@xxxxxxxxxxxxx> writes:
>
>> It isn't necessary to try to merge the bio which is marked
>> as NOMERGE.
>>
>> Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxxxxx>
>> ---
>> block/blk-mq.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/block/blk-mq.c b/block/blk-mq.c
>> index 546b3b8..deb5f4c 100644
>> --- a/block/blk-mq.c
>> +++ b/block/blk-mq.c
>> @@ -671,6 +671,9 @@ static bool blk_mq_attempt_merge(struct request_queue *q,
>> struct request *rq;
>> int checked = 8;
>>
>> + if (!bio_mergeable(bio))
>> + return false;
>> +
>> list_for_each_entry_reverse(rq, &ctx->rq_list, queuelist) {
>> int el_ret;
>>
>> @@ -1140,7 +1143,7 @@ static inline bool blk_mq_merge_queue_io(struct blk_mq_hw_ctx *hctx,
>> struct blk_mq_ctx *ctx,
>> struct request *rq, struct bio *bio)
>> {
>> - if (!hctx_allow_merges(hctx)) {
>> + if (!hctx_allow_merges(hctx) || !bio_mergeable(bio)) {
>> blk_mq_bio_to_request(rq, bio);
>> spin_lock(&ctx->lock);
>> insert_rq:
>
> blk_mq_attempt_merge is only called from blk_mq_merge_queue_io. So, by
> adding the conditional in blk_mq_merge_queue_io, you don't need any
> change in blk_mq_attempt_merge.

OK.

>
> Also, why haven't you updated the non-multiqueue code paths similarly?

Will do it in v1.

>
> Cheers,
> Jeff
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/