blob: 9df5ab04b6d6ba13d273f641d68f99bc1ed48392 [file] [log] [blame]
Vivek Goyal31e4c282009-12-03 12:59:42 -05001#ifndef _BLK_CGROUP_H
2#define _BLK_CGROUP_H
3/*
4 * Common Block IO controller cgroup interface
5 *
6 * Based on ideas and code from CFQ, CFS and BFQ:
7 * Copyright (C) 2003 Jens Axboe <axboe@kernel.dk>
8 *
9 * Copyright (C) 2008 Fabio Checconi <fabio@gandalf.sssup.it>
10 * Paolo Valente <paolo.valente@unimore.it>
11 *
12 * Copyright (C) 2009 Vivek Goyal <vgoyal@redhat.com>
13 * Nauman Rafique <nauman@google.com>
14 */
15
16#include <linux/cgroup.h>
Vivek Goyal575969a2011-05-19 15:38:29 -040017#include <linux/u64_stats_sync.h>
Vivek Goyal31e4c282009-12-03 12:59:42 -050018
Vivek Goyal062a6442010-09-15 17:06:33 -040019enum blkio_policy_id {
20 BLKIO_POLICY_PROP = 0, /* Proportional Bandwidth division */
Vivek Goyal4c9eefa2010-09-15 17:06:34 -040021 BLKIO_POLICY_THROTL, /* Throttling */
Tejun Heo035d10b2012-03-05 13:15:04 -080022
23 BLKIO_NR_POLICIES,
Vivek Goyal062a6442010-09-15 17:06:33 -040024};
25
Vivek Goyal9355aed2010-10-01 21:16:41 +020026/* Max limits for throttle policy */
27#define THROTL_IOPS_MAX UINT_MAX
28
Tejun Heo32e380a2012-03-05 13:14:54 -080029#ifdef CONFIG_BLK_CGROUP
Jens Axboe2f5ea472009-12-03 21:06:43 +010030
Divyesh Shah84c124d2010-04-09 08:31:19 +020031enum stat_type {
Tejun Heo5fe224d2012-03-08 10:53:57 -080032 /* Number of IOs merged */
33 BLKIO_STAT_MERGED,
Divyesh Shah84c124d2010-04-09 08:31:19 +020034 /* Total time spent (in ns) between request dispatch to the driver and
35 * request completion for IOs doen by this cgroup. This may not be
36 * accurate when NCQ is turned on. */
Tejun Heo5fe224d2012-03-08 10:53:57 -080037 BLKIO_STAT_SERVICE_TIME,
Divyesh Shah84c124d2010-04-09 08:31:19 +020038 /* Total time spent waiting in scheduler queue in ns */
39 BLKIO_STAT_WAIT_TIME,
Divyesh Shahcdc11842010-04-08 21:15:10 -070040 /* Number of IOs queued up */
41 BLKIO_STAT_QUEUED,
Tejun Heoc4c76a02012-03-08 10:53:59 -080042
Divyesh Shah84c124d2010-04-09 08:31:19 +020043 /* All the single valued stats go below this */
44 BLKIO_STAT_TIME,
Vivek Goyala23e6862011-05-19 15:38:20 -040045#ifdef CONFIG_DEBUG_BLK_CGROUP
Justin TerAvest167400d2011-03-12 16:54:00 +010046 /* Time not charged to this cgroup */
47 BLKIO_STAT_UNACCOUNTED_TIME,
Divyesh Shahcdc11842010-04-08 21:15:10 -070048 BLKIO_STAT_AVG_QUEUE_SIZE,
Divyesh Shah812df482010-04-08 21:15:35 -070049 BLKIO_STAT_IDLE_TIME,
50 BLKIO_STAT_EMPTY_TIME,
51 BLKIO_STAT_GROUP_WAIT_TIME,
Divyesh Shah84c124d2010-04-09 08:31:19 +020052 BLKIO_STAT_DEQUEUE
53#endif
54};
55
Tejun Heoc4c76a02012-03-08 10:53:59 -080056/* Types lower than this live in stat_arr and have subtypes */
57#define BLKIO_STAT_ARR_NR (BLKIO_STAT_QUEUED + 1)
58
Vivek Goyal5624a4e2011-05-19 15:38:28 -040059/* Per cpu stats */
60enum stat_type_cpu {
61 BLKIO_STAT_CPU_SECTORS,
62 /* Total bytes transferred */
63 BLKIO_STAT_CPU_SERVICE_BYTES,
64 /* Total IOs serviced, post merge */
65 BLKIO_STAT_CPU_SERVICED,
66 BLKIO_STAT_CPU_NR
67};
68
Divyesh Shah84c124d2010-04-09 08:31:19 +020069enum stat_sub_type {
70 BLKIO_STAT_READ = 0,
71 BLKIO_STAT_WRITE,
72 BLKIO_STAT_SYNC,
73 BLKIO_STAT_ASYNC,
74 BLKIO_STAT_TOTAL
Divyesh Shah303a3ac2010-04-01 15:01:24 -070075};
76
Divyesh Shah812df482010-04-08 21:15:35 -070077/* blkg state flags */
78enum blkg_state_flags {
79 BLKG_waiting = 0,
80 BLKG_idling,
81 BLKG_empty,
82};
83
Vivek Goyal062a6442010-09-15 17:06:33 -040084/* 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,
Justin TerAvest167400d2011-03-12 16:54:00 +010092 BLKIO_PROP_unaccounted_time,
Vivek Goyal062a6442010-09-15 17:06:33 -040093 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
Vivek Goyal4c9eefa2010-09-15 17:06:34 -0400104/* cgroup files owned by throttle policy */
105enum blkcg_file_name_throtl {
106 BLKIO_THROTL_read_bps_device,
107 BLKIO_THROTL_write_bps_device,
Vivek Goyal7702e8f2010-09-15 17:06:36 -0400108 BLKIO_THROTL_read_iops_device,
109 BLKIO_THROTL_write_iops_device,
Vivek Goyal4c9eefa2010-09-15 17:06:34 -0400110 BLKIO_THROTL_io_service_bytes,
111 BLKIO_THROTL_io_serviced,
112};
113
Vivek Goyal31e4c282009-12-03 12:59:42 -0500114struct blkio_cgroup {
115 struct cgroup_subsys_state css;
116 unsigned int weight;
117 spinlock_t lock;
118 struct hlist_head blkg_list;
119};
120
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700121struct blkio_group_stats {
Tejun Heoedf1b872012-03-08 10:54:00 -0800122 struct u64_stats_sync syncp;
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700123 /* total disk time and nr sectors dispatched by this group */
124 uint64_t time;
Tejun Heoc4c76a02012-03-08 10:53:59 -0800125 uint64_t stat_arr[BLKIO_STAT_ARR_NR][BLKIO_STAT_TOTAL];
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700126#ifdef CONFIG_DEBUG_BLK_CGROUP
Vivek Goyala23e6862011-05-19 15:38:20 -0400127 /* Time not charged to this cgroup */
128 uint64_t unaccounted_time;
129
Divyesh Shahcdc11842010-04-08 21:15:10 -0700130 /* Sum of number of IOs queued across all samples */
131 uint64_t avg_queue_size_sum;
132 /* Count of samples taken for average */
133 uint64_t avg_queue_size_samples;
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700134 /* How many times this group has been removed from service tree */
135 unsigned long dequeue;
Divyesh Shah812df482010-04-08 21:15:35 -0700136
137 /* Total time spent waiting for it to be assigned a timeslice. */
138 uint64_t group_wait_time;
Divyesh Shah812df482010-04-08 21:15:35 -0700139
140 /* Time spent idling for this blkio_group */
141 uint64_t idle_time;
Divyesh Shah812df482010-04-08 21:15:35 -0700142 /*
143 * Total time when we have requests queued and do not contain the
144 * current active queue.
145 */
146 uint64_t empty_time;
Tejun Heo997a0262012-03-08 10:53:58 -0800147
148 /* fields after this shouldn't be cleared on stat reset */
149 uint64_t start_group_wait_time;
150 uint64_t start_idle_time;
Divyesh Shah812df482010-04-08 21:15:35 -0700151 uint64_t start_empty_time;
152 uint16_t flags;
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700153#endif
154};
155
Tejun Heo997a0262012-03-08 10:53:58 -0800156#ifdef CONFIG_DEBUG_BLK_CGROUP
157#define BLKG_STATS_DEBUG_CLEAR_START \
158 offsetof(struct blkio_group_stats, unaccounted_time)
159#define BLKG_STATS_DEBUG_CLEAR_SIZE \
160 (offsetof(struct blkio_group_stats, start_group_wait_time) - \
161 BLKG_STATS_DEBUG_CLEAR_START)
162#endif
163
Vivek Goyal5624a4e2011-05-19 15:38:28 -0400164/* Per cpu blkio group stats */
165struct blkio_group_stats_cpu {
166 uint64_t sectors;
167 uint64_t stat_arr_cpu[BLKIO_STAT_CPU_NR][BLKIO_STAT_TOTAL];
Vivek Goyal575969a2011-05-19 15:38:29 -0400168 struct u64_stats_sync syncp;
Vivek Goyal5624a4e2011-05-19 15:38:28 -0400169};
170
Tejun Heoe56da7e2012-03-05 13:15:07 -0800171struct blkio_group_conf {
172 unsigned int weight;
173 unsigned int iops[2];
174 u64 bps[2];
175};
176
Tejun Heo03814112012-03-05 13:15:14 -0800177/* per-blkg per-policy data */
178struct blkg_policy_data {
179 /* the blkg this per-policy data belongs to */
180 struct blkio_group *blkg;
181
Tejun Heo549d3aa2012-03-05 13:15:16 -0800182 /* Configuration */
183 struct blkio_group_conf conf;
184
185 struct blkio_group_stats stats;
186 /* Per cpu stats pointer */
187 struct blkio_group_stats_cpu __percpu *stats_cpu;
188
Tejun Heo03814112012-03-05 13:15:14 -0800189 /* pol->pdata_size bytes of private data used by policy impl */
190 char pdata[] __aligned(__alignof__(unsigned long long));
191};
192
Vivek Goyal31e4c282009-12-03 12:59:42 -0500193struct blkio_group {
Tejun Heoc875f4d2012-03-05 13:15:22 -0800194 /* Pointer to the associated request_queue */
195 struct request_queue *q;
Tejun Heoe8989fa2012-03-05 13:15:20 -0800196 struct list_head q_node;
Vivek Goyal31e4c282009-12-03 12:59:42 -0500197 struct hlist_node blkcg_node;
Tejun Heo7ee9c562012-03-05 13:15:11 -0800198 struct blkio_cgroup *blkcg;
Vivek Goyal2868ef72009-12-03 12:59:48 -0500199 /* Store cgroup path */
200 char path[128];
Tejun Heo1adaf3d2012-03-05 13:15:15 -0800201 /* reference count */
202 int refcnt;
Vivek Goyal22084192009-12-03 12:59:49 -0500203
Tejun Heo549d3aa2012-03-05 13:15:16 -0800204 struct blkg_policy_data *pd[BLKIO_NR_POLICIES];
Tejun Heo1adaf3d2012-03-05 13:15:15 -0800205
Vivek Goyal1cd9e032012-03-08 10:53:56 -0800206 /* List of blkg waiting for per cpu stats memory to be allocated */
207 struct list_head alloc_node;
Tejun Heo1adaf3d2012-03-05 13:15:15 -0800208 struct rcu_head rcu_head;
Vivek Goyal31e4c282009-12-03 12:59:42 -0500209};
210
Tejun Heo03814112012-03-05 13:15:14 -0800211typedef void (blkio_init_group_fn)(struct blkio_group *blkg);
Tejun Heoca32aef2012-03-05 13:15:03 -0800212typedef void (blkio_update_group_weight_fn)(struct request_queue *q,
Vivek Goyalfe071432010-10-01 14:49:49 +0200213 struct blkio_group *blkg, unsigned int weight);
Tejun Heoca32aef2012-03-05 13:15:03 -0800214typedef void (blkio_update_group_read_bps_fn)(struct request_queue *q,
Vivek Goyalfe071432010-10-01 14:49:49 +0200215 struct blkio_group *blkg, u64 read_bps);
Tejun Heoca32aef2012-03-05 13:15:03 -0800216typedef void (blkio_update_group_write_bps_fn)(struct request_queue *q,
Vivek Goyalfe071432010-10-01 14:49:49 +0200217 struct blkio_group *blkg, u64 write_bps);
Tejun Heoca32aef2012-03-05 13:15:03 -0800218typedef void (blkio_update_group_read_iops_fn)(struct request_queue *q,
Vivek Goyalfe071432010-10-01 14:49:49 +0200219 struct blkio_group *blkg, unsigned int read_iops);
Tejun Heoca32aef2012-03-05 13:15:03 -0800220typedef void (blkio_update_group_write_iops_fn)(struct request_queue *q,
Vivek Goyalfe071432010-10-01 14:49:49 +0200221 struct blkio_group *blkg, unsigned int write_iops);
Vivek Goyal3e252062009-12-04 10:36:42 -0500222
223struct blkio_policy_ops {
Tejun Heo03814112012-03-05 13:15:14 -0800224 blkio_init_group_fn *blkio_init_group_fn;
Vivek Goyal3e252062009-12-04 10:36:42 -0500225 blkio_update_group_weight_fn *blkio_update_group_weight_fn;
Vivek Goyal4c9eefa2010-09-15 17:06:34 -0400226 blkio_update_group_read_bps_fn *blkio_update_group_read_bps_fn;
227 blkio_update_group_write_bps_fn *blkio_update_group_write_bps_fn;
Vivek Goyal7702e8f2010-09-15 17:06:36 -0400228 blkio_update_group_read_iops_fn *blkio_update_group_read_iops_fn;
229 blkio_update_group_write_iops_fn *blkio_update_group_write_iops_fn;
Vivek Goyal3e252062009-12-04 10:36:42 -0500230};
231
232struct blkio_policy_type {
233 struct list_head list;
234 struct blkio_policy_ops ops;
Vivek Goyal062a6442010-09-15 17:06:33 -0400235 enum blkio_policy_id plid;
Tejun Heo03814112012-03-05 13:15:14 -0800236 size_t pdata_size; /* policy specific private data size */
Vivek Goyal3e252062009-12-04 10:36:42 -0500237};
238
Tejun Heo5efd6112012-03-05 13:15:12 -0800239extern int blkcg_init_queue(struct request_queue *q);
240extern void blkcg_drain_queue(struct request_queue *q);
241extern void blkcg_exit_queue(struct request_queue *q);
242
Vivek Goyal3e252062009-12-04 10:36:42 -0500243/* Blkio controller policy registration */
244extern void blkio_policy_register(struct blkio_policy_type *);
245extern void blkio_policy_unregister(struct blkio_policy_type *);
Tejun Heoe8989fa2012-03-05 13:15:20 -0800246extern void blkg_destroy_all(struct request_queue *q, bool destroy_root);
247extern void update_root_blkg_pd(struct request_queue *q,
248 enum blkio_policy_id plid);
Vivek Goyal3e252062009-12-04 10:36:42 -0500249
Tejun Heo03814112012-03-05 13:15:14 -0800250/**
251 * blkg_to_pdata - get policy private data
252 * @blkg: blkg of interest
253 * @pol: policy of interest
254 *
255 * Return pointer to private data associated with the @blkg-@pol pair.
256 */
257static inline void *blkg_to_pdata(struct blkio_group *blkg,
258 struct blkio_policy_type *pol)
259{
Tejun Heo549d3aa2012-03-05 13:15:16 -0800260 return blkg ? blkg->pd[pol->plid]->pdata : NULL;
Tejun Heo03814112012-03-05 13:15:14 -0800261}
262
263/**
264 * pdata_to_blkg - get blkg associated with policy private data
265 * @pdata: policy private data of interest
266 * @pol: policy @pdata is for
267 *
268 * @pdata is policy private data for @pol. Determine the blkg it's
269 * associated with.
270 */
271static inline struct blkio_group *pdata_to_blkg(void *pdata,
272 struct blkio_policy_type *pol)
273{
274 if (pdata) {
275 struct blkg_policy_data *pd =
276 container_of(pdata, struct blkg_policy_data, pdata);
277 return pd->blkg;
278 }
279 return NULL;
280}
281
Vivek Goyalafc24d42010-04-26 19:27:56 +0200282static inline char *blkg_path(struct blkio_group *blkg)
283{
284 return blkg->path;
285}
286
Tejun Heo1adaf3d2012-03-05 13:15:15 -0800287/**
288 * blkg_get - get a blkg reference
289 * @blkg: blkg to get
290 *
291 * The caller should be holding queue_lock and an existing reference.
292 */
293static inline void blkg_get(struct blkio_group *blkg)
294{
295 lockdep_assert_held(blkg->q->queue_lock);
296 WARN_ON_ONCE(!blkg->refcnt);
297 blkg->refcnt++;
298}
299
300void __blkg_release(struct blkio_group *blkg);
301
302/**
303 * blkg_put - put a blkg reference
304 * @blkg: blkg to put
305 *
306 * The caller should be holding queue_lock.
307 */
308static inline void blkg_put(struct blkio_group *blkg)
309{
310 lockdep_assert_held(blkg->q->queue_lock);
311 WARN_ON_ONCE(blkg->refcnt <= 0);
312 if (!--blkg->refcnt)
313 __blkg_release(blkg);
314}
315
Jens Axboe2f5ea472009-12-03 21:06:43 +0100316#else
317
318struct blkio_group {
319};
320
Vivek Goyal3e252062009-12-04 10:36:42 -0500321struct blkio_policy_type {
322};
323
Tejun Heo5efd6112012-03-05 13:15:12 -0800324static inline int blkcg_init_queue(struct request_queue *q) { return 0; }
325static inline void blkcg_drain_queue(struct request_queue *q) { }
326static inline void blkcg_exit_queue(struct request_queue *q) { }
Vivek Goyal3e252062009-12-04 10:36:42 -0500327static inline void blkio_policy_register(struct blkio_policy_type *blkiop) { }
328static inline void blkio_policy_unregister(struct blkio_policy_type *blkiop) { }
Tejun Heo03aa2642012-03-05 13:15:19 -0800329static inline void blkg_destroy_all(struct request_queue *q,
Tejun Heo03aa2642012-03-05 13:15:19 -0800330 bool destory_root) { }
Tejun Heoe8989fa2012-03-05 13:15:20 -0800331static inline void update_root_blkg_pd(struct request_queue *q,
332 enum blkio_policy_id plid) { }
Vivek Goyal3e252062009-12-04 10:36:42 -0500333
Tejun Heo03814112012-03-05 13:15:14 -0800334static inline void *blkg_to_pdata(struct blkio_group *blkg,
335 struct blkio_policy_type *pol) { return NULL; }
336static inline struct blkio_group *pdata_to_blkg(void *pdata,
337 struct blkio_policy_type *pol) { return NULL; }
Vivek Goyalafc24d42010-04-26 19:27:56 +0200338static inline char *blkg_path(struct blkio_group *blkg) { return NULL; }
Tejun Heo1adaf3d2012-03-05 13:15:15 -0800339static inline void blkg_get(struct blkio_group *blkg) { }
340static inline void blkg_put(struct blkio_group *blkg) { }
Vivek Goyalafc24d42010-04-26 19:27:56 +0200341
Jens Axboe2f5ea472009-12-03 21:06:43 +0100342#endif
343
Justin TerAvestdf457f82011-03-08 19:45:00 +0100344#define BLKIO_WEIGHT_MIN 10
Vivek Goyal31e4c282009-12-03 12:59:42 -0500345#define BLKIO_WEIGHT_MAX 1000
346#define BLKIO_WEIGHT_DEFAULT 500
347
Vivek Goyal2868ef72009-12-03 12:59:48 -0500348#ifdef CONFIG_DEBUG_BLK_CGROUP
Tejun Heoc1768262012-03-05 13:15:17 -0800349void blkiocg_update_avg_queue_size_stats(struct blkio_group *blkg,
350 struct blkio_policy_type *pol);
Divyesh Shah91952912010-04-01 15:01:41 -0700351void blkiocg_update_dequeue_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800352 struct blkio_policy_type *pol,
353 unsigned long dequeue);
354void blkiocg_update_set_idle_time_stats(struct blkio_group *blkg,
355 struct blkio_policy_type *pol);
356void blkiocg_update_idle_time_stats(struct blkio_group *blkg,
357 struct blkio_policy_type *pol);
358void blkiocg_set_start_empty_time(struct blkio_group *blkg,
359 struct blkio_policy_type *pol);
Divyesh Shah812df482010-04-08 21:15:35 -0700360
361#define BLKG_FLAG_FNS(name) \
362static inline void blkio_mark_blkg_##name( \
363 struct blkio_group_stats *stats) \
364{ \
365 stats->flags |= (1 << BLKG_##name); \
366} \
367static inline void blkio_clear_blkg_##name( \
368 struct blkio_group_stats *stats) \
369{ \
370 stats->flags &= ~(1 << BLKG_##name); \
371} \
372static inline int blkio_blkg_##name(struct blkio_group_stats *stats) \
373{ \
374 return (stats->flags & (1 << BLKG_##name)) != 0; \
375} \
376
377BLKG_FLAG_FNS(waiting)
378BLKG_FLAG_FNS(idling)
379BLKG_FLAG_FNS(empty)
380#undef BLKG_FLAG_FNS
Vivek Goyal2868ef72009-12-03 12:59:48 -0500381#else
Tejun Heoc1768262012-03-05 13:15:17 -0800382static inline void blkiocg_update_avg_queue_size_stats(struct blkio_group *blkg,
383 struct blkio_policy_type *pol) { }
Divyesh Shah91952912010-04-01 15:01:41 -0700384static inline void blkiocg_update_dequeue_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800385 struct blkio_policy_type *pol, unsigned long dequeue) { }
386static inline void blkiocg_update_set_idle_time_stats(struct blkio_group *blkg,
387 struct blkio_policy_type *pol) { }
388static inline void blkiocg_update_idle_time_stats(struct blkio_group *blkg,
389 struct blkio_policy_type *pol) { }
390static inline void blkiocg_set_start_empty_time(struct blkio_group *blkg,
391 struct blkio_policy_type *pol) { }
Vivek Goyal2868ef72009-12-03 12:59:48 -0500392#endif
393
Tejun Heo32e380a2012-03-05 13:14:54 -0800394#ifdef CONFIG_BLK_CGROUP
Vivek Goyal31e4c282009-12-03 12:59:42 -0500395extern struct blkio_cgroup blkio_root_cgroup;
396extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup);
Tejun Heo4f85cb92012-03-05 13:15:28 -0800397extern struct blkio_cgroup *bio_blkio_cgroup(struct bio *bio);
Tejun Heocd1604f2012-03-05 13:15:06 -0800398extern struct blkio_group *blkg_lookup(struct blkio_cgroup *blkcg,
Tejun Heoe8989fa2012-03-05 13:15:20 -0800399 struct request_queue *q);
Tejun Heocd1604f2012-03-05 13:15:06 -0800400struct blkio_group *blkg_lookup_create(struct blkio_cgroup *blkcg,
401 struct request_queue *q,
402 enum blkio_policy_id plid,
403 bool for_root);
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700404void blkiocg_update_timeslice_used(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800405 struct blkio_policy_type *pol,
406 unsigned long time,
407 unsigned long unaccounted_time);
408void blkiocg_update_dispatch_stats(struct blkio_group *blkg,
409 struct blkio_policy_type *pol,
410 uint64_t bytes, bool direction, bool sync);
Divyesh Shah84c124d2010-04-09 08:31:19 +0200411void blkiocg_update_completion_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800412 struct blkio_policy_type *pol,
413 uint64_t start_time,
414 uint64_t io_start_time, bool direction,
415 bool sync);
416void blkiocg_update_io_merged_stats(struct blkio_group *blkg,
417 struct blkio_policy_type *pol,
418 bool direction, bool sync);
Divyesh Shaha11cdaa2010-04-13 19:59:17 +0200419void blkiocg_update_io_add_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800420 struct blkio_policy_type *pol,
421 struct blkio_group *curr_blkg, bool direction,
422 bool sync);
Divyesh Shaha11cdaa2010-04-13 19:59:17 +0200423void blkiocg_update_io_remove_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800424 struct blkio_policy_type *pol,
425 bool direction, bool sync);
Vivek Goyal31e4c282009-12-03 12:59:42 -0500426#else
Jens Axboe2f5ea472009-12-03 21:06:43 +0100427struct cgroup;
Vivek Goyal31e4c282009-12-03 12:59:42 -0500428static inline struct blkio_cgroup *
429cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; }
Vivek Goyal70087dc2011-05-16 15:24:08 +0200430static inline struct blkio_cgroup *
Tejun Heo4f85cb92012-03-05 13:15:28 -0800431bio_blkio_cgroup(struct bio *bio) { return NULL; }
Vivek Goyal31e4c282009-12-03 12:59:42 -0500432
Tejun Heocd1604f2012-03-05 13:15:06 -0800433static inline struct blkio_group *blkg_lookup(struct blkio_cgroup *blkcg,
434 void *key) { return NULL; }
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700435static inline void blkiocg_update_timeslice_used(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800436 struct blkio_policy_type *pol, unsigned long time,
437 unsigned long unaccounted_time) { }
Divyesh Shah84c124d2010-04-09 08:31:19 +0200438static inline void blkiocg_update_dispatch_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800439 struct blkio_policy_type *pol, uint64_t bytes,
440 bool direction, bool sync) { }
Divyesh Shah84c124d2010-04-09 08:31:19 +0200441static inline void blkiocg_update_completion_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800442 struct blkio_policy_type *pol, uint64_t start_time,
443 uint64_t io_start_time, bool direction, bool sync) { }
Divyesh Shah812d4022010-04-08 21:14:23 -0700444static inline void blkiocg_update_io_merged_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800445 struct blkio_policy_type *pol, bool direction,
446 bool sync) { }
Divyesh Shaha11cdaa2010-04-13 19:59:17 +0200447static inline void blkiocg_update_io_add_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800448 struct blkio_policy_type *pol,
449 struct blkio_group *curr_blkg, bool direction,
450 bool sync) { }
Divyesh Shaha11cdaa2010-04-13 19:59:17 +0200451static inline void blkiocg_update_io_remove_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800452 struct blkio_policy_type *pol, bool direction,
453 bool sync) { }
Vivek Goyal31e4c282009-12-03 12:59:42 -0500454#endif
455#endif /* _BLK_CGROUP_H */