block/diskstats: replace time_in_queue with sum of request times
authorKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
Wed, 25 Mar 2020 13:07:08 +0000 (16:07 +0300)
committerJens Axboe <axboe@kernel.dk>
Wed, 25 Mar 2020 14:49:12 +0000 (08:49 -0600)
Column "time_in_queue" in diskstats is supposed to show total waiting time
of all requests. I.e. value should be equal to the sum of times from other
columns. But this is not true, because column "time_in_queue" is counted
separately in jiffies rather than in nanoseconds as other times.

This patch removes redundant counter for "time_in_queue" and shows total
time of read, write, discard and flush requests.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio.c
block/blk-core.c
block/genhd.c
include/linux/genhd.h

index 68f65ef2cebace4ccbaf7979ba8fd3d3793c3e8b..bc9152977bf0c501b97c814fe2ad3aaba848c0be 100644 (file)
@@ -1811,7 +1811,6 @@ void generic_end_io_acct(struct request_queue *q, int req_op,
 
        update_io_ticks(part, now, true);
        part_stat_add(part, nsecs[sgrp], jiffies_to_nsecs(duration));
-       part_stat_add(part, time_in_queue, duration);
        part_dec_in_flight(q, part, op_is_write(req_op));
 
        part_stat_unlock();
index 4401b30a17516cf9a14453e3fb4a4d651c349b30..eaf6cb3887e6fbc3c5a8360a720c314ddd9a21e5 100644 (file)
@@ -1340,7 +1340,6 @@ void blk_account_io_done(struct request *req, u64 now)
                update_io_ticks(part, jiffies, true);
                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));
                part_dec_in_flight(req->q, part, rq_data_dir(req));
 
                hd_struct_put(part);
index 9eb981f7e5a45dd8e7f3e6d65e8b69e87b6f753c..792356e922a1611b7d8e26076550d9cad2ee0642 100644 (file)
@@ -110,7 +110,6 @@ static void part_stat_read_all(struct hd_struct *part, struct disk_stats *stat)
                }
 
                stat->io_ticks += ptr->io_ticks;
-               stat->time_in_queue += ptr->time_in_queue;
        }
 }
 #else /* CONFIG_SMP */
@@ -1265,7 +1264,11 @@ ssize_t part_stat_show(struct device *dev,
                (unsigned int)div_u64(stat.nsecs[STAT_WRITE], NSEC_PER_MSEC),
                inflight,
                jiffies_to_msecs(stat.io_ticks),
-               jiffies_to_msecs(stat.time_in_queue),
+               (unsigned int)div_u64(stat.nsecs[STAT_READ] +
+                                     stat.nsecs[STAT_WRITE] +
+                                     stat.nsecs[STAT_DISCARD] +
+                                     stat.nsecs[STAT_FLUSH],
+                                               NSEC_PER_MSEC),
                stat.ios[STAT_DISCARD],
                stat.merges[STAT_DISCARD],
                (unsigned long long)stat.sectors[STAT_DISCARD],
@@ -1559,7 +1562,11 @@ static int diskstats_show(struct seq_file *seqf, void *v)
                                                        NSEC_PER_MSEC),
                           inflight,
                           jiffies_to_msecs(stat.io_ticks),
-                          jiffies_to_msecs(stat.time_in_queue),
+                          (unsigned int)div_u64(stat.nsecs[STAT_READ] +
+                                                stat.nsecs[STAT_WRITE] +
+                                                stat.nsecs[STAT_DISCARD] +
+                                                stat.nsecs[STAT_FLUSH],
+                                                       NSEC_PER_MSEC),
                           stat.ios[STAT_DISCARD],
                           stat.merges[STAT_DISCARD],
                           stat.sectors[STAT_DISCARD],
index b0c588d1aa2937fcba41b68cc4ce71ffb4706d3c..790fdc3e0b3d18c8a7510769d7dd951ac2cd7b80 100644 (file)
@@ -46,7 +46,6 @@ struct disk_stats {
        unsigned long ios[NR_STAT_GROUPS];
        unsigned long merges[NR_STAT_GROUPS];
        unsigned long io_ticks;
-       unsigned long time_in_queue;
        local_t in_flight[2];
 };