[PATCH v2] block: make the io_ticks counter more accurate

From: Wen Yang
Date: Wed Dec 25 2019 - 22:10:38 EST


Instead of the jiffies, we should update the io_ticks counter
with the passed in parameter 'now'.

Signed-off-by: Wen Yang <wenyang@xxxxxxxxxxxxxxxxx>
Reviewed-by: Joseph Qi <joseph.qi@xxxxxxxxxxxxxxxxx>
Cc: Jens Axboe <axboe@xxxxxxxxx>
Cc: Mikulas Patocka <mpatocka@xxxxxxxxxx>
Cc: Mike Snitzer <snitzer@xxxxxxxxxx>
Cc: linux-block@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
v2->v1: Use the same clock source for io_ticks and other statistics in the diskstats

block/blk-core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 379f6f5..da7de9f 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1365,7 +1365,7 @@ void blk_account_io_done(struct request *req, u64 now)
part_stat_lock();
part = req->part;

- update_io_ticks(part, jiffies);
+ update_io_ticks(part, nsecs_to_jiffies(now));
part_stat_inc(part, ios[sgrp]);
part_stat_add(part, nsecs[sgrp], now - req->start_time_ns);
part_stat_add(part, time_in_queue, nsecs_to_jiffies64(now - req->start_time_ns));
@@ -1407,7 +1407,7 @@ void blk_account_io_start(struct request *rq, bool new_io)
rq->part = part;
}

- update_io_ticks(part, jiffies);
+ update_io_ticks(part, nsecs_to_jiffies(ktime_get_ns()));

part_stat_unlock();
}
--
1.8.3.1