aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/blk-cgroup.c64
-rw-r--r--block/blk-cgroup.h22
-rw-r--r--block/cfq-iosched.c19
3 files changed, 99 insertions, 6 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)
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index 3573199b298b..b24ab71db826 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -30,7 +30,15 @@ struct blkio_group {
30#ifdef CONFIG_DEBUG_BLK_CGROUP 30#ifdef CONFIG_DEBUG_BLK_CGROUP
31 /* Store cgroup path */ 31 /* Store cgroup path */
32 char path[128]; 32 char path[128];
33 /* How many times this group has been removed from service tree */
34 unsigned long dequeue;
33#endif 35#endif
36 /* The device MKDEV(major, minor), this group has been created for */
37 dev_t dev;
38
39 /* total disk time and nr sectors dispatched by this group */
40 unsigned long time;
41 unsigned long sectors;
34}; 42};
35 43
36#define BLKIO_WEIGHT_MIN 100 44#define BLKIO_WEIGHT_MIN 100
@@ -42,24 +50,30 @@ static inline char *blkg_path(struct blkio_group *blkg)
42{ 50{
43 return blkg->path; 51 return blkg->path;
44} 52}
53void blkiocg_update_blkio_group_dequeue_stats(struct blkio_group *blkg,
54 unsigned long dequeue);
45#else 55#else
46static inline char *blkg_path(struct blkio_group *blkg) { return NULL; } 56static inline char *blkg_path(struct blkio_group *blkg) { return NULL; }
57static inline void blkiocg_update_blkio_group_dequeue_stats(
58 struct blkio_group *blkg, unsigned long dequeue) {}
47#endif 59#endif
48 60
49#ifdef CONFIG_BLK_CGROUP 61#ifdef CONFIG_BLK_CGROUP
50extern struct blkio_cgroup blkio_root_cgroup; 62extern struct blkio_cgroup blkio_root_cgroup;
51extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup); 63extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup);
52extern void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, 64extern void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg,
53 struct blkio_group *blkg, void *key); 65 struct blkio_group *blkg, void *key, dev_t dev);
54extern int blkiocg_del_blkio_group(struct blkio_group *blkg); 66extern int blkiocg_del_blkio_group(struct blkio_group *blkg);
55extern struct blkio_group *blkiocg_lookup_group(struct blkio_cgroup *blkcg, 67extern struct blkio_group *blkiocg_lookup_group(struct blkio_cgroup *blkcg,
56 void *key); 68 void *key);
69void blkiocg_update_blkio_group_stats(struct blkio_group *blkg,
70 unsigned long time, unsigned long sectors);
57#else 71#else
58static inline struct blkio_cgroup * 72static inline struct blkio_cgroup *
59cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; } 73cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; }
60 74
61static inline void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, 75static inline void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg,
62 struct blkio_group *blkg, void *key) 76 struct blkio_group *blkg, void *key, dev_t dev)
63{ 77{
64} 78}
65 79
@@ -68,5 +82,9 @@ blkiocg_del_blkio_group(struct blkio_group *blkg) { return 0; }
68 82
69static inline struct blkio_group * 83static inline struct blkio_group *
70blkiocg_lookup_group(struct blkio_cgroup *blkcg, void *key) { return NULL; } 84blkiocg_lookup_group(struct blkio_cgroup *blkcg, void *key) { return NULL; }
85static inline void blkiocg_update_blkio_group_stats(struct blkio_group *blkg,
86 unsigned long time, unsigned long sectors)
87{
88}
71#endif 89#endif
72#endif /* _BLK_CGROUP_H */ 90#endif /* _BLK_CGROUP_H */
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 662d4e55b3c2..7d345e772d88 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -143,6 +143,8 @@ struct cfq_queue {
143 struct cfq_rb_root *service_tree; 143 struct cfq_rb_root *service_tree;
144 struct cfq_queue *new_cfqq; 144 struct cfq_queue *new_cfqq;
145 struct cfq_group *cfqg; 145 struct cfq_group *cfqg;
146 /* Sectors dispatched in current dispatch round */
147 unsigned long nr_sectors;
146}; 148};
147 149
148/* 150/*
@@ -852,6 +854,7 @@ cfq_group_service_tree_del(struct cfq_data *cfqd, struct cfq_group *cfqg)
852 if (!RB_EMPTY_NODE(&cfqg->rb_node)) 854 if (!RB_EMPTY_NODE(&cfqg->rb_node))
853 cfq_rb_erase(&cfqg->rb_node, st); 855 cfq_rb_erase(&cfqg->rb_node, st);
854 cfqg->saved_workload_slice = 0; 856 cfqg->saved_workload_slice = 0;
857 blkiocg_update_blkio_group_dequeue_stats(&cfqg->blkg, 1);
855} 858}
856 859
857static inline unsigned int cfq_cfqq_slice_usage(struct cfq_queue *cfqq) 860static inline unsigned int cfq_cfqq_slice_usage(struct cfq_queue *cfqq)
@@ -878,7 +881,8 @@ static inline unsigned int cfq_cfqq_slice_usage(struct cfq_queue *cfqq)
878 slice_used = allocated_slice; 881 slice_used = allocated_slice;
879 } 882 }
880 883
881 cfq_log_cfqq(cfqq->cfqd, cfqq, "sl_used=%u", slice_used); 884 cfq_log_cfqq(cfqq->cfqd, cfqq, "sl_used=%u sect=%lu", slice_used,
885 cfqq->nr_sectors);
882 return slice_used; 886 return slice_used;
883} 887}
884 888
@@ -906,6 +910,8 @@ static void cfq_group_served(struct cfq_data *cfqd, struct cfq_group *cfqg,
906 910
907 cfq_log_cfqg(cfqd, cfqg, "served: vt=%llu min_vt=%llu", cfqg->vdisktime, 911 cfq_log_cfqg(cfqd, cfqg, "served: vt=%llu min_vt=%llu", cfqg->vdisktime,
908 st->min_vdisktime); 912 st->min_vdisktime);
913 blkiocg_update_blkio_group_stats(&cfqg->blkg, used_sl,
914 cfqq->nr_sectors);
909} 915}
910 916
911#ifdef CONFIG_CFQ_GROUP_IOSCHED 917#ifdef CONFIG_CFQ_GROUP_IOSCHED
@@ -924,6 +930,8 @@ cfq_find_alloc_cfqg(struct cfq_data *cfqd, struct cgroup *cgroup, int create)
924 void *key = cfqd; 930 void *key = cfqd;
925 int i, j; 931 int i, j;
926 struct cfq_rb_root *st; 932 struct cfq_rb_root *st;
933 struct backing_dev_info *bdi = &cfqd->queue->backing_dev_info;
934 unsigned int major, minor;
927 935
928 /* Do we need to take this reference */ 936 /* Do we need to take this reference */
929 if (!css_tryget(&blkcg->css)) 937 if (!css_tryget(&blkcg->css))
@@ -951,7 +959,9 @@ cfq_find_alloc_cfqg(struct cfq_data *cfqd, struct cgroup *cgroup, int create)
951 atomic_set(&cfqg->ref, 1); 959 atomic_set(&cfqg->ref, 1);
952 960
953 /* Add group onto cgroup list */ 961 /* Add group onto cgroup list */
954 blkiocg_add_blkio_group(blkcg, &cfqg->blkg, (void *)cfqd); 962 sscanf(dev_name(bdi->dev), "%u:%u", &major, &minor);
963 blkiocg_add_blkio_group(blkcg, &cfqg->blkg, (void *)cfqd,
964 MKDEV(major, minor));
955 965
956 /* Add group on cfqd list */ 966 /* Add group on cfqd list */
957 hlist_add_head(&cfqg->cfqd_node, &cfqd->cfqg_list); 967 hlist_add_head(&cfqg->cfqd_node, &cfqd->cfqg_list);
@@ -1478,6 +1488,7 @@ static void __cfq_set_active_queue(struct cfq_data *cfqd,
1478 cfqq->dispatch_start = jiffies; 1488 cfqq->dispatch_start = jiffies;
1479 cfqq->slice_end = 0; 1489 cfqq->slice_end = 0;
1480 cfqq->slice_dispatch = 0; 1490 cfqq->slice_dispatch = 0;
1491 cfqq->nr_sectors = 0;
1481 1492
1482 cfq_clear_cfqq_wait_request(cfqq); 1493 cfq_clear_cfqq_wait_request(cfqq);
1483 cfq_clear_cfqq_must_dispatch(cfqq); 1494 cfq_clear_cfqq_must_dispatch(cfqq);
@@ -1801,6 +1812,7 @@ static void cfq_dispatch_insert(struct request_queue *q, struct request *rq)
1801 1812
1802 if (cfq_cfqq_sync(cfqq)) 1813 if (cfq_cfqq_sync(cfqq))
1803 cfqd->sync_flight++; 1814 cfqd->sync_flight++;
1815 cfqq->nr_sectors += blk_rq_sectors(rq);
1804} 1816}
1805 1817
1806/* 1818/*
@@ -3513,7 +3525,8 @@ static void *cfq_init_queue(struct request_queue *q)
3513 * to make sure that cfq_put_cfqg() does not try to kfree root group 3525 * to make sure that cfq_put_cfqg() does not try to kfree root group
3514 */ 3526 */
3515 atomic_set(&cfqg->ref, 1); 3527 atomic_set(&cfqg->ref, 1);
3516 blkiocg_add_blkio_group(&blkio_root_cgroup, &cfqg->blkg, (void *)cfqd); 3528 blkiocg_add_blkio_group(&blkio_root_cgroup, &cfqg->blkg, (void *)cfqd,
3529 0);
3517#endif 3530#endif
3518 /* 3531 /*
3519 * Not strictly needed (since RB_ROOT just clears the node and we 3532 * Not strictly needed (since RB_ROOT just clears the node and we