blob: 1fa3c5e8d87f4fa43d708fd534c4332237cd3d7b [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,
Divyesh Shah84c124d2010-04-09 08:31:19 +020042 /* All the single valued stats go below this */
43 BLKIO_STAT_TIME,
Vivek Goyala23e6862011-05-19 15:38:20 -040044#ifdef CONFIG_DEBUG_BLK_CGROUP
Justin TerAvest167400d2011-03-12 16:54:00 +010045 /* Time not charged to this cgroup */
46 BLKIO_STAT_UNACCOUNTED_TIME,
Divyesh Shahcdc11842010-04-08 21:15:10 -070047 BLKIO_STAT_AVG_QUEUE_SIZE,
Divyesh Shah812df482010-04-08 21:15:35 -070048 BLKIO_STAT_IDLE_TIME,
49 BLKIO_STAT_EMPTY_TIME,
50 BLKIO_STAT_GROUP_WAIT_TIME,
Divyesh Shah84c124d2010-04-09 08:31:19 +020051 BLKIO_STAT_DEQUEUE
52#endif
53};
54
Vivek Goyal5624a4e2011-05-19 15:38:28 -040055/* Per cpu stats */
56enum stat_type_cpu {
57 BLKIO_STAT_CPU_SECTORS,
58 /* Total bytes transferred */
59 BLKIO_STAT_CPU_SERVICE_BYTES,
60 /* Total IOs serviced, post merge */
61 BLKIO_STAT_CPU_SERVICED,
62 BLKIO_STAT_CPU_NR
63};
64
Divyesh Shah84c124d2010-04-09 08:31:19 +020065enum stat_sub_type {
66 BLKIO_STAT_READ = 0,
67 BLKIO_STAT_WRITE,
68 BLKIO_STAT_SYNC,
69 BLKIO_STAT_ASYNC,
70 BLKIO_STAT_TOTAL
Divyesh Shah303a3ac2010-04-01 15:01:24 -070071};
72
Divyesh Shah812df482010-04-08 21:15:35 -070073/* blkg state flags */
74enum blkg_state_flags {
75 BLKG_waiting = 0,
76 BLKG_idling,
77 BLKG_empty,
78};
79
Vivek Goyal062a6442010-09-15 17:06:33 -040080/* cgroup files owned by proportional weight policy */
81enum blkcg_file_name_prop {
82 BLKIO_PROP_weight = 1,
83 BLKIO_PROP_weight_device,
84 BLKIO_PROP_io_service_bytes,
85 BLKIO_PROP_io_serviced,
86 BLKIO_PROP_time,
87 BLKIO_PROP_sectors,
Justin TerAvest167400d2011-03-12 16:54:00 +010088 BLKIO_PROP_unaccounted_time,
Vivek Goyal062a6442010-09-15 17:06:33 -040089 BLKIO_PROP_io_service_time,
90 BLKIO_PROP_io_wait_time,
91 BLKIO_PROP_io_merged,
92 BLKIO_PROP_io_queued,
93 BLKIO_PROP_avg_queue_size,
94 BLKIO_PROP_group_wait_time,
95 BLKIO_PROP_idle_time,
96 BLKIO_PROP_empty_time,
97 BLKIO_PROP_dequeue,
98};
99
Vivek Goyal4c9eefa2010-09-15 17:06:34 -0400100/* cgroup files owned by throttle policy */
101enum blkcg_file_name_throtl {
102 BLKIO_THROTL_read_bps_device,
103 BLKIO_THROTL_write_bps_device,
Vivek Goyal7702e8f2010-09-15 17:06:36 -0400104 BLKIO_THROTL_read_iops_device,
105 BLKIO_THROTL_write_iops_device,
Vivek Goyal4c9eefa2010-09-15 17:06:34 -0400106 BLKIO_THROTL_io_service_bytes,
107 BLKIO_THROTL_io_serviced,
108};
109
Vivek Goyal31e4c282009-12-03 12:59:42 -0500110struct blkio_cgroup {
111 struct cgroup_subsys_state css;
112 unsigned int weight;
113 spinlock_t lock;
114 struct hlist_head blkg_list;
115};
116
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700117struct blkio_group_stats {
118 /* total disk time and nr sectors dispatched by this group */
119 uint64_t time;
Divyesh Shahcdc11842010-04-08 21:15:10 -0700120 uint64_t stat_arr[BLKIO_STAT_QUEUED + 1][BLKIO_STAT_TOTAL];
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700121#ifdef CONFIG_DEBUG_BLK_CGROUP
Vivek Goyala23e6862011-05-19 15:38:20 -0400122 /* Time not charged to this cgroup */
123 uint64_t unaccounted_time;
124
Divyesh Shahcdc11842010-04-08 21:15:10 -0700125 /* Sum of number of IOs queued across all samples */
126 uint64_t avg_queue_size_sum;
127 /* Count of samples taken for average */
128 uint64_t avg_queue_size_samples;
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700129 /* How many times this group has been removed from service tree */
130 unsigned long dequeue;
Divyesh Shah812df482010-04-08 21:15:35 -0700131
132 /* Total time spent waiting for it to be assigned a timeslice. */
133 uint64_t group_wait_time;
Divyesh Shah812df482010-04-08 21:15:35 -0700134
135 /* Time spent idling for this blkio_group */
136 uint64_t idle_time;
Divyesh Shah812df482010-04-08 21:15:35 -0700137 /*
138 * Total time when we have requests queued and do not contain the
139 * current active queue.
140 */
141 uint64_t empty_time;
Tejun Heo997a0262012-03-08 10:53:58 -0800142
143 /* fields after this shouldn't be cleared on stat reset */
144 uint64_t start_group_wait_time;
145 uint64_t start_idle_time;
Divyesh Shah812df482010-04-08 21:15:35 -0700146 uint64_t start_empty_time;
147 uint16_t flags;
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700148#endif
149};
150
Tejun Heo997a0262012-03-08 10:53:58 -0800151#ifdef CONFIG_DEBUG_BLK_CGROUP
152#define BLKG_STATS_DEBUG_CLEAR_START \
153 offsetof(struct blkio_group_stats, unaccounted_time)
154#define BLKG_STATS_DEBUG_CLEAR_SIZE \
155 (offsetof(struct blkio_group_stats, start_group_wait_time) - \
156 BLKG_STATS_DEBUG_CLEAR_START)
157#endif
158
Vivek Goyal5624a4e2011-05-19 15:38:28 -0400159/* Per cpu blkio group stats */
160struct blkio_group_stats_cpu {
161 uint64_t sectors;
162 uint64_t stat_arr_cpu[BLKIO_STAT_CPU_NR][BLKIO_STAT_TOTAL];
Vivek Goyal575969a2011-05-19 15:38:29 -0400163 struct u64_stats_sync syncp;
Vivek Goyal5624a4e2011-05-19 15:38:28 -0400164};
165
Tejun Heoe56da7e2012-03-05 13:15:07 -0800166struct blkio_group_conf {
167 unsigned int weight;
168 unsigned int iops[2];
169 u64 bps[2];
170};
171
Tejun Heo03814112012-03-05 13:15:14 -0800172/* per-blkg per-policy data */
173struct blkg_policy_data {
174 /* the blkg this per-policy data belongs to */
175 struct blkio_group *blkg;
176
Tejun Heo549d3aa2012-03-05 13:15:16 -0800177 /* Configuration */
178 struct blkio_group_conf conf;
179
180 struct blkio_group_stats stats;
181 /* Per cpu stats pointer */
182 struct blkio_group_stats_cpu __percpu *stats_cpu;
183
Tejun Heo03814112012-03-05 13:15:14 -0800184 /* pol->pdata_size bytes of private data used by policy impl */
185 char pdata[] __aligned(__alignof__(unsigned long long));
186};
187
Vivek Goyal31e4c282009-12-03 12:59:42 -0500188struct blkio_group {
Tejun Heoc875f4d2012-03-05 13:15:22 -0800189 /* Pointer to the associated request_queue */
190 struct request_queue *q;
Tejun Heoe8989fa2012-03-05 13:15:20 -0800191 struct list_head q_node;
Vivek Goyal31e4c282009-12-03 12:59:42 -0500192 struct hlist_node blkcg_node;
Tejun Heo7ee9c562012-03-05 13:15:11 -0800193 struct blkio_cgroup *blkcg;
Vivek Goyal2868ef72009-12-03 12:59:48 -0500194 /* Store cgroup path */
195 char path[128];
Tejun Heo1adaf3d2012-03-05 13:15:15 -0800196 /* reference count */
197 int refcnt;
Vivek Goyal22084192009-12-03 12:59:49 -0500198
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700199 /* Need to serialize the stats in the case of reset/update */
200 spinlock_t stats_lock;
Tejun Heo549d3aa2012-03-05 13:15:16 -0800201 struct blkg_policy_data *pd[BLKIO_NR_POLICIES];
Tejun Heo1adaf3d2012-03-05 13:15:15 -0800202
Vivek Goyal1cd9e032012-03-08 10:53:56 -0800203 /* List of blkg waiting for per cpu stats memory to be allocated */
204 struct list_head alloc_node;
Tejun Heo1adaf3d2012-03-05 13:15:15 -0800205 struct rcu_head rcu_head;
Vivek Goyal31e4c282009-12-03 12:59:42 -0500206};
207
Tejun Heo03814112012-03-05 13:15:14 -0800208typedef void (blkio_init_group_fn)(struct blkio_group *blkg);
Tejun Heoca32aef2012-03-05 13:15:03 -0800209typedef void (blkio_update_group_weight_fn)(struct request_queue *q,
Vivek Goyalfe071432010-10-01 14:49:49 +0200210 struct blkio_group *blkg, unsigned int weight);
Tejun Heoca32aef2012-03-05 13:15:03 -0800211typedef void (blkio_update_group_read_bps_fn)(struct request_queue *q,
Vivek Goyalfe071432010-10-01 14:49:49 +0200212 struct blkio_group *blkg, u64 read_bps);
Tejun Heoca32aef2012-03-05 13:15:03 -0800213typedef void (blkio_update_group_write_bps_fn)(struct request_queue *q,
Vivek Goyalfe071432010-10-01 14:49:49 +0200214 struct blkio_group *blkg, u64 write_bps);
Tejun Heoca32aef2012-03-05 13:15:03 -0800215typedef void (blkio_update_group_read_iops_fn)(struct request_queue *q,
Vivek Goyalfe071432010-10-01 14:49:49 +0200216 struct blkio_group *blkg, unsigned int read_iops);
Tejun Heoca32aef2012-03-05 13:15:03 -0800217typedef void (blkio_update_group_write_iops_fn)(struct request_queue *q,
Vivek Goyalfe071432010-10-01 14:49:49 +0200218 struct blkio_group *blkg, unsigned int write_iops);
Vivek Goyal3e252062009-12-04 10:36:42 -0500219
220struct blkio_policy_ops {
Tejun Heo03814112012-03-05 13:15:14 -0800221 blkio_init_group_fn *blkio_init_group_fn;
Vivek Goyal3e252062009-12-04 10:36:42 -0500222 blkio_update_group_weight_fn *blkio_update_group_weight_fn;
Vivek Goyal4c9eefa2010-09-15 17:06:34 -0400223 blkio_update_group_read_bps_fn *blkio_update_group_read_bps_fn;
224 blkio_update_group_write_bps_fn *blkio_update_group_write_bps_fn;
Vivek Goyal7702e8f2010-09-15 17:06:36 -0400225 blkio_update_group_read_iops_fn *blkio_update_group_read_iops_fn;
226 blkio_update_group_write_iops_fn *blkio_update_group_write_iops_fn;
Vivek Goyal3e252062009-12-04 10:36:42 -0500227};
228
229struct blkio_policy_type {
230 struct list_head list;
231 struct blkio_policy_ops ops;
Vivek Goyal062a6442010-09-15 17:06:33 -0400232 enum blkio_policy_id plid;
Tejun Heo03814112012-03-05 13:15:14 -0800233 size_t pdata_size; /* policy specific private data size */
Vivek Goyal3e252062009-12-04 10:36:42 -0500234};
235
Tejun Heo5efd6112012-03-05 13:15:12 -0800236extern int blkcg_init_queue(struct request_queue *q);
237extern void blkcg_drain_queue(struct request_queue *q);
238extern void blkcg_exit_queue(struct request_queue *q);
239
Vivek Goyal3e252062009-12-04 10:36:42 -0500240/* Blkio controller policy registration */
241extern void blkio_policy_register(struct blkio_policy_type *);
242extern void blkio_policy_unregister(struct blkio_policy_type *);
Tejun Heoe8989fa2012-03-05 13:15:20 -0800243extern void blkg_destroy_all(struct request_queue *q, bool destroy_root);
244extern void update_root_blkg_pd(struct request_queue *q,
245 enum blkio_policy_id plid);
Vivek Goyal3e252062009-12-04 10:36:42 -0500246
Tejun Heo03814112012-03-05 13:15:14 -0800247/**
248 * blkg_to_pdata - get policy private data
249 * @blkg: blkg of interest
250 * @pol: policy of interest
251 *
252 * Return pointer to private data associated with the @blkg-@pol pair.
253 */
254static inline void *blkg_to_pdata(struct blkio_group *blkg,
255 struct blkio_policy_type *pol)
256{
Tejun Heo549d3aa2012-03-05 13:15:16 -0800257 return blkg ? blkg->pd[pol->plid]->pdata : NULL;
Tejun Heo03814112012-03-05 13:15:14 -0800258}
259
260/**
261 * pdata_to_blkg - get blkg associated with policy private data
262 * @pdata: policy private data of interest
263 * @pol: policy @pdata is for
264 *
265 * @pdata is policy private data for @pol. Determine the blkg it's
266 * associated with.
267 */
268static inline struct blkio_group *pdata_to_blkg(void *pdata,
269 struct blkio_policy_type *pol)
270{
271 if (pdata) {
272 struct blkg_policy_data *pd =
273 container_of(pdata, struct blkg_policy_data, pdata);
274 return pd->blkg;
275 }
276 return NULL;
277}
278
Vivek Goyalafc24d42010-04-26 19:27:56 +0200279static inline char *blkg_path(struct blkio_group *blkg)
280{
281 return blkg->path;
282}
283
Tejun Heo1adaf3d2012-03-05 13:15:15 -0800284/**
285 * blkg_get - get a blkg reference
286 * @blkg: blkg to get
287 *
288 * The caller should be holding queue_lock and an existing reference.
289 */
290static inline void blkg_get(struct blkio_group *blkg)
291{
292 lockdep_assert_held(blkg->q->queue_lock);
293 WARN_ON_ONCE(!blkg->refcnt);
294 blkg->refcnt++;
295}
296
297void __blkg_release(struct blkio_group *blkg);
298
299/**
300 * blkg_put - put a blkg reference
301 * @blkg: blkg to put
302 *
303 * The caller should be holding queue_lock.
304 */
305static inline void blkg_put(struct blkio_group *blkg)
306{
307 lockdep_assert_held(blkg->q->queue_lock);
308 WARN_ON_ONCE(blkg->refcnt <= 0);
309 if (!--blkg->refcnt)
310 __blkg_release(blkg);
311}
312
Jens Axboe2f5ea472009-12-03 21:06:43 +0100313#else
314
315struct blkio_group {
316};
317
Vivek Goyal3e252062009-12-04 10:36:42 -0500318struct blkio_policy_type {
319};
320
Tejun Heo5efd6112012-03-05 13:15:12 -0800321static inline int blkcg_init_queue(struct request_queue *q) { return 0; }
322static inline void blkcg_drain_queue(struct request_queue *q) { }
323static inline void blkcg_exit_queue(struct request_queue *q) { }
Vivek Goyal3e252062009-12-04 10:36:42 -0500324static inline void blkio_policy_register(struct blkio_policy_type *blkiop) { }
325static inline void blkio_policy_unregister(struct blkio_policy_type *blkiop) { }
Tejun Heo03aa2642012-03-05 13:15:19 -0800326static inline void blkg_destroy_all(struct request_queue *q,
Tejun Heo03aa2642012-03-05 13:15:19 -0800327 bool destory_root) { }
Tejun Heoe8989fa2012-03-05 13:15:20 -0800328static inline void update_root_blkg_pd(struct request_queue *q,
329 enum blkio_policy_id plid) { }
Vivek Goyal3e252062009-12-04 10:36:42 -0500330
Tejun Heo03814112012-03-05 13:15:14 -0800331static inline void *blkg_to_pdata(struct blkio_group *blkg,
332 struct blkio_policy_type *pol) { return NULL; }
333static inline struct blkio_group *pdata_to_blkg(void *pdata,
334 struct blkio_policy_type *pol) { return NULL; }
Vivek Goyalafc24d42010-04-26 19:27:56 +0200335static inline char *blkg_path(struct blkio_group *blkg) { return NULL; }
Tejun Heo1adaf3d2012-03-05 13:15:15 -0800336static inline void blkg_get(struct blkio_group *blkg) { }
337static inline void blkg_put(struct blkio_group *blkg) { }
Vivek Goyalafc24d42010-04-26 19:27:56 +0200338
Jens Axboe2f5ea472009-12-03 21:06:43 +0100339#endif
340
Justin TerAvestdf457f82011-03-08 19:45:00 +0100341#define BLKIO_WEIGHT_MIN 10
Vivek Goyal31e4c282009-12-03 12:59:42 -0500342#define BLKIO_WEIGHT_MAX 1000
343#define BLKIO_WEIGHT_DEFAULT 500
344
Vivek Goyal2868ef72009-12-03 12:59:48 -0500345#ifdef CONFIG_DEBUG_BLK_CGROUP
Tejun Heoc1768262012-03-05 13:15:17 -0800346void blkiocg_update_avg_queue_size_stats(struct blkio_group *blkg,
347 struct blkio_policy_type *pol);
Divyesh Shah91952912010-04-01 15:01:41 -0700348void blkiocg_update_dequeue_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800349 struct blkio_policy_type *pol,
350 unsigned long dequeue);
351void blkiocg_update_set_idle_time_stats(struct blkio_group *blkg,
352 struct blkio_policy_type *pol);
353void blkiocg_update_idle_time_stats(struct blkio_group *blkg,
354 struct blkio_policy_type *pol);
355void blkiocg_set_start_empty_time(struct blkio_group *blkg,
356 struct blkio_policy_type *pol);
Divyesh Shah812df482010-04-08 21:15:35 -0700357
358#define BLKG_FLAG_FNS(name) \
359static inline void blkio_mark_blkg_##name( \
360 struct blkio_group_stats *stats) \
361{ \
362 stats->flags |= (1 << BLKG_##name); \
363} \
364static inline void blkio_clear_blkg_##name( \
365 struct blkio_group_stats *stats) \
366{ \
367 stats->flags &= ~(1 << BLKG_##name); \
368} \
369static inline int blkio_blkg_##name(struct blkio_group_stats *stats) \
370{ \
371 return (stats->flags & (1 << BLKG_##name)) != 0; \
372} \
373
374BLKG_FLAG_FNS(waiting)
375BLKG_FLAG_FNS(idling)
376BLKG_FLAG_FNS(empty)
377#undef BLKG_FLAG_FNS
Vivek Goyal2868ef72009-12-03 12:59:48 -0500378#else
Tejun Heoc1768262012-03-05 13:15:17 -0800379static inline void blkiocg_update_avg_queue_size_stats(struct blkio_group *blkg,
380 struct blkio_policy_type *pol) { }
Divyesh Shah91952912010-04-01 15:01:41 -0700381static inline void blkiocg_update_dequeue_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800382 struct blkio_policy_type *pol, unsigned long dequeue) { }
383static inline void blkiocg_update_set_idle_time_stats(struct blkio_group *blkg,
384 struct blkio_policy_type *pol) { }
385static inline void blkiocg_update_idle_time_stats(struct blkio_group *blkg,
386 struct blkio_policy_type *pol) { }
387static inline void blkiocg_set_start_empty_time(struct blkio_group *blkg,
388 struct blkio_policy_type *pol) { }
Vivek Goyal2868ef72009-12-03 12:59:48 -0500389#endif
390
Tejun Heo32e380a2012-03-05 13:14:54 -0800391#ifdef CONFIG_BLK_CGROUP
Vivek Goyal31e4c282009-12-03 12:59:42 -0500392extern struct blkio_cgroup blkio_root_cgroup;
393extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup);
Tejun Heo4f85cb92012-03-05 13:15:28 -0800394extern struct blkio_cgroup *bio_blkio_cgroup(struct bio *bio);
Tejun Heocd1604f2012-03-05 13:15:06 -0800395extern struct blkio_group *blkg_lookup(struct blkio_cgroup *blkcg,
Tejun Heoe8989fa2012-03-05 13:15:20 -0800396 struct request_queue *q);
Tejun Heocd1604f2012-03-05 13:15:06 -0800397struct blkio_group *blkg_lookup_create(struct blkio_cgroup *blkcg,
398 struct request_queue *q,
399 enum blkio_policy_id plid,
400 bool for_root);
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700401void blkiocg_update_timeslice_used(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800402 struct blkio_policy_type *pol,
403 unsigned long time,
404 unsigned long unaccounted_time);
405void blkiocg_update_dispatch_stats(struct blkio_group *blkg,
406 struct blkio_policy_type *pol,
407 uint64_t bytes, bool direction, bool sync);
Divyesh Shah84c124d2010-04-09 08:31:19 +0200408void blkiocg_update_completion_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800409 struct blkio_policy_type *pol,
410 uint64_t start_time,
411 uint64_t io_start_time, bool direction,
412 bool sync);
413void blkiocg_update_io_merged_stats(struct blkio_group *blkg,
414 struct blkio_policy_type *pol,
415 bool direction, bool sync);
Divyesh Shaha11cdaa2010-04-13 19:59:17 +0200416void blkiocg_update_io_add_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800417 struct blkio_policy_type *pol,
418 struct blkio_group *curr_blkg, bool direction,
419 bool sync);
Divyesh Shaha11cdaa2010-04-13 19:59:17 +0200420void blkiocg_update_io_remove_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800421 struct blkio_policy_type *pol,
422 bool direction, bool sync);
Vivek Goyal31e4c282009-12-03 12:59:42 -0500423#else
Jens Axboe2f5ea472009-12-03 21:06:43 +0100424struct cgroup;
Vivek Goyal31e4c282009-12-03 12:59:42 -0500425static inline struct blkio_cgroup *
426cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; }
Vivek Goyal70087dc2011-05-16 15:24:08 +0200427static inline struct blkio_cgroup *
Tejun Heo4f85cb92012-03-05 13:15:28 -0800428bio_blkio_cgroup(struct bio *bio) { return NULL; }
Vivek Goyal31e4c282009-12-03 12:59:42 -0500429
Tejun Heocd1604f2012-03-05 13:15:06 -0800430static inline struct blkio_group *blkg_lookup(struct blkio_cgroup *blkcg,
431 void *key) { return NULL; }
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700432static inline void blkiocg_update_timeslice_used(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800433 struct blkio_policy_type *pol, unsigned long time,
434 unsigned long unaccounted_time) { }
Divyesh Shah84c124d2010-04-09 08:31:19 +0200435static inline void blkiocg_update_dispatch_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800436 struct blkio_policy_type *pol, uint64_t bytes,
437 bool direction, bool sync) { }
Divyesh Shah84c124d2010-04-09 08:31:19 +0200438static inline void blkiocg_update_completion_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800439 struct blkio_policy_type *pol, uint64_t start_time,
440 uint64_t io_start_time, bool direction, bool sync) { }
Divyesh Shah812d4022010-04-08 21:14:23 -0700441static inline void blkiocg_update_io_merged_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800442 struct blkio_policy_type *pol, bool direction,
443 bool sync) { }
Divyesh Shaha11cdaa2010-04-13 19:59:17 +0200444static inline void blkiocg_update_io_add_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800445 struct blkio_policy_type *pol,
446 struct blkio_group *curr_blkg, bool direction,
447 bool sync) { }
Divyesh Shaha11cdaa2010-04-13 19:59:17 +0200448static inline void blkiocg_update_io_remove_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800449 struct blkio_policy_type *pol, bool direction,
450 bool sync) { }
Vivek Goyal31e4c282009-12-03 12:59:42 -0500451#endif
452#endif /* _BLK_CGROUP_H */