Skip to content

Commit 44e4138

Browse files
bvanasscheaxboe
authored andcommitted
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 <dlemoal@kernel.org> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Link: https://lore.kernel.org/r/20241218212246.1073149-2-bvanassche@acm.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent e7b94c5 commit 44e4138

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

block/blk-mq.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3125,12 +3125,12 @@ void blk_mq_submit_bio(struct bio *bio)
31253125
goto queue_exit;
31263126

31273127
new_request:
3128-
if (!rq) {
3128+
if (rq) {
3129+
blk_mq_use_cached_rq(rq, plug, bio);
3130+
} else {
31293131
rq = blk_mq_get_new_requests(q, plug, bio, nr_segs);
31303132
if (unlikely(!rq))
31313133
goto queue_exit;
3132-
} else {
3133-
blk_mq_use_cached_rq(rq, plug, bio);
31343134
}
31353135

31363136
trace_block_getrq(bio);

0 commit comments

Comments
 (0)