summaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorJens Axboe <axboe@suse.de>2005-11-01 09:26:16 +0100
committerJens Axboe <axboe@suse.de>2005-11-01 09:26:16 +0100
commita362357b6cd62643d4dda3b152639303d78473da (patch)
treefe4ce823e638ded151edcb142f28a240860f0d33 /drivers/block
parentd72d904a5367ad4ca3f2c9a2ce8c3a68f0b28bf0 (diff)
downloadop-kernel-dev-a362357b6cd62643d4dda3b152639303d78473da.zip
op-kernel-dev-a362357b6cd62643d4dda3b152639303d78473da.tar.gz
[BLOCK] Unify the seperate read/write io stat fields into arrays
Instead of having ->read_sectors and ->write_sectors, combine the two into ->sectors[2] and similar for the other fields. This saves a branch several places in the io path, since we don't have to care for what the actual io direction is. On my x86-64 box, that's 200 bytes less text in just the core (not counting the various drivers). Signed-off-by: Jens Axboe <axboe@suse.de>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/genhd.c29
-rw-r--r--drivers/block/ll_rw_blk.c40
2 files changed, 26 insertions, 43 deletions
diff --git a/drivers/block/genhd.c b/drivers/block/genhd.c
index 486ce1f..54aec4a 100644
--- a/drivers/block/genhd.c
+++ b/drivers/block/genhd.c
@@ -391,13 +391,12 @@ static ssize_t disk_stats_read(struct gendisk * disk, char *page)
"%8u %8u %8llu %8u "
"%8u %8u %8u"
"\n",
- disk_stat_read(disk, reads), disk_stat_read(disk, read_merges),
- (unsigned long long)disk_stat_read(disk, read_sectors),
- jiffies_to_msecs(disk_stat_read(disk, read_ticks)),
- disk_stat_read(disk, writes),
- disk_stat_read(disk, write_merges),
- (unsigned long long)disk_stat_read(disk, write_sectors),
- jiffies_to_msecs(disk_stat_read(disk, write_ticks)),
+ disk_stat_read(disk, ios[0]), disk_stat_read(disk, merges[0]),
+ (unsigned long long)disk_stat_read(disk, sectors[0]),
+ jiffies_to_msecs(disk_stat_read(disk, ticks[0])),
+ disk_stat_read(disk, ios[1]), disk_stat_read(disk, merges[1]),
+ (unsigned long long)disk_stat_read(disk, sectors[1]),
+ jiffies_to_msecs(disk_stat_read(disk, ticks[1])),
disk->in_flight,
jiffies_to_msecs(disk_stat_read(disk, io_ticks)),
jiffies_to_msecs(disk_stat_read(disk, time_in_queue)));
@@ -583,12 +582,12 @@ static int diskstats_show(struct seq_file *s, void *v)
preempt_enable();
seq_printf(s, "%4d %4d %s %u %u %llu %u %u %u %llu %u %u %u %u\n",
gp->major, n + gp->first_minor, disk_name(gp, n, buf),
- disk_stat_read(gp, reads), disk_stat_read(gp, read_merges),
- (unsigned long long)disk_stat_read(gp, read_sectors),
- jiffies_to_msecs(disk_stat_read(gp, read_ticks)),
- disk_stat_read(gp, writes), disk_stat_read(gp, write_merges),
- (unsigned long long)disk_stat_read(gp, write_sectors),
- jiffies_to_msecs(disk_stat_read(gp, write_ticks)),
+ disk_stat_read(gp, ios[0]), disk_stat_read(gp, merges[0]),
+ (unsigned long long)disk_stat_read(gp, sectors[0]),
+ jiffies_to_msecs(disk_stat_read(gp, ticks[0])),
+ disk_stat_read(gp, ios[1]), disk_stat_read(gp, merges[1]),
+ (unsigned long long)disk_stat_read(gp, sectors[1]),
+ jiffies_to_msecs(disk_stat_read(gp, ticks[1])),
gp->in_flight,
jiffies_to_msecs(disk_stat_read(gp, io_ticks)),
jiffies_to_msecs(disk_stat_read(gp, time_in_queue)));
@@ -601,8 +600,8 @@ static int diskstats_show(struct seq_file *s, void *v)
seq_printf(s, "%4d %4d %s %u %u %u %u\n",
gp->major, n + gp->first_minor + 1,
disk_name(gp, n + 1, buf),
- hd->reads, hd->read_sectors,
- hd->writes, hd->write_sectors);
+ hd->ios[0], hd->sectors[0],
+ hd->ios[1], hd->sectors[1]);
}
return 0;
diff --git a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c
index 1b27288..2747741 100644
--- a/drivers/block/ll_rw_blk.c
+++ b/drivers/block/ll_rw_blk.c
@@ -2388,10 +2388,7 @@ static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io)
return;
if (!new_io) {
- if (rw == READ)
- __disk_stat_inc(rq->rq_disk, read_merges);
- else
- __disk_stat_inc(rq->rq_disk, write_merges);
+ __disk_stat_inc(rq->rq_disk, merges[rw]);
} else {
disk_round_stats(rq->rq_disk);
rq->rq_disk->in_flight++;
@@ -2787,17 +2784,11 @@ static inline void blk_partition_remap(struct bio *bio)
if (bdev != bdev->bd_contains) {
struct hd_struct *p = bdev->bd_part;
+ const int rw = bio_data_dir(bio);
+
+ p->sectors[rw] += bio_sectors(bio);
+ p->ios[rw]++;
- switch (bio_data_dir(bio)) {
- case READ:
- p->read_sectors += bio_sectors(bio);
- p->reads++;
- break;
- case WRITE:
- p->write_sectors += bio_sectors(bio);
- p->writes++;
- break;
- }
bio->bi_sector += p->start_sect;
bio->bi_bdev = bdev->bd_contains;
}
@@ -3045,10 +3036,9 @@ static int __end_that_request_first(struct request *req, int uptodate,
}
if (blk_fs_request(req) && req->rq_disk) {
- if (rq_data_dir(req) == READ)
- __disk_stat_add(req->rq_disk, read_sectors, nr_bytes >> 9);
- else
- __disk_stat_add(req->rq_disk, write_sectors, nr_bytes >> 9);
+ const int rw = rq_data_dir(req);
+
+ __disk_stat_add(req->rq_disk, sectors[rw], nr_bytes >> 9);
}
total_bytes = bio_nbytes = 0;
@@ -3179,16 +3169,10 @@ void end_that_request_last(struct request *req)
if (disk && blk_fs_request(req)) {
unsigned long duration = jiffies - req->start_time;
- switch (rq_data_dir(req)) {
- case WRITE:
- __disk_stat_inc(disk, writes);
- __disk_stat_add(disk, write_ticks, duration);
- break;
- case READ:
- __disk_stat_inc(disk, reads);
- __disk_stat_add(disk, read_ticks, duration);
- break;
- }
+ const int rw = rq_data_dir(req);
+
+ __disk_stat_inc(disk, ios[rw]);
+ __disk_stat_add(disk, ticks[rw], duration);
disk_round_stats(disk);
disk->in_flight--;
}
OpenPOWER on IntegriCloud