提交 07232d74 编写于 作者: X Xiaoguang Wang 提交者: Joseph Qi

alios: block: add counter to track io request's d2c time

Indeed tool iostat's await is not good enough, which is somewhat sketchy
and could not show request's latency on device driver's side.

Here we add a new counter to track io request's d2c time, also with this
patch, we can extend iostat to show this value easily.

Note:
I had checked how iostat is implemented, it just reads fields it needs,
so iostat won't be affected by this change, so does tsar.
Reviewed-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Signed-off-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Acked-by: NCaspar Zhang <caspar@linux.alibaba.com>
上级 2292db66
......@@ -184,6 +184,24 @@ your ``/etc/fstab``::
none /sys sysfs defaults 0 0
Field 12 -- # of discards completed
This is the total number of discards completed successfully.
Field 13 -- # of discards merged
See the description of field 2
Field 14 -- # of sectors discarded
This is the total number of sectors discarded successfully.
Field 15 -- # of milliseconds spent discarding
This is the total number of milliseconds spent by all discards (as
measured from __make_request() to end_that_request_last()).
Field 16 -- # of milliseconds spent reading on device driver's side
Field 17 -- # of milliseconds spent writing on device driver's side
Field 18 -- # of milliseconds spent discarding on device driver's side
In 2.6+, all disk statistics were removed from ``/proc/stat``. In 2.4, they
appear in both ``/proc/partitions`` and ``/proc/stat``, although the ones in
......
......@@ -2750,6 +2750,9 @@ void blk_account_io_done(struct request *req, u64 now)
part_stat_inc(cpu, part, ios[sgrp]);
part_stat_add(cpu, part, nsecs[sgrp], now - req->start_time_ns);
if (req->io_start_time_ns)
part_stat_add(cpu, part, d2c_nsecs[sgrp],
now - req->io_start_time_ns);
part_round_stats(req->q, cpu, part);
part_dec_in_flight(req->q, part, rq_data_dir(req));
......
......@@ -1356,7 +1356,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)
"%lu %lu %lu %u "
"%lu %lu %lu %u "
"%u %u %u "
"%lu %lu %lu %u\n",
"%lu %lu %lu %u %u %u %u\n",
MAJOR(part_devt(hd)), MINOR(part_devt(hd)),
disk_name(gp, hd->partno, buf),
part_stat_read(hd, ios[STAT_READ]),
......@@ -1373,7 +1373,10 @@ static int diskstats_show(struct seq_file *seqf, void *v)
part_stat_read(hd, ios[STAT_DISCARD]),
part_stat_read(hd, merges[STAT_DISCARD]),
part_stat_read(hd, sectors[STAT_DISCARD]),
(unsigned int)part_stat_read_msecs(hd, STAT_DISCARD)
(unsigned int)part_stat_read_msecs(hd, STAT_DISCARD),
(unsigned int)part_stat_read_d2c_msecs(hd, STAT_READ),
(unsigned int)part_stat_read_d2c_msecs(hd, STAT_WRITE),
(unsigned int)part_stat_read_d2c_msecs(hd, STAT_DISCARD)
);
}
disk_part_iter_exit(&piter);
......
......@@ -131,7 +131,7 @@ ssize_t part_stat_show(struct device *dev,
"%8lu %8lu %8llu %8u "
"%8lu %8lu %8llu %8u "
"%8u %8u %8u "
"%8lu %8lu %8llu %8u"
"%8lu %8lu %8llu %8u %8u %8u %8u"
"\n",
part_stat_read(p, ios[STAT_READ]),
part_stat_read(p, merges[STAT_READ]),
......@@ -147,7 +147,10 @@ ssize_t part_stat_show(struct device *dev,
part_stat_read(p, ios[STAT_DISCARD]),
part_stat_read(p, merges[STAT_DISCARD]),
(unsigned long long)part_stat_read(p, sectors[STAT_DISCARD]),
(unsigned int)part_stat_read_msecs(p, STAT_DISCARD));
(unsigned int)part_stat_read_msecs(p, STAT_DISCARD),
(unsigned int)part_stat_read_d2c_msecs(p, STAT_READ),
(unsigned int)part_stat_read_d2c_msecs(p, STAT_WRITE),
(unsigned int)part_stat_read_d2c_msecs(p, STAT_DISCARD));
}
ssize_t part_inflight_show(struct device *dev, struct device_attribute *attr,
......
......@@ -84,6 +84,7 @@ struct partition {
struct disk_stats {
u64 nsecs[NR_STAT_GROUPS];
u64 d2c_nsecs[NR_STAT_GROUPS];
unsigned long sectors[NR_STAT_GROUPS];
unsigned long ios[NR_STAT_GROUPS];
unsigned long merges[NR_STAT_GROUPS];
......@@ -361,6 +362,9 @@ static inline void free_part_stats(struct hd_struct *part)
#define part_stat_read_msecs(part, which) \
div_u64(part_stat_read(part, nsecs[which]), NSEC_PER_MSEC)
#define part_stat_read_d2c_msecs(part, which) \
div_u64(part_stat_read(part, d2c_nsecs[which]), NSEC_PER_MSEC)
#define part_stat_read_accum(part, field) \
(part_stat_read(part, field[STAT_READ]) + \
part_stat_read(part, field[STAT_WRITE]) + \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册