dm: skip dm-stats work in alloc_io() unless needed
authorMike Snitzer <snitzer@kernel.org>
Tue, 13 Jun 2023 20:02:17 +0000 (16:02 -0400)
committerMike Snitzer <snitzer@kernel.org>
Fri, 16 Jun 2023 22:24:13 +0000 (18:24 -0400)
Don't dm_stats_record_start() if dm_stats_used() is false.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
drivers/md/dm.c

index 658323aff676f4843e88508991f387d0919a975b..ea1671c39ba131ab2e49b93289d1094cda5cfb25 100644 (file)
@@ -597,7 +597,8 @@ static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio)
        if (blk_queue_io_stat(md->queue))
                dm_io_set_flag(io, DM_IO_BLK_STAT);
 
-       if (static_branch_unlikely(&stats_enabled))
+       if (static_branch_unlikely(&stats_enabled) &&
+           unlikely(dm_stats_used(&md->stats)))
                dm_stats_record_start(&md->stats, &io->stats_aux);
 
        return io;