aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-cgroup.h
diff options
context:
space:
mode:
Diffstat (limited to 'block/blk-cgroup.h')
-rw-r--r--block/blk-cgroup.h40
1 files changed, 29 insertions, 11 deletions
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index c774930cc206..a71d2904ffb9 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -14,6 +14,7 @@
14 */ 14 */
15 15
16#include <linux/cgroup.h> 16#include <linux/cgroup.h>
17#include <linux/u64_stats_sync.h>
17 18
18enum blkio_policy_id { 19enum blkio_policy_id {
19 BLKIO_POLICY_PROP = 0, /* Proportional Bandwidth division */ 20 BLKIO_POLICY_PROP = 0, /* Proportional Bandwidth division */
@@ -36,22 +37,15 @@ enum stat_type {
36 * 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
37 * accurate when NCQ is turned on. */ 38 * accurate when NCQ is turned on. */
38 BLKIO_STAT_SERVICE_TIME = 0, 39 BLKIO_STAT_SERVICE_TIME = 0,
39 /* Total bytes transferred */
40 BLKIO_STAT_SERVICE_BYTES,
41 /* Total IOs serviced, post merge */
42 BLKIO_STAT_SERVICED,
43 /* Total time spent waiting in scheduler queue in ns */ 40 /* Total time spent waiting in scheduler queue in ns */
44 BLKIO_STAT_WAIT_TIME, 41 BLKIO_STAT_WAIT_TIME,
45 /* Number of IOs merged */
46 BLKIO_STAT_MERGED,
47 /* Number of IOs queued up */ 42 /* Number of IOs queued up */
48 BLKIO_STAT_QUEUED, 43 BLKIO_STAT_QUEUED,
49 /* All the single valued stats go below this */ 44 /* All the single valued stats go below this */
50 BLKIO_STAT_TIME, 45 BLKIO_STAT_TIME,
51 BLKIO_STAT_SECTORS, 46#ifdef CONFIG_DEBUG_BLK_CGROUP
52 /* Time not charged to this cgroup */ 47 /* Time not charged to this cgroup */
53 BLKIO_STAT_UNACCOUNTED_TIME, 48 BLKIO_STAT_UNACCOUNTED_TIME,
54#ifdef CONFIG_DEBUG_BLK_CGROUP
55 BLKIO_STAT_AVG_QUEUE_SIZE, 49 BLKIO_STAT_AVG_QUEUE_SIZE,
56 BLKIO_STAT_IDLE_TIME, 50 BLKIO_STAT_IDLE_TIME,
57 BLKIO_STAT_EMPTY_TIME, 51 BLKIO_STAT_EMPTY_TIME,
@@ -60,6 +54,18 @@ enum stat_type {
60#endif 54#endif
61}; 55};
62 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
63enum stat_sub_type { 69enum stat_sub_type {
64 BLKIO_STAT_READ = 0, 70 BLKIO_STAT_READ = 0,
65 BLKIO_STAT_WRITE, 71 BLKIO_STAT_WRITE,
@@ -116,11 +122,11 @@ struct blkio_cgroup {
116struct blkio_group_stats { 122struct blkio_group_stats {
117 /* total disk time and nr sectors dispatched by this group */ 123 /* total disk time and nr sectors dispatched by this group */
118 uint64_t time; 124 uint64_t time;
119 uint64_t sectors;
120 /* Time not charged to this cgroup */
121 uint64_t unaccounted_time;
122 uint64_t stat_arr[BLKIO_STAT_QUEUED + 1][BLKIO_STAT_TOTAL]; 125 uint64_t stat_arr[BLKIO_STAT_QUEUED + 1][BLKIO_STAT_TOTAL];
123#ifdef CONFIG_DEBUG_BLK_CGROUP 126#ifdef CONFIG_DEBUG_BLK_CGROUP
127 /* Time not charged to this cgroup */
128 uint64_t unaccounted_time;
129
124 /* Sum of number of IOs queued across all samples */ 130 /* Sum of number of IOs queued across all samples */
125 uint64_t avg_queue_size_sum; 131 uint64_t avg_queue_size_sum;
126 /* Count of samples taken for average */ 132 /* Count of samples taken for average */
@@ -145,6 +151,13 @@ struct blkio_group_stats {
145#endif 151#endif
146}; 152};
147 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
148struct blkio_group { 161struct blkio_group {
149 /* An rcu protected unique identifier for the group */ 162 /* An rcu protected unique identifier for the group */
150 void *key; 163 void *key;
@@ -160,6 +173,8 @@ struct blkio_group {
160 /* Need to serialize the stats in the case of reset/update */ 173 /* Need to serialize the stats in the case of reset/update */
161 spinlock_t stats_lock; 174 spinlock_t stats_lock;
162 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;
163}; 178};
164 179
165struct blkio_policy_node { 180struct blkio_policy_node {
@@ -295,6 +310,7 @@ extern struct blkio_cgroup *task_blkio_cgroup(struct task_struct *tsk);
295extern void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, 310extern void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg,
296 struct blkio_group *blkg, void *key, dev_t dev, 311 struct blkio_group *blkg, void *key, dev_t dev,
297 enum blkio_policy_id plid); 312 enum blkio_policy_id plid);
313extern int blkio_alloc_blkg_stats(struct blkio_group *blkg);
298extern int blkiocg_del_blkio_group(struct blkio_group *blkg); 314extern int blkiocg_del_blkio_group(struct blkio_group *blkg);
299extern struct blkio_group *blkiocg_lookup_group(struct blkio_cgroup *blkcg, 315extern struct blkio_group *blkiocg_lookup_group(struct blkio_cgroup *blkcg,
300 void *key); 316 void *key);
@@ -322,6 +338,8 @@ static inline void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg,
322 struct blkio_group *blkg, void *key, dev_t dev, 338 struct blkio_group *blkg, void *key, dev_t dev,
323 enum blkio_policy_id plid) {} 339 enum blkio_policy_id plid) {}
324 340
341static inline int blkio_alloc_blkg_stats(struct blkio_group *blkg) { return 0; }
342
325static inline int 343static inline int
326blkiocg_del_blkio_group(struct blkio_group *blkg) { return 0; } 344blkiocg_del_blkio_group(struct blkio_group *blkg) { return 0; }
327 345