]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
block: Reorder the request allocation code in blk_mq_submit_bio()
authorBart Van Assche <bvanassche@acm.org>
Wed, 18 Dec 2024 21:22:45 +0000 (13:22 -0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 14 Jan 2025 17:13:25 +0000 (10:13 -0700)
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>
block/blk-mq.c

index 655dcc16db76951810d84f836f5c9e25b1a2ccce..b815ac4872b7d76382878e97d80dd9aff56f3a59 100644 (file)
@@ -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);