[PATCH 1/7] block: keep track of per-device io sizes in stats

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jes Sorensen <jsorensen@xxxxxx>

In order to provide blk stat heuristics, we need to track request
sizes per device. This relies on blk_rq_stats_sectors() introduced in
3d24430694077313c75c6b89f618db09943621e4. Add a field to the
blk_rq_stat to hold this information so that consumers of the
blk_rq_stat stuff can use it.

Based on a previous patch by Josef Bacik <josef@xxxxxxxxxxxxxx>

Signed-off-by: Jes Sorensen <jsorensen@xxxxxx>
---
 block/blk-iolatency.c     |  2 +-
 block/blk-stat.c          | 14 ++++++++------
 block/blk-stat.h          |  2 +-
 include/linux/blk_types.h |  1 +
 4 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c
index c128d50cb410..ca0eba5fedf7 100644
--- a/block/blk-iolatency.c
+++ b/block/blk-iolatency.c
@@ -219,7 +219,7 @@ static inline void latency_stat_record_time(struct iolatency_grp *iolat,
 			stat->ps.missed++;
 		stat->ps.total++;
 	} else
-		blk_rq_stat_add(&stat->rqs, req_time);
+		blk_rq_stat_add(&stat->rqs, req_time, 0);
 	put_cpu_ptr(stat);
 }
 
diff --git a/block/blk-stat.c b/block/blk-stat.c
index 7da302ff88d0..dd5c9c8989a5 100644
--- a/block/blk-stat.c
+++ b/block/blk-stat.c
@@ -21,7 +21,7 @@ struct blk_queue_stats {
 void blk_rq_stat_init(struct blk_rq_stat *stat)
 {
 	stat->min = -1ULL;
-	stat->max = stat->nr_samples = stat->mean = 0;
+	stat->max = stat->nr_samples = stat->mean = stat->sectors = 0;
 	stat->batch = 0;
 }
 
@@ -38,13 +38,15 @@ void blk_rq_stat_sum(struct blk_rq_stat *dst, struct blk_rq_stat *src)
 				dst->nr_samples + src->nr_samples);
 
 	dst->nr_samples += src->nr_samples;
+	dst->sectors += src->sectors;
 }
 
-void blk_rq_stat_add(struct blk_rq_stat *stat, u64 value)
+void blk_rq_stat_add(struct blk_rq_stat *stat, u64 time, u64 sectors)
 {
-	stat->min = min(stat->min, value);
-	stat->max = max(stat->max, value);
-	stat->batch += value;
+	stat->min = min(stat->min, time);
+	stat->max = max(stat->max, time);
+	stat->batch += time;
+	stat->sectors += sectors;
 	stat->nr_samples++;
 }
 
@@ -71,7 +73,7 @@ void blk_stat_add(struct request *rq, u64 now)
 			continue;
 
 		stat = &per_cpu_ptr(cb->cpu_stat, cpu)[bucket];
-		blk_rq_stat_add(stat, value);
+		blk_rq_stat_add(stat, value, blk_rq_stats_sectors(rq));
 	}
 	put_cpu();
 	rcu_read_unlock();
diff --git a/block/blk-stat.h b/block/blk-stat.h
index 17b47a86eefb..ea893c4a9af1 100644
--- a/block/blk-stat.h
+++ b/block/blk-stat.h
@@ -164,7 +164,7 @@ static inline void blk_stat_activate_msecs(struct blk_stat_callback *cb,
 	mod_timer(&cb->timer, jiffies + msecs_to_jiffies(msecs));
 }
 
-void blk_rq_stat_add(struct blk_rq_stat *, u64);
+void blk_rq_stat_add(struct blk_rq_stat *, u64, u64);
 void blk_rq_stat_sum(struct blk_rq_stat *, struct blk_rq_stat *);
 void blk_rq_stat_init(struct blk_rq_stat *);
 
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 70254ae11769..4db37b220367 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -482,6 +482,7 @@ struct blk_rq_stat {
 	u64 max;
 	u32 nr_samples;
 	u64 batch;
+	u64 sectors;
 };
 
 #endif /* __LINUX_BLK_TYPES_H */
-- 
2.17.1




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux