aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-cgroup.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/blk-cgroup.c')
-rw-r--r--block/blk-cgroup.c64
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
16extern void cfq_unlink_blkio_group(void *, struct blkio_group *); 18extern 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
28void 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
26void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, 35void 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
42static void __blkiocg_del_blkio_group(struct blkio_group *blkg) 52static 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) \
129static 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
151SHOW_FUNCTION_PER_GROUP(time);
152SHOW_FUNCTION_PER_GROUP(sectors);
153#ifdef CONFIG_DEBUG_BLK_CGROUP
154SHOW_FUNCTION_PER_GROUP(dequeue);
155#endif
156#undef SHOW_FUNCTION_PER_GROUP
157
158#ifdef CONFIG_DEBUG_BLK_CGROUP
159void blkiocg_update_blkio_group_dequeue_stats(struct blkio_group *blkg,
160 unsigned long dequeue)
161{
162 blkg->dequeue += dequeue;
163}
164#endif
165
118struct cftype blkio_files[] = { 166struct 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
126static int blkiocg_populate(struct cgroup_subsys *subsys, struct cgroup *cgroup) 188static int blkiocg_populate(struct cgroup_subsys *subsys, struct cgroup *cgroup)