diff options
author | Vivek Goyal <vgoyal@redhat.com> | 2009-12-03 12:59:49 -0500 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-12-03 13:28:52 -0500 |
commit | 220841906fccafaf4094e87bdb6d252e20cf8c7c (patch) | |
tree | f25b1f057887cf2a05bb8309e0b757149e052797 /block/blk-cgroup.c | |
parent | 2868ef7b39490e6b41c2c61cd9a5cd891e778b54 (diff) |
blkio: Export disk time and sectors used by a group to user space
o Export disk time and sector used by a group to user space through cgroup
interface.
o Also export a "dequeue" interface to cgroup which keeps track of how many
a times a group was deleted from service tree. Helps in debugging.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/blk-cgroup.c')
-rw-r--r-- | block/blk-cgroup.c | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 6bc99a3865b0..4ef78d35cbd2 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c | |||
@@ -11,6 +11,8 @@ | |||
11 | * Nauman Rafique <nauman@google.com> | 11 | * Nauman Rafique <nauman@google.com> |
12 | */ | 12 | */ |
13 | #include <linux/ioprio.h> | 13 | #include <linux/ioprio.h> |
14 | #include <linux/seq_file.h> | ||
15 | #include <linux/kdev_t.h> | ||
14 | #include "blk-cgroup.h" | 16 | #include "blk-cgroup.h" |
15 | 17 | ||
16 | extern void cfq_unlink_blkio_group(void *, struct blkio_group *); | 18 | extern void cfq_unlink_blkio_group(void *, struct blkio_group *); |
@@ -23,8 +25,15 @@ struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup) | |||
23 | struct blkio_cgroup, css); | 25 | struct blkio_cgroup, css); |
24 | } | 26 | } |
25 | 27 | ||
28 | void blkiocg_update_blkio_group_stats(struct blkio_group *blkg, | ||
29 | unsigned long time, unsigned long sectors) | ||
30 | { | ||
31 | blkg->time += time; | ||
32 | blkg->sectors += sectors; | ||
33 | } | ||
34 | |||
26 | void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, | 35 | void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, |
27 | struct blkio_group *blkg, void *key) | 36 | struct blkio_group *blkg, void *key, dev_t dev) |
28 | { | 37 | { |
29 | unsigned long flags; | 38 | unsigned long flags; |
30 | 39 | ||
@@ -37,6 +46,7 @@ void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, | |||
37 | /* Need to take css reference ? */ | 46 | /* Need to take css reference ? */ |
38 | cgroup_path(blkcg->css.cgroup, blkg->path, sizeof(blkg->path)); | 47 | cgroup_path(blkcg->css.cgroup, blkg->path, sizeof(blkg->path)); |
39 | #endif | 48 | #endif |
49 | blkg->dev = dev; | ||
40 | } | 50 | } |
41 | 51 | ||
42 | static void __blkiocg_del_blkio_group(struct blkio_group *blkg) | 52 | static void __blkiocg_del_blkio_group(struct blkio_group *blkg) |
@@ -115,12 +125,64 @@ blkiocg_weight_write(struct cgroup *cgroup, struct cftype *cftype, u64 val) | |||
115 | return 0; | 125 | return 0; |
116 | } | 126 | } |
117 | 127 | ||
128 | #define SHOW_FUNCTION_PER_GROUP(__VAR) \ | ||
129 | static int blkiocg_##__VAR##_read(struct cgroup *cgroup, \ | ||
130 | struct cftype *cftype, struct seq_file *m) \ | ||
131 | { \ | ||
132 | struct blkio_cgroup *blkcg; \ | ||
133 | struct blkio_group *blkg; \ | ||
134 | struct hlist_node *n; \ | ||
135 | \ | ||
136 | if (!cgroup_lock_live_group(cgroup)) \ | ||
137 | return -ENODEV; \ | ||
138 | \ | ||
139 | blkcg = cgroup_to_blkio_cgroup(cgroup); \ | ||
140 | rcu_read_lock(); \ | ||
141 | hlist_for_each_entry_rcu(blkg, n, &blkcg->blkg_list, blkcg_node) {\ | ||
142 | if (blkg->dev) \ | ||
143 | seq_printf(m, "%u:%u %lu\n", MAJOR(blkg->dev), \ | ||
144 | MINOR(blkg->dev), blkg->__VAR); \ | ||
145 | } \ | ||
146 | rcu_read_unlock(); \ | ||
147 | cgroup_unlock(); \ | ||
148 | return 0; \ | ||
149 | } | ||
150 | |||
151 | SHOW_FUNCTION_PER_GROUP(time); | ||
152 | SHOW_FUNCTION_PER_GROUP(sectors); | ||
153 | #ifdef CONFIG_DEBUG_BLK_CGROUP | ||
154 | SHOW_FUNCTION_PER_GROUP(dequeue); | ||
155 | #endif | ||
156 | #undef SHOW_FUNCTION_PER_GROUP | ||
157 | |||
158 | #ifdef CONFIG_DEBUG_BLK_CGROUP | ||
159 | void blkiocg_update_blkio_group_dequeue_stats(struct blkio_group *blkg, | ||
160 | unsigned long dequeue) | ||
161 | { | ||
162 | blkg->dequeue += dequeue; | ||
163 | } | ||
164 | #endif | ||
165 | |||
118 | struct cftype blkio_files[] = { | 166 | struct cftype blkio_files[] = { |
119 | { | 167 | { |
120 | .name = "weight", | 168 | .name = "weight", |
121 | .read_u64 = blkiocg_weight_read, | 169 | .read_u64 = blkiocg_weight_read, |
122 | .write_u64 = blkiocg_weight_write, | 170 | .write_u64 = blkiocg_weight_write, |
123 | }, | 171 | }, |
172 | { | ||
173 | .name = "time", | ||
174 | .read_seq_string = blkiocg_time_read, | ||
175 | }, | ||
176 | { | ||
177 | .name = "sectors", | ||
178 | .read_seq_string = blkiocg_sectors_read, | ||
179 | }, | ||
180 | #ifdef CONFIG_DEBUG_BLK_CGROUP | ||
181 | { | ||
182 | .name = "dequeue", | ||
183 | .read_seq_string = blkiocg_dequeue_read, | ||
184 | }, | ||
185 | #endif | ||
124 | }; | 186 | }; |
125 | 187 | ||
126 | static int blkiocg_populate(struct cgroup_subsys *subsys, struct cgroup *cgroup) | 188 | static int blkiocg_populate(struct cgroup_subsys *subsys, struct cgroup *cgroup) |