aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-cgroup.h
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /block/blk-cgroup.h
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'block/blk-cgroup.h')
-rw-r--r--block/blk-cgroup.h138
1 files changed, 122 insertions, 16 deletions
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index 2b866ec1dcea..a71d2904ffb9 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -14,6 +14,15 @@
14 */ 14 */
15 15
16#include <linux/cgroup.h> 16#include <linux/cgroup.h>
17#include <linux/u64_stats_sync.h>
18
19enum blkio_policy_id {
20 BLKIO_POLICY_PROP = 0, /* Proportional Bandwidth division */
21 BLKIO_POLICY_THROTL, /* Throttling */
22};
23
24/* Max limits for throttle policy */
25#define THROTL_IOPS_MAX UINT_MAX
17 26
18#if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE) 27#if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE)
19 28
@@ -28,20 +37,15 @@ enum stat_type {
28 * request completion for IOs doen by this cgroup. This may not be 37 * request completion for IOs doen by this cgroup. This may not be
29 * accurate when NCQ is turned on. */ 38 * accurate when NCQ is turned on. */
30 BLKIO_STAT_SERVICE_TIME = 0, 39 BLKIO_STAT_SERVICE_TIME = 0,
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 */ 40 /* Total time spent waiting in scheduler queue in ns */
36 BLKIO_STAT_WAIT_TIME, 41 BLKIO_STAT_WAIT_TIME,
37 /* Number of IOs merged */
38 BLKIO_STAT_MERGED,
39 /* Number of IOs queued up */ 42 /* Number of IOs queued up */
40 BLKIO_STAT_QUEUED, 43 BLKIO_STAT_QUEUED,
41 /* All the single valued stats go below this */ 44 /* All the single valued stats go below this */
42 BLKIO_STAT_TIME, 45 BLKIO_STAT_TIME,
43 BLKIO_STAT_SECTORS,
44#ifdef CONFIG_DEBUG_BLK_CGROUP 46#ifdef CONFIG_DEBUG_BLK_CGROUP
47 /* Time not charged to this cgroup */
48 BLKIO_STAT_UNACCOUNTED_TIME,
45 BLKIO_STAT_AVG_QUEUE_SIZE, 49 BLKIO_STAT_AVG_QUEUE_SIZE,
46 BLKIO_STAT_IDLE_TIME, 50 BLKIO_STAT_IDLE_TIME,
47 BLKIO_STAT_EMPTY_TIME, 51 BLKIO_STAT_EMPTY_TIME,
@@ -50,6 +54,18 @@ enum stat_type {
50#endif 54#endif
51}; 55};
52 56
57/* Per cpu stats */
58enum stat_type_cpu {
59 BLKIO_STAT_CPU_SECTORS,
60 /* Total bytes transferred */
61 BLKIO_STAT_CPU_SERVICE_BYTES,
62 /* Total IOs serviced, post merge */
63 BLKIO_STAT_CPU_SERVICED,
64 /* Number of IOs merged */
65 BLKIO_STAT_CPU_MERGED,
66 BLKIO_STAT_CPU_NR
67};
68
53enum stat_sub_type { 69enum stat_sub_type {
54 BLKIO_STAT_READ = 0, 70 BLKIO_STAT_READ = 0,
55 BLKIO_STAT_WRITE, 71 BLKIO_STAT_WRITE,
@@ -65,6 +81,36 @@ enum blkg_state_flags {
65 BLKG_empty, 81 BLKG_empty,
66}; 82};
67 83
84/* cgroup files owned by proportional weight policy */
85enum blkcg_file_name_prop {
86 BLKIO_PROP_weight = 1,
87 BLKIO_PROP_weight_device,
88 BLKIO_PROP_io_service_bytes,
89 BLKIO_PROP_io_serviced,
90 BLKIO_PROP_time,
91 BLKIO_PROP_sectors,
92 BLKIO_PROP_unaccounted_time,
93 BLKIO_PROP_io_service_time,
94 BLKIO_PROP_io_wait_time,
95 BLKIO_PROP_io_merged,
96 BLKIO_PROP_io_queued,
97 BLKIO_PROP_avg_queue_size,
98 BLKIO_PROP_group_wait_time,
99 BLKIO_PROP_idle_time,
100 BLKIO_PROP_empty_time,
101 BLKIO_PROP_dequeue,
102};
103
104/* cgroup files owned by throttle policy */
105enum blkcg_file_name_throtl {
106 BLKIO_THROTL_read_bps_device,
107 BLKIO_THROTL_write_bps_device,
108 BLKIO_THROTL_read_iops_device,
109 BLKIO_THROTL_write_iops_device,
110 BLKIO_THROTL_io_service_bytes,
111 BLKIO_THROTL_io_serviced,
112};
113
68struct blkio_cgroup { 114struct blkio_cgroup {
69 struct cgroup_subsys_state css; 115 struct cgroup_subsys_state css;
70 unsigned int weight; 116 unsigned int weight;
@@ -76,9 +122,11 @@ struct blkio_cgroup {
76struct blkio_group_stats { 122struct blkio_group_stats {
77 /* total disk time and nr sectors dispatched by this group */ 123 /* total disk time and nr sectors dispatched by this group */
78 uint64_t time; 124 uint64_t time;
79 uint64_t sectors;
80 uint64_t stat_arr[BLKIO_STAT_QUEUED + 1][BLKIO_STAT_TOTAL]; 125 uint64_t stat_arr[BLKIO_STAT_QUEUED + 1][BLKIO_STAT_TOTAL];
81#ifdef CONFIG_DEBUG_BLK_CGROUP 126#ifdef CONFIG_DEBUG_BLK_CGROUP
127 /* Time not charged to this cgroup */
128 uint64_t unaccounted_time;
129
82 /* Sum of number of IOs queued across all samples */ 130 /* Sum of number of IOs queued across all samples */
83 uint64_t avg_queue_size_sum; 131 uint64_t avg_queue_size_sum;
84 /* Count of samples taken for average */ 132 /* Count of samples taken for average */
@@ -103,6 +151,13 @@ struct blkio_group_stats {
103#endif 151#endif
104}; 152};
105 153
154/* Per cpu blkio group stats */
155struct blkio_group_stats_cpu {
156 uint64_t sectors;
157 uint64_t stat_arr_cpu[BLKIO_STAT_CPU_NR][BLKIO_STAT_TOTAL];
158 struct u64_stats_sync syncp;
159};
160
106struct blkio_group { 161struct blkio_group {
107 /* An rcu protected unique identifier for the group */ 162 /* An rcu protected unique identifier for the group */
108 void *key; 163 void *key;
@@ -112,33 +167,73 @@ struct blkio_group {
112 char path[128]; 167 char path[128];
113 /* The device MKDEV(major, minor), this group has been created for */ 168 /* The device MKDEV(major, minor), this group has been created for */
114 dev_t dev; 169 dev_t dev;
170 /* policy which owns this blk group */
171 enum blkio_policy_id plid;
115 172
116 /* Need to serialize the stats in the case of reset/update */ 173 /* Need to serialize the stats in the case of reset/update */
117 spinlock_t stats_lock; 174 spinlock_t stats_lock;
118 struct blkio_group_stats stats; 175 struct blkio_group_stats stats;
176 /* Per cpu stats pointer */
177 struct blkio_group_stats_cpu __percpu *stats_cpu;
119}; 178};
120 179
121struct blkio_policy_node { 180struct blkio_policy_node {
122 struct list_head node; 181 struct list_head node;
123 dev_t dev; 182 dev_t dev;
124 unsigned int weight; 183 /* This node belongs to max bw policy or porportional weight policy */
184 enum blkio_policy_id plid;
185 /* cgroup file to which this rule belongs to */
186 int fileid;
187
188 union {
189 unsigned int weight;
190 /*
191 * Rate read/write in terms of byptes per second
192 * Whether this rate represents read or write is determined
193 * by file type "fileid".
194 */
195 u64 bps;
196 unsigned int iops;
197 } val;
125}; 198};
126 199
127extern unsigned int blkcg_get_weight(struct blkio_cgroup *blkcg, 200extern unsigned int blkcg_get_weight(struct blkio_cgroup *blkcg,
128 dev_t dev); 201 dev_t dev);
202extern uint64_t blkcg_get_read_bps(struct blkio_cgroup *blkcg,
203 dev_t dev);
204extern uint64_t blkcg_get_write_bps(struct blkio_cgroup *blkcg,
205 dev_t dev);
206extern unsigned int blkcg_get_read_iops(struct blkio_cgroup *blkcg,
207 dev_t dev);
208extern unsigned int blkcg_get_write_iops(struct blkio_cgroup *blkcg,
209 dev_t dev);
129 210
130typedef void (blkio_unlink_group_fn) (void *key, struct blkio_group *blkg); 211typedef void (blkio_unlink_group_fn) (void *key, struct blkio_group *blkg);
131typedef void (blkio_update_group_weight_fn) (struct blkio_group *blkg, 212
132 unsigned int weight); 213typedef void (blkio_update_group_weight_fn) (void *key,
214 struct blkio_group *blkg, unsigned int weight);
215typedef void (blkio_update_group_read_bps_fn) (void * key,
216 struct blkio_group *blkg, u64 read_bps);
217typedef void (blkio_update_group_write_bps_fn) (void *key,
218 struct blkio_group *blkg, u64 write_bps);
219typedef void (blkio_update_group_read_iops_fn) (void *key,
220 struct blkio_group *blkg, unsigned int read_iops);
221typedef void (blkio_update_group_write_iops_fn) (void *key,
222 struct blkio_group *blkg, unsigned int write_iops);
133 223
134struct blkio_policy_ops { 224struct blkio_policy_ops {
135 blkio_unlink_group_fn *blkio_unlink_group_fn; 225 blkio_unlink_group_fn *blkio_unlink_group_fn;
136 blkio_update_group_weight_fn *blkio_update_group_weight_fn; 226 blkio_update_group_weight_fn *blkio_update_group_weight_fn;
227 blkio_update_group_read_bps_fn *blkio_update_group_read_bps_fn;
228 blkio_update_group_write_bps_fn *blkio_update_group_write_bps_fn;
229 blkio_update_group_read_iops_fn *blkio_update_group_read_iops_fn;
230 blkio_update_group_write_iops_fn *blkio_update_group_write_iops_fn;
137}; 231};
138 232
139struct blkio_policy_type { 233struct blkio_policy_type {
140 struct list_head list; 234 struct list_head list;
141 struct blkio_policy_ops ops; 235 struct blkio_policy_ops ops;
236 enum blkio_policy_id plid;
142}; 237};
143 238
144/* Blkio controller policy registration */ 239/* Blkio controller policy registration */
@@ -165,7 +260,7 @@ static inline char *blkg_path(struct blkio_group *blkg) { return NULL; }
165 260
166#endif 261#endif
167 262
168#define BLKIO_WEIGHT_MIN 100 263#define BLKIO_WEIGHT_MIN 10
169#define BLKIO_WEIGHT_MAX 1000 264#define BLKIO_WEIGHT_MAX 1000
170#define BLKIO_WEIGHT_DEFAULT 500 265#define BLKIO_WEIGHT_DEFAULT 500
171 266
@@ -211,13 +306,17 @@ static inline void blkiocg_set_start_empty_time(struct blkio_group *blkg) {}
211#if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE) 306#if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE)
212extern struct blkio_cgroup blkio_root_cgroup; 307extern struct blkio_cgroup blkio_root_cgroup;
213extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup); 308extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup);
309extern struct blkio_cgroup *task_blkio_cgroup(struct task_struct *tsk);
214extern void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, 310extern void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg,
215 struct blkio_group *blkg, void *key, dev_t dev); 311 struct blkio_group *blkg, void *key, dev_t dev,
312 enum blkio_policy_id plid);
313extern int blkio_alloc_blkg_stats(struct blkio_group *blkg);
216extern int blkiocg_del_blkio_group(struct blkio_group *blkg); 314extern int blkiocg_del_blkio_group(struct blkio_group *blkg);
217extern struct blkio_group *blkiocg_lookup_group(struct blkio_cgroup *blkcg, 315extern struct blkio_group *blkiocg_lookup_group(struct blkio_cgroup *blkcg,
218 void *key); 316 void *key);
219void blkiocg_update_timeslice_used(struct blkio_group *blkg, 317void blkiocg_update_timeslice_used(struct blkio_group *blkg,
220 unsigned long time); 318 unsigned long time,
319 unsigned long unaccounted_time);
221void blkiocg_update_dispatch_stats(struct blkio_group *blkg, uint64_t bytes, 320void blkiocg_update_dispatch_stats(struct blkio_group *blkg, uint64_t bytes,
222 bool direction, bool sync); 321 bool direction, bool sync);
223void blkiocg_update_completion_stats(struct blkio_group *blkg, 322void blkiocg_update_completion_stats(struct blkio_group *blkg,
@@ -232,9 +331,14 @@ void blkiocg_update_io_remove_stats(struct blkio_group *blkg,
232struct cgroup; 331struct cgroup;
233static inline struct blkio_cgroup * 332static inline struct blkio_cgroup *
234cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; } 333cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; }
334static inline struct blkio_cgroup *
335task_blkio_cgroup(struct task_struct *tsk) { return NULL; }
235 336
236static inline void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, 337static inline void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg,
237 struct blkio_group *blkg, void *key, dev_t dev) {} 338 struct blkio_group *blkg, void *key, dev_t dev,
339 enum blkio_policy_id plid) {}
340
341static inline int blkio_alloc_blkg_stats(struct blkio_group *blkg) { return 0; }
238 342
239static inline int 343static inline int
240blkiocg_del_blkio_group(struct blkio_group *blkg) { return 0; } 344blkiocg_del_blkio_group(struct blkio_group *blkg) { return 0; }
@@ -242,7 +346,9 @@ blkiocg_del_blkio_group(struct blkio_group *blkg) { return 0; }
242static inline struct blkio_group * 346static inline struct blkio_group *
243blkiocg_lookup_group(struct blkio_cgroup *blkcg, void *key) { return NULL; } 347blkiocg_lookup_group(struct blkio_cgroup *blkcg, void *key) { return NULL; }
244static inline void blkiocg_update_timeslice_used(struct blkio_group *blkg, 348static inline void blkiocg_update_timeslice_used(struct blkio_group *blkg,
245 unsigned long time) {} 349 unsigned long time,
350 unsigned long unaccounted_time)
351{}
246static inline void blkiocg_update_dispatch_stats(struct blkio_group *blkg, 352static inline void blkiocg_update_dispatch_stats(struct blkio_group *blkg,
247 uint64_t bytes, bool direction, bool sync) {} 353 uint64_t bytes, bool direction, bool sync) {}
248static inline void blkiocg_update_completion_stats(struct blkio_group *blkg, 354static inline void blkiocg_update_completion_stats(struct blkio_group *blkg,