Thread (10 messages) 10 messages, 4 authors, 2020-08-11
STALE2148d
Revisions (5)
  1. rfc [diff vs current]
  2. v2 current
  3. v4 [diff vs current]
  4. v1 [diff vs current]
  5. v2 [diff vs current]

[PATCH RFC V2 4/4] block: call blk_additional_{latency,sector} only when io_extra_stats is true

From: Guoqing Jiang <hidden>
Date: 2020-07-13 21:13:59
Subsystem: block layer, the rest · Maintainers: Jens Axboe, Linus Torvalds

If ADDITIONAL_DISKSTAT is enabled carelessly, then it is bad to people
who don't want the additional overhead.

Now add check before call blk_additional_{latency,sector}, which guarntee
only those who really know about the attribute can account the additional
data.

Signed-off-by: Guoqing Jiang <redacted>
---
 block/blk-core.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index b67aedfbcefc..171e99ed820b 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1458,7 +1458,8 @@ static void blk_account_io_completion(struct request *req, unsigned int bytes)
 		part_stat_lock();
 		part = req->part;
 #ifdef CONFIG_BLK_ADDITIONAL_DISKSTAT
-		blk_additional_sector(part, sgrp, bytes >> SECTOR_SHIFT);
+		if (blk_queue_extra_io_stat(req->q))
+			blk_additional_sector(part, sgrp, bytes >> SECTOR_SHIFT);
 #endif
 		part_stat_add(part, sectors[sgrp], bytes >> 9);
 		part_stat_unlock();
@@ -1482,7 +1483,8 @@ void blk_account_io_done(struct request *req, u64 now)
 
 		update_io_ticks(part, jiffies, true);
 #ifdef CONFIG_BLK_ADDITIONAL_DISKSTAT
-		blk_additional_latency(part, sgrp, req, 0);
+		if (blk_queue_extra_io_stat(req->q))
+			blk_additional_latency(part, sgrp, req, 0);
 #endif
 		part_stat_inc(part, ios[sgrp]);
 		part_stat_add(part, nsecs[sgrp], now - req->start_time_ns);
@@ -1516,7 +1518,8 @@ unsigned long disk_start_io_acct(struct gendisk *disk, unsigned int sectors,
 	part_stat_inc(part, ios[sgrp]);
 	part_stat_add(part, sectors[sgrp], sectors);
 #ifdef CONFIG_BLK_ADDITIONAL_DISKSTAT
-	blk_additional_sector(part, sgrp, sectors);
+	if (blk_queue_extra_io_stat(disk->queue))
+		blk_additional_sector(part, sgrp, sectors);
 #endif
 	part_stat_local_inc(part, in_flight[op_is_write(op)]);
 	part_stat_unlock();
@@ -1536,7 +1539,8 @@ void disk_end_io_acct(struct gendisk *disk, unsigned int op,
 	part_stat_lock();
 	update_io_ticks(part, now, true);
 #ifdef CONFIG_BLK_ADDITIONAL_DISKSTAT
-	blk_additional_latency(part, sgrp, NULL, start_time);
+	if (blk_queue_extra_io_stat(disk->queue))
+		blk_additional_latency(part, sgrp, NULL, start_time);
 #endif
 	part_stat_add(part, nsecs[sgrp], jiffies_to_nsecs(duration));
 	part_stat_local_dec(part, in_flight[op_is_write(op)]);
-- 
2.17.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help