aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-cgroup.h
diff options
context:
space:
mode:
authorDivyesh Shah <dpshah@google.com>2010-04-09 02:31:19 -0400
committerJens Axboe <jens.axboe@oracle.com>2010-04-09 02:31:19 -0400
commit84c124da9ff50bd71fab9c939ee5b7cd8bef2bd9 (patch)
treef94ad03b56c71ebbe6b92265054c5e24af25b869 /block/blk-cgroup.h
parent31373d09da5b7fe21fe6f781e92bd534a3495f00 (diff)
blkio: Changes to IO controller additional stats patches
that include some minor fixes and addresses all comments. Changelog: (most based on Vivek Goyal's comments) o renamed blkiocg_reset_write to blkiocg_reset_stats o more clarification in the documentation on io_service_time and io_wait_time o Initialize blkg->stats_lock o rename io_add_stat to blkio_add_stat and declare it static o use bool for direction and sync o derive direction and sync info from existing rq methods o use 12 for major:minor string length o define io_service_time better to cover the NCQ case o add a separate reset_stats interface o make the indexed stats a 2d array to simplify macro and function pointer code o blkio.time now exports in jiffies as before o Added stats description in patch description and Documentation/cgroup/blkio-controller.txt o Prefix all stats functions with blkio and make them static as applicable o replace IO_TYPE_MAX with IO_TYPE_TOTAL o Moved #define constant to top of blk-cgroup.c o Pass dev_t around instead of char * o Add note to documentation file about resetting stats o use BLK_CGROUP_MODULE in addition to BLK_CGROUP config option in #ifdef statements o Avoid struct request specific knowledge in blk-cgroup. blk-cgroup.h now has rq_direction() and rq_sync() functions which are used by CFQ and when using io-controller at a higher level, bio_* functions can be added. Signed-off-by: Divyesh Shah<dpshah@google.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/blk-cgroup.h')
-rw-r--r--block/blk-cgroup.h64
1 files changed, 39 insertions, 25 deletions
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index 80010ef64ab0..b22e55390a4f 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -23,12 +23,31 @@ extern struct cgroup_subsys blkio_subsys;
23#define blkio_subsys_id blkio_subsys.subsys_id 23#define blkio_subsys_id blkio_subsys.subsys_id
24#endif 24#endif
25 25
26enum io_type { 26enum stat_type {
27 IO_READ = 0, 27 /* Total time spent (in ns) between request dispatch to the driver and
28 IO_WRITE, 28 * request completion for IOs doen by this cgroup. This may not be
29 IO_SYNC, 29 * accurate when NCQ is turned on. */
30 IO_ASYNC, 30 BLKIO_STAT_SERVICE_TIME = 0,
31 IO_TYPE_MAX 31 /* Total bytes transferred */
32 BLKIO_STAT_SERVICE_BYTES,
33 /* Total IOs serviced, post merge */
34 BLKIO_STAT_SERVICED,
35 /* Total time spent waiting in scheduler queue in ns */
36 BLKIO_STAT_WAIT_TIME,
37 /* All the single valued stats go below this */
38 BLKIO_STAT_TIME,
39 BLKIO_STAT_SECTORS,
40#ifdef CONFIG_DEBUG_BLK_CGROUP
41 BLKIO_STAT_DEQUEUE
42#endif
43};
44
45enum stat_sub_type {
46 BLKIO_STAT_READ = 0,
47 BLKIO_STAT_WRITE,
48 BLKIO_STAT_SYNC,
49 BLKIO_STAT_ASYNC,
50 BLKIO_STAT_TOTAL
32}; 51};
33 52
34struct blkio_cgroup { 53struct blkio_cgroup {
@@ -42,13 +61,7 @@ struct blkio_group_stats {
42 /* total disk time and nr sectors dispatched by this group */ 61 /* total disk time and nr sectors dispatched by this group */
43 uint64_t time; 62 uint64_t time;
44 uint64_t sectors; 63 uint64_t sectors;
45 /* Total disk time used by IOs in ns */ 64 uint64_t stat_arr[BLKIO_STAT_WAIT_TIME + 1][BLKIO_STAT_TOTAL];
46 uint64_t io_service_time[IO_TYPE_MAX];
47 uint64_t io_service_bytes[IO_TYPE_MAX]; /* Total bytes transferred */
48 /* Total IOs serviced, post merge */
49 uint64_t io_serviced[IO_TYPE_MAX];
50 /* Total time spent waiting in scheduler queue in ns */
51 uint64_t io_wait_time[IO_TYPE_MAX];
52#ifdef CONFIG_DEBUG_BLK_CGROUP 65#ifdef CONFIG_DEBUG_BLK_CGROUP
53 /* How many times this group has been removed from service tree */ 66 /* How many times this group has been removed from service tree */
54 unsigned long dequeue; 67 unsigned long dequeue;
@@ -65,7 +78,7 @@ struct blkio_group {
65 char path[128]; 78 char path[128];
66#endif 79#endif
67 /* The device MKDEV(major, minor), this group has been created for */ 80 /* The device MKDEV(major, minor), this group has been created for */
68 dev_t dev; 81 dev_t dev;
69 82
70 /* Need to serialize the stats in the case of reset/update */ 83 /* Need to serialize the stats in the case of reset/update */
71 spinlock_t stats_lock; 84 spinlock_t stats_lock;
@@ -128,21 +141,21 @@ extern void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg,
128extern int blkiocg_del_blkio_group(struct blkio_group *blkg); 141extern int blkiocg_del_blkio_group(struct blkio_group *blkg);
129extern struct blkio_group *blkiocg_lookup_group(struct blkio_cgroup *blkcg, 142extern struct blkio_group *blkiocg_lookup_group(struct blkio_cgroup *blkcg,
130 void *key); 143 void *key);
144void blkio_group_init(struct blkio_group *blkg);
131void blkiocg_update_timeslice_used(struct blkio_group *blkg, 145void blkiocg_update_timeslice_used(struct blkio_group *blkg,
132 unsigned long time); 146 unsigned long time);
133void blkiocg_update_request_dispatch_stats(struct blkio_group *blkg, 147void blkiocg_update_dispatch_stats(struct blkio_group *blkg, uint64_t bytes,
134 struct request *rq); 148 bool direction, bool sync);
135void blkiocg_update_request_completion_stats(struct blkio_group *blkg, 149void blkiocg_update_completion_stats(struct blkio_group *blkg,
136 struct request *rq); 150 uint64_t start_time, uint64_t io_start_time, bool direction, bool sync);
137#else 151#else
138struct cgroup; 152struct cgroup;
139static inline struct blkio_cgroup * 153static inline struct blkio_cgroup *
140cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; } 154cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; }
141 155
156static inline void blkio_group_init(struct blkio_group *blkg) {}
142static inline void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, 157static inline void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg,
143 struct blkio_group *blkg, void *key, dev_t dev) 158 struct blkio_group *blkg, void *key, dev_t dev) {}
144{
145}
146 159
147static inline int 160static inline int
148blkiocg_del_blkio_group(struct blkio_group *blkg) { return 0; } 161blkiocg_del_blkio_group(struct blkio_group *blkg) { return 0; }
@@ -151,9 +164,10 @@ static inline struct blkio_group *
151blkiocg_lookup_group(struct blkio_cgroup *blkcg, void *key) { return NULL; } 164blkiocg_lookup_group(struct blkio_cgroup *blkcg, void *key) { return NULL; }
152static inline void blkiocg_update_timeslice_used(struct blkio_group *blkg, 165static inline void blkiocg_update_timeslice_used(struct blkio_group *blkg,
153 unsigned long time) {} 166 unsigned long time) {}
154static inline void blkiocg_update_request_dispatch_stats( 167static inline void blkiocg_update_dispatch_stats(struct blkio_group *blkg,
155 struct blkio_group *blkg, struct request *rq) {} 168 uint64_t bytes, bool direction, bool sync) {}
156static inline void blkiocg_update_request_completion_stats( 169static inline void blkiocg_update_completion_stats(struct blkio_group *blkg,
157 struct blkio_group *blkg, struct request *rq) {} 170 uint64_t start_time, uint64_t io_start_time, bool direction,
171 bool sync) {}
158#endif 172#endif
159#endif /* _BLK_CGROUP_H */ 173#endif /* _BLK_CGROUP_H */