My brain just fell out. Why don't we just do
return (x / HZ) * 1000;
?
Yes, it'll return zero for the first second of disk activity.
I don't think that matters?
return ((x + HZ / 2) / HZ) * 1000;
would be more accurate too, and reduces it to half a second ;)
--- 25/drivers/block/genhd.c~msec-fix Tue Nov 5 21:59:35 2002
+++ 25-akpm/drivers/block/genhd.c Tue Nov 5 22:02:17 2002
@@ -324,10 +324,12 @@ static ssize_t disk_size_read(struct gen
{
return off ? 0 : sprintf(page, "%llu\n",(unsigned long long)get_capacity(disk));
}
-static inline unsigned MSEC(unsigned x)
+
+static unsigned jiffies_to_msec(unsigned jif)
{
- return x * 1000 / HZ;
+ return ((jif + HZ / 2) / HZ) * 1000;
}
+
static ssize_t disk_stat_read(struct gendisk * disk,
char *page, size_t count, loff_t off)
{
@@ -338,11 +340,11 @@ static ssize_t disk_stat_read(struct gen
"%8u %8u %8u"
"\n",
disk->reads, disk->read_merges, (u64)disk->read_sectors,
- MSEC(disk->read_ticks),
+ jiffies_to_msec(disk->read_ticks),
disk->writes, disk->write_merges, (u64)disk->write_sectors,
- MSEC(disk->write_ticks),
- disk->in_flight, MSEC(disk->io_ticks),
- MSEC(disk->time_in_queue));
+ jiffies_to_msec(disk->write_ticks),
+ disk->in_flight, jiffies_to_msec(disk->io_ticks),
+ jiffies_to_msec(disk->time_in_queue));
}
static struct disk_attribute disk_attr_dev = {
.attr = {.name = "dev", .mode = S_IRUGO },
_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/