From 44e41381591dc5b4ea67a9f170b4ec85c817586e Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 18 Dec 2024 13:22:45 -0800 Subject: [PATCH] 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 --- block/blk-mq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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); -- 2.50.1