From: Bart Van Assche Date: Wed, 18 Dec 2024 21:22:45 +0000 (-0800) Subject: block: Reorder the request allocation code in blk_mq_submit_bio() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=44e41381591dc5b4ea67a9f170b4ec85c817586e;p=users%2Fwilly%2Flinux.git block: Reorder the request allocation code in blk_mq_submit_bio() Help the CPU branch predictor in case of a cache hit by handling the cache hit scenario first. Reviewed-by: Damien Le Moal Cc: Christoph Hellwig Signed-off-by: Bart Van Assche Reviewed-by: Christoph Hellwig Reviewed-by: Chaitanya Kulkarni Link: https://lore.kernel.org/r/20241218212246.1073149-2-bvanassche@acm.org Signed-off-by: Jens Axboe --- diff --git a/block/blk-mq.c b/block/blk-mq.c index 655dcc16db76..b815ac4872b7 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -3125,12 +3125,12 @@ void blk_mq_submit_bio(struct bio *bio) goto queue_exit; new_request: - if (!rq) { + if (rq) { + blk_mq_use_cached_rq(rq, plug, bio); + } else { rq = blk_mq_get_new_requests(q, plug, bio, nr_segs); if (unlikely(!rq)) goto queue_exit; - } else { - blk_mq_use_cached_rq(rq, plug, bio); } trace_block_getrq(bio);