diff options
author | Jens Axboe <axboe@suse.de> | 2005-11-01 03:26:16 -0500 |
---|---|---|
committer | Jens Axboe <axboe@suse.de> | 2005-11-01 03:26:16 -0500 |
commit | a362357b6cd62643d4dda3b152639303d78473da (patch) | |
tree | fe4ce823e638ded151edcb142f28a240860f0d33 /drivers/block | |
parent | d72d904a5367ad4ca3f2c9a2ce8c3a68f0b28bf0 (diff) |
[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.c | 29 | ||||
-rw-r--r-- | drivers/block/ll_rw_blk.c | 40 |
2 files changed, 26 insertions, 43 deletions
diff --git a/drivers/block/genhd.c b/drivers/block/genhd.c index 486ce1fdeb8c..54aec4a1ae13 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) | |||
391 | "%8u %8u %8llu %8u " | 391 | "%8u %8u %8llu %8u " |
392 | "%8u %8u %8u" | 392 | "%8u %8u %8u" |
393 | "\n", | 393 | "\n", |
394 | disk_stat_read(disk, reads), disk_stat_read(disk, read_merges), | 394 | disk_stat_read(disk, ios[0]), disk_stat_read(disk, merges[0]), |
395 | (unsigned long long)disk_stat_read(disk, read_sectors), | 395 | (unsigned long long)disk_stat_read(disk, sectors[0]), |
396 | jiffies_to_msecs(disk_stat_read(disk, read_ticks)), | 396 | jiffies_to_msecs(disk_stat_read(disk, ticks[0])), |
397 | disk_stat_read(disk, writes), | 397 | disk_stat_read(disk, ios[1]), disk_stat_read(disk, merges[1]), |
398 | disk_stat_read(disk, write_merges), | 398 | (unsigned long long)disk_stat_read(disk, sectors[1]), |
399 | (unsigned long long)disk_stat_read(disk, write_sectors), | 399 | jiffies_to_msecs(disk_stat_read(disk, ticks[1])), |
400 | jiffies_to_msecs(disk_stat_read(disk, write_ticks)), | ||
401 | disk->in_flight, | 400 | disk->in_flight, |
402 | jiffies_to_msecs(disk_stat_read(disk, io_ticks)), | 401 | jiffies_to_msecs(disk_stat_read(disk, io_ticks)), |
403 | jiffies_to_msecs(disk_stat_read(disk, time_in_queue))); | 402 | jiffies_to_msecs(disk_stat_read(disk, time_in_queue))); |
@@ -583,12 +582,12 @@ static int diskstats_show(struct seq_file *s, void *v) | |||
583 | preempt_enable(); | 582 | preempt_enable(); |
584 | seq_printf(s, "%4d %4d %s %u %u %llu %u %u %u %llu %u %u %u %u\n", | 583 | seq_printf(s, "%4d %4d %s %u %u %llu %u %u %u %llu %u %u %u %u\n", |
585 | gp->major, n + gp->first_minor, disk_name(gp, n, buf), | 584 | gp->major, n + gp->first_minor, disk_name(gp, n, buf), |
586 | disk_stat_read(gp, reads), disk_stat_read(gp, read_merges), | 585 | disk_stat_read(gp, ios[0]), disk_stat_read(gp, merges[0]), |
587 | (unsigned long long)disk_stat_read(gp, read_sectors), | 586 | (unsigned long long)disk_stat_read(gp, sectors[0]), |
588 | jiffies_to_msecs(disk_stat_read(gp, read_ticks)), | 587 | jiffies_to_msecs(disk_stat_read(gp, ticks[0])), |
589 | disk_stat_read(gp, writes), disk_stat_read(gp, write_merges), | 588 | disk_stat_read(gp, ios[1]), disk_stat_read(gp, merges[1]), |
590 | (unsigned long long)disk_stat_read(gp, write_sectors), | 589 | (unsigned long long)disk_stat_read(gp, sectors[1]), |
591 | jiffies_to_msecs(disk_stat_read(gp, write_ticks)), | 590 | jiffies_to_msecs(disk_stat_read(gp, ticks[1])), |
592 | gp->in_flight, | 591 | gp->in_flight, |
593 | jiffies_to_msecs(disk_stat_read(gp, io_ticks)), | 592 | jiffies_to_msecs(disk_stat_read(gp, io_ticks)), |
594 | jiffies_to_msecs(disk_stat_read(gp, time_in_queue))); | 593 | jiffies_to_msecs(disk_stat_read(gp, time_in_queue))); |
@@ -601,8 +600,8 @@ static int diskstats_show(struct seq_file *s, void *v) | |||
601 | seq_printf(s, "%4d %4d %s %u %u %u %u\n", | 600 | seq_printf(s, "%4d %4d %s %u %u %u %u\n", |
602 | gp->major, n + gp->first_minor + 1, | 601 | gp->major, n + gp->first_minor + 1, |
603 | disk_name(gp, n + 1, buf), | 602 | disk_name(gp, n + 1, buf), |
604 | hd->reads, hd->read_sectors, | 603 | hd->ios[0], hd->sectors[0], |
605 | hd->writes, hd->write_sectors); | 604 | hd->ios[1], hd->sectors[1]); |
606 | } | 605 | } |
607 | 606 | ||
608 | return 0; | 607 | return 0; |
diff --git a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c index 1b272883aadf..2747741677fb 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) | |||
2388 | return; | 2388 | return; |
2389 | 2389 | ||
2390 | if (!new_io) { | 2390 | if (!new_io) { |
2391 | if (rw == READ) | 2391 | __disk_stat_inc(rq->rq_disk, merges[rw]); |
2392 | __disk_stat_inc(rq->rq_disk, read_merges); | ||
2393 | else | ||
2394 | __disk_stat_inc(rq->rq_disk, write_merges); | ||
2395 | } else { | 2392 | } else { |
2396 | disk_round_stats(rq->rq_disk); | 2393 | disk_round_stats(rq->rq_disk); |
2397 | rq->rq_disk->in_flight++; | 2394 | rq->rq_disk->in_flight++; |
@@ -2787,17 +2784,11 @@ static inline void blk_partition_remap(struct bio *bio) | |||
2787 | 2784 | ||
2788 | if (bdev != bdev->bd_contains) { | 2785 | if (bdev != bdev->bd_contains) { |
2789 | struct hd_struct *p = bdev->bd_part; | 2786 | struct hd_struct *p = bdev->bd_part; |
2787 | const int rw = bio_data_dir(bio); | ||
2788 | |||
2789 | p->sectors[rw] += bio_sectors(bio); | ||
2790 | p->ios[rw]++; | ||
2790 | 2791 | ||
2791 | switch (bio_data_dir(bio)) { | ||
2792 | case READ: | ||
2793 | p->read_sectors += bio_sectors(bio); | ||
2794 | p->reads++; | ||
2795 | break; | ||
2796 | case WRITE: | ||
2797 | p->write_sectors += bio_sectors(bio); | ||
2798 | p->writes++; | ||
2799 | break; | ||
2800 | } | ||
2801 | bio->bi_sector += p->start_sect; | 2792 | bio->bi_sector += p->start_sect; |
2802 | bio->bi_bdev = bdev->bd_contains; | 2793 | bio->bi_bdev = bdev->bd_contains; |
2803 | } | 2794 | } |
@@ -3045,10 +3036,9 @@ static int __end_that_request_first(struct request *req, int uptodate, | |||
3045 | } | 3036 | } |
3046 | 3037 | ||
3047 | if (blk_fs_request(req) && req->rq_disk) { | 3038 | if (blk_fs_request(req) && req->rq_disk) { |
3048 | if (rq_data_dir(req) == READ) | 3039 | const int rw = rq_data_dir(req); |
3049 | __disk_stat_add(req->rq_disk, read_sectors, nr_bytes >> 9); | 3040 | |
3050 | else | 3041 | __disk_stat_add(req->rq_disk, sectors[rw], nr_bytes >> 9); |
3051 | __disk_stat_add(req->rq_disk, write_sectors, nr_bytes >> 9); | ||
3052 | } | 3042 | } |
3053 | 3043 | ||
3054 | total_bytes = bio_nbytes = 0; | 3044 | total_bytes = bio_nbytes = 0; |
@@ -3179,16 +3169,10 @@ void end_that_request_last(struct request *req) | |||
3179 | 3169 | ||
3180 | if (disk && blk_fs_request(req)) { | 3170 | if (disk && blk_fs_request(req)) { |
3181 | unsigned long duration = jiffies - req->start_time; | 3171 | unsigned long duration = jiffies - req->start_time; |
3182 | switch (rq_data_dir(req)) { | 3172 | const int rw = rq_data_dir(req); |
3183 | case WRITE: | 3173 | |
3184 | __disk_stat_inc(disk, writes); | 3174 | __disk_stat_inc(disk, ios[rw]); |
3185 | __disk_stat_add(disk, write_ticks, duration); | 3175 | __disk_stat_add(disk, ticks[rw], duration); |
3186 | break; | ||
3187 | case READ: | ||
3188 | __disk_stat_inc(disk, reads); | ||
3189 | __disk_stat_add(disk, read_ticks, duration); | ||
3190 | break; | ||
3191 | } | ||
3192 | disk_round_stats(disk); | 3176 | disk_round_stats(disk); |
3193 | disk->in_flight--; | 3177 | disk->in_flight--; |
3194 | } | 3178 | } |