dm: skip dm-stats work in alloc_io() unless needed

Don't dm_stats_record_start() if dm_stats_used() is false.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
This commit is contained in:
Mike Snitzer 2023-06-13 16:02:17 -04:00
parent 06eed768ea
commit c4f512d255
1 changed files with 2 additions and 1 deletions

View 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;