]> www.infradead.org Git - nvme.git/commitdiff
block: ensure that struct blk_mq_alloc_data is fully initialized
authorJens Axboe <axboe@kernel.dk>
Tue, 15 Apr 2025 14:48:06 +0000 (08:48 -0600)
committerJens Axboe <axboe@kernel.dk>
Mon, 21 Apr 2025 11:07:02 +0000 (05:07 -0600)
On x86, rep stos will be emitted to clear the the blk_mq_alloc_data
struct, as not all members are being explicitly initialied. Depending on
the type of CPU, this is a noticeable slowdown compared to just ensuring
that the struct is fully initialized when setup.

For the 4 spots that setup a struct blk_mq_alloc_data on the stack,
ensure all members are being initialized.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq.c

index e0fe12f1320f366a221233ef25de37c275d8132d..554380bfd002f336dd4038f6c91bcb3ea379567d 100644 (file)
@@ -584,9 +584,13 @@ static struct request *blk_mq_rq_cache_fill(struct request_queue *q,
        struct blk_mq_alloc_data data = {
                .q              = q,
                .flags          = flags,
+               .shallow_depth  = 0,
                .cmd_flags      = opf,
+               .rq_flags       = 0,
                .nr_tags        = plug->nr_ios,
                .cached_rqs     = &plug->cached_rqs,
+               .ctx            = NULL,
+               .hctx           = NULL
        };
        struct request *rq;
 
@@ -646,8 +650,13 @@ struct request *blk_mq_alloc_request(struct request_queue *q, blk_opf_t opf,
                struct blk_mq_alloc_data data = {
                        .q              = q,
                        .flags          = flags,
+                       .shallow_depth  = 0,
                        .cmd_flags      = opf,
+                       .rq_flags       = 0,
                        .nr_tags        = 1,
+                       .cached_rqs     = NULL,
+                       .ctx            = NULL,
+                       .hctx           = NULL
                };
                int ret;
 
@@ -675,8 +684,13 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q,
        struct blk_mq_alloc_data data = {
                .q              = q,
                .flags          = flags,
+               .shallow_depth  = 0,
                .cmd_flags      = opf,
+               .rq_flags       = 0,
                .nr_tags        = 1,
+               .cached_rqs     = NULL,
+               .ctx            = NULL,
+               .hctx           = NULL
        };
        u64 alloc_time_ns = 0;
        struct request *rq;
@@ -2967,8 +2981,14 @@ static struct request *blk_mq_get_new_requests(struct request_queue *q,
 {
        struct blk_mq_alloc_data data = {
                .q              = q,
-               .nr_tags        = 1,
+               .flags          = 0,
+               .shallow_depth  = 0,
                .cmd_flags      = bio->bi_opf,
+               .rq_flags       = 0,
+               .nr_tags        = 1,
+               .cached_rqs     = NULL,
+               .ctx            = NULL,
+               .hctx           = NULL
        };
        struct request *rq;