diff options
-rw-r--r-- | include/linux/cgroup.h | 71 |
1 files changed, 41 insertions, 30 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 499900d0cee7..bb8feb9feccd 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -47,14 +47,18 @@ enum cgroup_subsys_id { | |||
47 | 47 | ||
48 | /* Per-subsystem/per-cgroup state maintained by the system. */ | 48 | /* Per-subsystem/per-cgroup state maintained by the system. */ |
49 | struct cgroup_subsys_state { | 49 | struct cgroup_subsys_state { |
50 | /* The cgroup that this subsystem is attached to. Useful | 50 | /* |
51 | * The cgroup that this subsystem is attached to. Useful | ||
51 | * for subsystems that want to know about the cgroup | 52 | * for subsystems that want to know about the cgroup |
52 | * hierarchy structure */ | 53 | * hierarchy structure |
54 | */ | ||
53 | struct cgroup *cgroup; | 55 | struct cgroup *cgroup; |
54 | 56 | ||
55 | /* State maintained by the cgroup system to allow subsystems | 57 | /* |
58 | * State maintained by the cgroup system to allow subsystems | ||
56 | * to be "busy". Should be accessed via css_get(), | 59 | * to be "busy". Should be accessed via css_get(), |
57 | * css_tryget() and and css_put(). */ | 60 | * css_tryget() and and css_put(). |
61 | */ | ||
58 | 62 | ||
59 | atomic_t refcnt; | 63 | atomic_t refcnt; |
60 | 64 | ||
@@ -120,8 +124,10 @@ static inline void css_put(struct cgroup_subsys_state *css) | |||
120 | enum { | 124 | enum { |
121 | /* Control Group is dead */ | 125 | /* Control Group is dead */ |
122 | CGRP_REMOVED, | 126 | CGRP_REMOVED, |
123 | /* Control Group has previously had a child cgroup or a task, | 127 | /* |
124 | * but no longer (only if CGRP_NOTIFY_ON_RELEASE is set) */ | 128 | * Control Group has previously had a child cgroup or a task, |
129 | * but no longer (only if CGRP_NOTIFY_ON_RELEASE is set) | ||
130 | */ | ||
125 | CGRP_RELEASABLE, | 131 | CGRP_RELEASABLE, |
126 | /* Control Group requires release notifications to userspace */ | 132 | /* Control Group requires release notifications to userspace */ |
127 | CGRP_NOTIFY_ON_RELEASE, | 133 | CGRP_NOTIFY_ON_RELEASE, |
@@ -130,9 +136,10 @@ enum { | |||
130 | struct cgroup { | 136 | struct cgroup { |
131 | unsigned long flags; /* "unsigned long" so bitops work */ | 137 | unsigned long flags; /* "unsigned long" so bitops work */ |
132 | 138 | ||
133 | /* count users of this cgroup. >0 means busy, but doesn't | 139 | /* |
134 | * necessarily indicate the number of tasks in the | 140 | * count users of this cgroup. >0 means busy, but doesn't |
135 | * cgroup */ | 141 | * necessarily indicate the number of tasks in the cgroup |
142 | */ | ||
136 | atomic_t count; | 143 | atomic_t count; |
137 | 144 | ||
138 | /* | 145 | /* |
@@ -142,7 +149,7 @@ struct cgroup { | |||
142 | struct list_head sibling; /* my parent's children */ | 149 | struct list_head sibling; /* my parent's children */ |
143 | struct list_head children; /* my children */ | 150 | struct list_head children; /* my children */ |
144 | 151 | ||
145 | struct cgroup *parent; /* my parent */ | 152 | struct cgroup *parent; /* my parent */ |
146 | struct dentry *dentry; /* cgroup fs entry, RCU protected */ | 153 | struct dentry *dentry; /* cgroup fs entry, RCU protected */ |
147 | 154 | ||
148 | /* Private pointers for each registered subsystem */ | 155 | /* Private pointers for each registered subsystem */ |
@@ -177,11 +184,12 @@ struct cgroup { | |||
177 | struct rcu_head rcu_head; | 184 | struct rcu_head rcu_head; |
178 | }; | 185 | }; |
179 | 186 | ||
180 | /* A css_set is a structure holding pointers to a set of | 187 | /* |
188 | * A css_set is a structure holding pointers to a set of | ||
181 | * cgroup_subsys_state objects. This saves space in the task struct | 189 | * cgroup_subsys_state objects. This saves space in the task struct |
182 | * object and speeds up fork()/exit(), since a single inc/dec and a | 190 | * object and speeds up fork()/exit(), since a single inc/dec and a |
183 | * list_add()/del() can bump the reference count on the entire | 191 | * list_add()/del() can bump the reference count on the entire cgroup |
184 | * cgroup set for a task. | 192 | * set for a task. |
185 | */ | 193 | */ |
186 | 194 | ||
187 | struct css_set { | 195 | struct css_set { |
@@ -226,13 +234,8 @@ struct cgroup_map_cb { | |||
226 | void *state; | 234 | void *state; |
227 | }; | 235 | }; |
228 | 236 | ||
229 | /* struct cftype: | 237 | /* |
230 | * | 238 | * struct cftype: handler definitions for cgroup control files |
231 | * The files in the cgroup filesystem mostly have a very simple read/write | ||
232 | * handling, some common function will take care of it. Nevertheless some cases | ||
233 | * (read tasks) are special and therefore I define this structure for every | ||
234 | * kind of file. | ||
235 | * | ||
236 | * | 239 | * |
237 | * When reading/writing to a file: | 240 | * When reading/writing to a file: |
238 | * - the cgroup to use is file->f_dentry->d_parent->d_fsdata | 241 | * - the cgroup to use is file->f_dentry->d_parent->d_fsdata |
@@ -241,8 +244,10 @@ struct cgroup_map_cb { | |||
241 | 244 | ||
242 | #define MAX_CFTYPE_NAME 64 | 245 | #define MAX_CFTYPE_NAME 64 |
243 | struct cftype { | 246 | struct cftype { |
244 | /* By convention, the name should begin with the name of the | 247 | /* |
245 | * subsystem, followed by a period */ | 248 | * By convention, the name should begin with the name of the |
249 | * subsystem, followed by a period | ||
250 | */ | ||
246 | char name[MAX_CFTYPE_NAME]; | 251 | char name[MAX_CFTYPE_NAME]; |
247 | int private; | 252 | int private; |
248 | 253 | ||
@@ -321,13 +326,17 @@ struct cgroup_scanner { | |||
321 | struct ptr_heap *heap; | 326 | struct ptr_heap *heap; |
322 | }; | 327 | }; |
323 | 328 | ||
324 | /* Add a new file to the given cgroup directory. Should only be | 329 | /* |
325 | * called by subsystems from within a populate() method */ | 330 | * Add a new file to the given cgroup directory. Should only be |
331 | * called by subsystems from within a populate() method | ||
332 | */ | ||
326 | int cgroup_add_file(struct cgroup *cgrp, struct cgroup_subsys *subsys, | 333 | int cgroup_add_file(struct cgroup *cgrp, struct cgroup_subsys *subsys, |
327 | const struct cftype *cft); | 334 | const struct cftype *cft); |
328 | 335 | ||
329 | /* Add a set of new files to the given cgroup directory. Should | 336 | /* |
330 | * only be called by subsystems from within a populate() method */ | 337 | * Add a set of new files to the given cgroup directory. Should |
338 | * only be called by subsystems from within a populate() method | ||
339 | */ | ||
331 | int cgroup_add_files(struct cgroup *cgrp, | 340 | int cgroup_add_files(struct cgroup *cgrp, |
332 | struct cgroup_subsys *subsys, | 341 | struct cgroup_subsys *subsys, |
333 | const struct cftype cft[], | 342 | const struct cftype cft[], |
@@ -419,7 +428,8 @@ struct cgroup_iter { | |||
419 | struct list_head *task; | 428 | struct list_head *task; |
420 | }; | 429 | }; |
421 | 430 | ||
422 | /* To iterate across the tasks in a cgroup: | 431 | /* |
432 | * To iterate across the tasks in a cgroup: | ||
423 | * | 433 | * |
424 | * 1) call cgroup_iter_start to intialize an iterator | 434 | * 1) call cgroup_iter_start to intialize an iterator |
425 | * | 435 | * |
@@ -428,9 +438,10 @@ struct cgroup_iter { | |||
428 | * | 438 | * |
429 | * 3) call cgroup_iter_end() to destroy the iterator. | 439 | * 3) call cgroup_iter_end() to destroy the iterator. |
430 | * | 440 | * |
431 | * Or, call cgroup_scan_tasks() to iterate through every task in a cpuset. | 441 | * Or, call cgroup_scan_tasks() to iterate through every task in a |
432 | * - cgroup_scan_tasks() holds the css_set_lock when calling the test_task() | 442 | * cgroup - cgroup_scan_tasks() holds the css_set_lock when calling |
433 | * callback, but not while calling the process_task() callback. | 443 | * the test_task() callback, but not while calling the process_task() |
444 | * callback. | ||
434 | */ | 445 | */ |
435 | void cgroup_iter_start(struct cgroup *cgrp, struct cgroup_iter *it); | 446 | void cgroup_iter_start(struct cgroup *cgrp, struct cgroup_iter *it); |
436 | struct task_struct *cgroup_iter_next(struct cgroup *cgrp, | 447 | struct task_struct *cgroup_iter_next(struct cgroup *cgrp, |