blob: 8bdcf504f94bb13ff86c569ce412e859b40fc99f [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 {
122 /* total disk time and nr sectors dispatched by this group */
123 uint64_t time;
Tejun Heoc4c76a02012-03-08 10:53:59 -0800124 uint64_t stat_arr[BLKIO_STAT_ARR_NR][BLKIO_STAT_TOTAL];
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700125#ifdef CONFIG_DEBUG_BLK_CGROUP
Vivek Goyala23e6862011-05-19 15:38:20 -0400126 /* Time not charged to this cgroup */
127 uint64_t unaccounted_time;
128
Divyesh Shahcdc11842010-04-08 21:15:10 -0700129 /* Sum of number of IOs queued across all samples */
130 uint64_t avg_queue_size_sum;
131 /* Count of samples taken for average */
132 uint64_t avg_queue_size_samples;
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700133 /* How many times this group has been removed from service tree */
134 unsigned long dequeue;
Divyesh Shah812df482010-04-08 21:15:35 -0700135
136 /* Total time spent waiting for it to be assigned a timeslice. */
137 uint64_t group_wait_time;
Divyesh Shah812df482010-04-08 21:15:35 -0700138
139 /* Time spent idling for this blkio_group */
140 uint64_t idle_time;
Divyesh Shah812df482010-04-08 21:15:35 -0700141 /*
142 * Total time when we have requests queued and do not contain the
143 * current active queue.
144 */
145 uint64_t empty_time;
Tejun Heo997a0262012-03-08 10:53:58 -0800146
147 /* fields after this shouldn't be cleared on stat reset */
148 uint64_t start_group_wait_time;
149 uint64_t start_idle_time;
Divyesh Shah812df482010-04-08 21:15:35 -0700150 uint64_t start_empty_time;
151 uint16_t flags;
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700152#endif
153};
154
Tejun Heo997a0262012-03-08 10:53:58 -0800155#ifdef CONFIG_DEBUG_BLK_CGROUP
156#define BLKG_STATS_DEBUG_CLEAR_START \
157 offsetof(struct blkio_group_stats, unaccounted_time)
158#define BLKG_STATS_DEBUG_CLEAR_SIZE \
159 (offsetof(struct blkio_group_stats, start_group_wait_time) - \
160 BLKG_STATS_DEBUG_CLEAR_START)
161#endif
162
Vivek Goyal5624a4e2011-05-19 15:38:28 -0400163/* Per cpu blkio group stats */
164struct blkio_group_stats_cpu {
165 uint64_t sectors;
166 uint64_t stat_arr_cpu[BLKIO_STAT_CPU_NR][BLKIO_STAT_TOTAL];
Vivek Goyal575969a2011-05-19 15:38:29 -0400167 struct u64_stats_sync syncp;
Vivek Goyal5624a4e2011-05-19 15:38:28 -0400168};
169
Tejun Heoe56da7e2012-03-05 13:15:07 -0800170struct blkio_group_conf {
171 unsigned int weight;
172 unsigned int iops[2];
173 u64 bps[2];
174};
175
Tejun Heo03814112012-03-05 13:15:14 -0800176/* per-blkg per-policy data */
177struct blkg_policy_data {
178 /* the blkg this per-policy data belongs to */
179 struct blkio_group *blkg;
180
Tejun Heo549d3aa2012-03-05 13:15:16 -0800181 /* Configuration */
182 struct blkio_group_conf conf;
183
184 struct blkio_group_stats stats;
185 /* Per cpu stats pointer */
186 struct blkio_group_stats_cpu __percpu *stats_cpu;
187
Tejun Heo03814112012-03-05 13:15:14 -0800188 /* pol->pdata_size bytes of private data used by policy impl */
189 char pdata[] __aligned(__alignof__(unsigned long long));
190};
191
Vivek Goyal31e4c282009-12-03 12:59:42 -0500192struct blkio_group {
Tejun Heoc875f4d2012-03-05 13:15:22 -0800193 /* Pointer to the associated request_queue */
194 struct request_queue *q;
Tejun Heoe8989fa2012-03-05 13:15:20 -0800195 struct list_head q_node;
Vivek Goyal31e4c282009-12-03 12:59:42 -0500196 struct hlist_node blkcg_node;
Tejun Heo7ee9c562012-03-05 13:15:11 -0800197 struct blkio_cgroup *blkcg;
Vivek Goyal2868ef72009-12-03 12:59:48 -0500198 /* Store cgroup path */
199 char path[128];
Tejun Heo1adaf3d2012-03-05 13:15:15 -0800200 /* reference count */
201 int refcnt;
Vivek Goyal22084192009-12-03 12:59:49 -0500202
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700203 /* Need to serialize the stats in the case of reset/update */
204 spinlock_t stats_lock;
Tejun Heo549d3aa2012-03-05 13:15:16 -0800205 struct blkg_policy_data *pd[BLKIO_NR_POLICIES];
Tejun Heo1adaf3d2012-03-05 13:15:15 -0800206
Vivek Goyal1cd9e032012-03-08 10:53:56 -0800207 /* List of blkg waiting for per cpu stats memory to be allocated */
208 struct list_head alloc_node;
Tejun Heo1adaf3d2012-03-05 13:15:15 -0800209 struct rcu_head rcu_head;
Vivek Goyal31e4c282009-12-03 12:59:42 -0500210};
211
Tejun Heo03814112012-03-05 13:15:14 -0800212typedef void (blkio_init_group_fn)(struct blkio_group *blkg);
Tejun Heoca32aef2012-03-05 13:15:03 -0800213typedef void (blkio_update_group_weight_fn)(struct request_queue *q,
Vivek Goyalfe071432010-10-01 14:49:49 +0200214 struct blkio_group *blkg, unsigned int weight);
Tejun Heoca32aef2012-03-05 13:15:03 -0800215typedef void (blkio_update_group_read_bps_fn)(struct request_queue *q,
Vivek Goyalfe071432010-10-01 14:49:49 +0200216 struct blkio_group *blkg, u64 read_bps);
Tejun Heoca32aef2012-03-05 13:15:03 -0800217typedef void (blkio_update_group_write_bps_fn)(struct request_queue *q,
Vivek Goyalfe071432010-10-01 14:49:49 +0200218 struct blkio_group *blkg, u64 write_bps);
Tejun Heoca32aef2012-03-05 13:15:03 -0800219typedef void (blkio_update_group_read_iops_fn)(struct request_queue *q,
Vivek Goyalfe071432010-10-01 14:49:49 +0200220 struct blkio_group *blkg, unsigned int read_iops);
Tejun Heoca32aef2012-03-05 13:15:03 -0800221typedef void (blkio_update_group_write_iops_fn)(struct request_queue *q,
Vivek Goyalfe071432010-10-01 14:49:49 +0200222 struct blkio_group *blkg, unsigned int write_iops);
Vivek Goyal3e252062009-12-04 10:36:42 -0500223
224struct blkio_policy_ops {
Tejun Heo03814112012-03-05 13:15:14 -0800225 blkio_init_group_fn *blkio_init_group_fn;
Vivek Goyal3e252062009-12-04 10:36:42 -0500226 blkio_update_group_weight_fn *blkio_update_group_weight_fn;
Vivek Goyal4c9eefa2010-09-15 17:06:34 -0400227 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;
Vivek Goyal7702e8f2010-09-15 17:06:36 -0400229 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;
Vivek Goyal3e252062009-12-04 10:36:42 -0500231};
232
233struct blkio_policy_type {
234 struct list_head list;
235 struct blkio_policy_ops ops;
Vivek Goyal062a6442010-09-15 17:06:33 -0400236 enum blkio_policy_id plid;
Tejun Heo03814112012-03-05 13:15:14 -0800237 size_t pdata_size; /* policy specific private data size */
Vivek Goyal3e252062009-12-04 10:36:42 -0500238};
239
Tejun Heo5efd6112012-03-05 13:15:12 -0800240extern int blkcg_init_queue(struct request_queue *q);
241extern void blkcg_drain_queue(struct request_queue *q);
242extern void blkcg_exit_queue(struct request_queue *q);
243
Vivek Goyal3e252062009-12-04 10:36:42 -0500244/* Blkio controller policy registration */
245extern void blkio_policy_register(struct blkio_policy_type *);
246extern void blkio_policy_unregister(struct blkio_policy_type *);
Tejun Heoe8989fa2012-03-05 13:15:20 -0800247extern void blkg_destroy_all(struct request_queue *q, bool destroy_root);
248extern void update_root_blkg_pd(struct request_queue *q,
249 enum blkio_policy_id plid);
Vivek Goyal3e252062009-12-04 10:36:42 -0500250
Tejun Heo03814112012-03-05 13:15:14 -0800251/**
252 * blkg_to_pdata - get policy private data
253 * @blkg: blkg of interest
254 * @pol: policy of interest
255 *
256 * Return pointer to private data associated with the @blkg-@pol pair.
257 */
258static inline void *blkg_to_pdata(struct blkio_group *blkg,
259 struct blkio_policy_type *pol)
260{
Tejun Heo549d3aa2012-03-05 13:15:16 -0800261 return blkg ? blkg->pd[pol->plid]->pdata : NULL;
Tejun Heo03814112012-03-05 13:15:14 -0800262}
263
264/**
265 * pdata_to_blkg - get blkg associated with policy private data
266 * @pdata: policy private data of interest
267 * @pol: policy @pdata is for
268 *
269 * @pdata is policy private data for @pol. Determine the blkg it's
270 * associated with.
271 */
272static inline struct blkio_group *pdata_to_blkg(void *pdata,
273 struct blkio_policy_type *pol)
274{
275 if (pdata) {
276 struct blkg_policy_data *pd =
277 container_of(pdata, struct blkg_policy_data, pdata);
278 return pd->blkg;
279 }
280 return NULL;
281}
282
Vivek Goyalafc24d42010-04-26 19:27:56 +0200283static inline char *blkg_path(struct blkio_group *blkg)
284{
285 return blkg->path;
286}
287
Tejun Heo1adaf3d2012-03-05 13:15:15 -0800288/**
289 * blkg_get - get a blkg reference
290 * @blkg: blkg to get
291 *
292 * The caller should be holding queue_lock and an existing reference.
293 */
294static inline void blkg_get(struct blkio_group *blkg)
295{
296 lockdep_assert_held(blkg->q->queue_lock);
297 WARN_ON_ONCE(!blkg->refcnt);
298 blkg->refcnt++;
299}
300
301void __blkg_release(struct blkio_group *blkg);
302
303/**
304 * blkg_put - put a blkg reference
305 * @blkg: blkg to put
306 *
307 * The caller should be holding queue_lock.
308 */
309static inline void blkg_put(struct blkio_group *blkg)
310{
311 lockdep_assert_held(blkg->q->queue_lock);
312 WARN_ON_ONCE(blkg->refcnt <= 0);
313 if (!--blkg->refcnt)
314 __blkg_release(blkg);
315}
316
Jens Axboe2f5ea472009-12-03 21:06:43 +0100317#else
318
319struct blkio_group {
320};
321
Vivek Goyal3e252062009-12-04 10:36:42 -0500322struct blkio_policy_type {
323};
324
Tejun Heo5efd6112012-03-05 13:15:12 -0800325static inline int blkcg_init_queue(struct request_queue *q) { return 0; }
326static inline void blkcg_drain_queue(struct request_queue *q) { }
327static inline void blkcg_exit_queue(struct request_queue *q) { }
Vivek Goyal3e252062009-12-04 10:36:42 -0500328static inline void blkio_policy_register(struct blkio_policy_type *blkiop) { }
329static inline void blkio_policy_unregister(struct blkio_policy_type *blkiop) { }
Tejun Heo03aa2642012-03-05 13:15:19 -0800330static inline void blkg_destroy_all(struct request_queue *q,
Tejun Heo03aa2642012-03-05 13:15:19 -0800331 bool destory_root) { }
Tejun Heoe8989fa2012-03-05 13:15:20 -0800332static inline void update_root_blkg_pd(struct request_queue *q,
333 enum blkio_policy_id plid) { }
Vivek Goyal3e252062009-12-04 10:36:42 -0500334
Tejun Heo03814112012-03-05 13:15:14 -0800335static inline void *blkg_to_pdata(struct blkio_group *blkg,
336 struct blkio_policy_type *pol) { return NULL; }
337static inline struct blkio_group *pdata_to_blkg(void *pdata,
338 struct blkio_policy_type *pol) { return NULL; }
Vivek Goyalafc24d42010-04-26 19:27:56 +0200339static inline char *blkg_path(struct blkio_group *blkg) { return NULL; }
Tejun Heo1adaf3d2012-03-05 13:15:15 -0800340static inline void blkg_get(struct blkio_group *blkg) { }
341static inline void blkg_put(struct blkio_group *blkg) { }
Vivek Goyalafc24d42010-04-26 19:27:56 +0200342
Jens Axboe2f5ea472009-12-03 21:06:43 +0100343#endif
344
Justin TerAvestdf457f82011-03-08 19:45:00 +0100345#define BLKIO_WEIGHT_MIN 10
Vivek Goyal31e4c282009-12-03 12:59:42 -0500346#define BLKIO_WEIGHT_MAX 1000
347#define BLKIO_WEIGHT_DEFAULT 500
348
Vivek Goyal2868ef72009-12-03 12:59:48 -0500349#ifdef CONFIG_DEBUG_BLK_CGROUP
Tejun Heoc1768262012-03-05 13:15:17 -0800350void blkiocg_update_avg_queue_size_stats(struct blkio_group *blkg,
351 struct blkio_policy_type *pol);
Divyesh Shah91952912010-04-01 15:01:41 -0700352void blkiocg_update_dequeue_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800353 struct blkio_policy_type *pol,
354 unsigned long dequeue);
355void blkiocg_update_set_idle_time_stats(struct blkio_group *blkg,
356 struct blkio_policy_type *pol);
357void blkiocg_update_idle_time_stats(struct blkio_group *blkg,
358 struct blkio_policy_type *pol);
359void blkiocg_set_start_empty_time(struct blkio_group *blkg,
360 struct blkio_policy_type *pol);
Divyesh Shah812df482010-04-08 21:15:35 -0700361
362#define BLKG_FLAG_FNS(name) \
363static inline void blkio_mark_blkg_##name( \
364 struct blkio_group_stats *stats) \
365{ \
366 stats->flags |= (1 << BLKG_##name); \
367} \
368static inline void blkio_clear_blkg_##name( \
369 struct blkio_group_stats *stats) \
370{ \
371 stats->flags &= ~(1 << BLKG_##name); \
372} \
373static inline int blkio_blkg_##name(struct blkio_group_stats *stats) \
374{ \
375 return (stats->flags & (1 << BLKG_##name)) != 0; \
376} \
377
378BLKG_FLAG_FNS(waiting)
379BLKG_FLAG_FNS(idling)
380BLKG_FLAG_FNS(empty)
381#undef BLKG_FLAG_FNS
Vivek Goyal2868ef72009-12-03 12:59:48 -0500382#else
Tejun Heoc1768262012-03-05 13:15:17 -0800383static inline void blkiocg_update_avg_queue_size_stats(struct blkio_group *blkg,
384 struct blkio_policy_type *pol) { }
Divyesh Shah91952912010-04-01 15:01:41 -0700385static inline void blkiocg_update_dequeue_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800386 struct blkio_policy_type *pol, unsigned long dequeue) { }
387static inline void blkiocg_update_set_idle_time_stats(struct blkio_group *blkg,
388 struct blkio_policy_type *pol) { }
389static inline void blkiocg_update_idle_time_stats(struct blkio_group *blkg,
390 struct blkio_policy_type *pol) { }
391static inline void blkiocg_set_start_empty_time(struct blkio_group *blkg,
392 struct blkio_policy_type *pol) { }
Vivek Goyal2868ef72009-12-03 12:59:48 -0500393#endif
394
Tejun Heo32e380a2012-03-05 13:14:54 -0800395#ifdef CONFIG_BLK_CGROUP
Vivek Goyal31e4c282009-12-03 12:59:42 -0500396extern struct blkio_cgroup blkio_root_cgroup;
397extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup);
Tejun Heo4f85cb92012-03-05 13:15:28 -0800398extern struct blkio_cgroup *bio_blkio_cgroup(struct bio *bio);
Tejun Heocd1604f2012-03-05 13:15:06 -0800399extern struct blkio_group *blkg_lookup(struct blkio_cgroup *blkcg,
Tejun Heoe8989fa2012-03-05 13:15:20 -0800400 struct request_queue *q);
Tejun Heocd1604f2012-03-05 13:15:06 -0800401struct blkio_group *blkg_lookup_create(struct blkio_cgroup *blkcg,
402 struct request_queue *q,
403 enum blkio_policy_id plid,
404 bool for_root);
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700405void blkiocg_update_timeslice_used(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800406 struct blkio_policy_type *pol,
407 unsigned long time,
408 unsigned long unaccounted_time);
409void blkiocg_update_dispatch_stats(struct blkio_group *blkg,
410 struct blkio_policy_type *pol,
411 uint64_t bytes, bool direction, bool sync);
Divyesh Shah84c124d2010-04-09 08:31:19 +0200412void blkiocg_update_completion_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800413 struct blkio_policy_type *pol,
414 uint64_t start_time,
415 uint64_t io_start_time, bool direction,
416 bool sync);
417void blkiocg_update_io_merged_stats(struct blkio_group *blkg,
418 struct blkio_policy_type *pol,
419 bool direction, bool sync);
Divyesh Shaha11cdaa2010-04-13 19:59:17 +0200420void blkiocg_update_io_add_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800421 struct blkio_policy_type *pol,
422 struct blkio_group *curr_blkg, bool direction,
423 bool sync);
Divyesh Shaha11cdaa2010-04-13 19:59:17 +0200424void blkiocg_update_io_remove_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800425 struct blkio_policy_type *pol,
426 bool direction, bool sync);
Vivek Goyal31e4c282009-12-03 12:59:42 -0500427#else
Jens Axboe2f5ea472009-12-03 21:06:43 +0100428struct cgroup;
Vivek Goyal31e4c282009-12-03 12:59:42 -0500429static inline struct blkio_cgroup *
430cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; }
Vivek Goyal70087dc2011-05-16 15:24:08 +0200431static inline struct blkio_cgroup *
Tejun Heo4f85cb92012-03-05 13:15:28 -0800432bio_blkio_cgroup(struct bio *bio) { return NULL; }
Vivek Goyal31e4c282009-12-03 12:59:42 -0500433
Tejun Heocd1604f2012-03-05 13:15:06 -0800434static inline struct blkio_group *blkg_lookup(struct blkio_cgroup *blkcg,
435 void *key) { return NULL; }
Divyesh Shah303a3ac2010-04-01 15:01:24 -0700436static inline void blkiocg_update_timeslice_used(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800437 struct blkio_policy_type *pol, unsigned long time,
438 unsigned long unaccounted_time) { }
Divyesh Shah84c124d2010-04-09 08:31:19 +0200439static inline void blkiocg_update_dispatch_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800440 struct blkio_policy_type *pol, uint64_t bytes,
441 bool direction, bool sync) { }
Divyesh Shah84c124d2010-04-09 08:31:19 +0200442static inline void blkiocg_update_completion_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800443 struct blkio_policy_type *pol, uint64_t start_time,
444 uint64_t io_start_time, bool direction, bool sync) { }
Divyesh Shah812d4022010-04-08 21:14:23 -0700445static inline void blkiocg_update_io_merged_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800446 struct blkio_policy_type *pol, bool direction,
447 bool sync) { }
Divyesh Shaha11cdaa2010-04-13 19:59:17 +0200448static inline void blkiocg_update_io_add_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800449 struct blkio_policy_type *pol,
450 struct blkio_group *curr_blkg, bool direction,
451 bool sync) { }
Divyesh Shaha11cdaa2010-04-13 19:59:17 +0200452static inline void blkiocg_update_io_remove_stats(struct blkio_group *blkg,
Tejun Heoc1768262012-03-05 13:15:17 -0800453 struct blkio_policy_type *pol, bool direction,
454 bool sync) { }
Vivek Goyal31e4c282009-12-03 12:59:42 -0500455#endif
456#endif /* _BLK_CGROUP_H */