aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup_freezer.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-08-08 20:11:25 -0400
committerTejun Heo <tj@kernel.org>2013-08-08 20:11:25 -0400
commit492eb21b98f88e411a8bb43d6edcd7d7022add10 (patch)
treeda06df9485fd607762fdec06169f7d9f601e3cf6 /kernel/cgroup_freezer.c
parentf48e3924dca268c677c4e338e5d91ad9e6fe6b9e (diff)
cgroup: make hierarchy iterators deal with cgroup_subsys_state instead of cgroup
cgroup is currently in the process of transitioning to using css (cgroup_subsys_state) as the primary handle instead of cgroup in subsystem API. For hierarchy iterators, this is beneficial because * In most cases, css is the only thing subsystems care about anyway. * On the planned unified hierarchy, iterations for different subsystems will need to skip over different subtrees of the hierarchy depending on which subsystems are enabled on each cgroup. Passing around css makes it unnecessary to explicitly specify the subsystem in question as css is intersection between cgroup and subsystem * For the planned unified hierarchy, css's would need to be created and destroyed dynamically independent from cgroup hierarchy. Having cgroup core manage css iteration makes enforcing deref rules a lot easier. Most subsystem conversions are straight-forward. Noteworthy changes are * blkio: cgroup_to_blkcg() is no longer used. Removed. * freezer: cgroup_freezer() is no longer used. Removed. * devices: cgroup_to_devcgroup() is no longer used. Removed. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com> Acked-by: Michal Hocko <mhocko@suse.cz> Acked-by: Vivek Goyal <vgoyal@redhat.com> Acked-by: Aristeu Rozanski <aris@redhat.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Balbir Singh <bsingharora@gmail.com> Cc: Matt Helsley <matthltc@us.ibm.com> Cc: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'kernel/cgroup_freezer.c')
-rw-r--r--kernel/cgroup_freezer.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c
index 19613ba51444..98ca48d9ceb4 100644
--- a/kernel/cgroup_freezer.c
+++ b/kernel/cgroup_freezer.c
@@ -50,11 +50,6 @@ static inline struct freezer *css_freezer(struct cgroup_subsys_state *css)
50 return css ? container_of(css, struct freezer, css) : NULL; 50 return css ? container_of(css, struct freezer, css) : NULL;
51} 51}
52 52
53static inline struct freezer *cgroup_freezer(struct cgroup *cgroup)
54{
55 return css_freezer(cgroup_css(cgroup, freezer_subsys_id));
56}
57
58static inline struct freezer *task_freezer(struct task_struct *task) 53static inline struct freezer *task_freezer(struct task_struct *task)
59{ 54{
60 return css_freezer(task_css(task, freezer_subsys_id)); 55 return css_freezer(task_css(task, freezer_subsys_id));
@@ -120,7 +115,7 @@ static int freezer_css_online(struct cgroup_subsys_state *css)
120 /* 115 /*
121 * The following double locking and freezing state inheritance 116 * The following double locking and freezing state inheritance
122 * guarantee that @cgroup can never escape ancestors' freezing 117 * guarantee that @cgroup can never escape ancestors' freezing
123 * states. See cgroup_for_each_descendant_pre() for details. 118 * states. See css_for_each_descendant_pre() for details.
124 */ 119 */
125 if (parent) 120 if (parent)
126 spin_lock_irq(&parent->lock); 121 spin_lock_irq(&parent->lock);
@@ -262,7 +257,7 @@ out:
262static void update_if_frozen(struct cgroup_subsys_state *css) 257static void update_if_frozen(struct cgroup_subsys_state *css)
263{ 258{
264 struct freezer *freezer = css_freezer(css); 259 struct freezer *freezer = css_freezer(css);
265 struct cgroup *pos; 260 struct cgroup_subsys_state *pos;
266 struct cgroup_iter it; 261 struct cgroup_iter it;
267 struct task_struct *task; 262 struct task_struct *task;
268 263
@@ -275,8 +270,8 @@ static void update_if_frozen(struct cgroup_subsys_state *css)
275 goto out_unlock; 270 goto out_unlock;
276 271
277 /* are all (live) children frozen? */ 272 /* are all (live) children frozen? */
278 cgroup_for_each_child(pos, css->cgroup) { 273 css_for_each_child(pos, css) {
279 struct freezer *child = cgroup_freezer(pos); 274 struct freezer *child = css_freezer(pos);
280 275
281 if ((child->state & CGROUP_FREEZER_ONLINE) && 276 if ((child->state & CGROUP_FREEZER_ONLINE) &&
282 !(child->state & CGROUP_FROZEN)) 277 !(child->state & CGROUP_FROZEN))
@@ -309,13 +304,13 @@ out_unlock:
309static int freezer_read(struct cgroup_subsys_state *css, struct cftype *cft, 304static int freezer_read(struct cgroup_subsys_state *css, struct cftype *cft,
310 struct seq_file *m) 305 struct seq_file *m)
311{ 306{
312 struct cgroup *pos; 307 struct cgroup_subsys_state *pos;
313 308
314 rcu_read_lock(); 309 rcu_read_lock();
315 310
316 /* update states bottom-up */ 311 /* update states bottom-up */
317 cgroup_for_each_descendant_post(pos, css->cgroup) 312 css_for_each_descendant_post(pos, css)
318 update_if_frozen(cgroup_css(pos, freezer_subsys_id)); 313 update_if_frozen(pos);
319 update_if_frozen(css); 314 update_if_frozen(css);
320 315
321 rcu_read_unlock(); 316 rcu_read_unlock();
@@ -396,7 +391,7 @@ static void freezer_apply_state(struct freezer *freezer, bool freeze,
396 */ 391 */
397static void freezer_change_state(struct freezer *freezer, bool freeze) 392static void freezer_change_state(struct freezer *freezer, bool freeze)
398{ 393{
399 struct cgroup *pos; 394 struct cgroup_subsys_state *pos;
400 395
401 /* update @freezer */ 396 /* update @freezer */
402 spin_lock_irq(&freezer->lock); 397 spin_lock_irq(&freezer->lock);
@@ -409,8 +404,8 @@ static void freezer_change_state(struct freezer *freezer, bool freeze)
409 * CGROUP_FREEZING_PARENT. 404 * CGROUP_FREEZING_PARENT.
410 */ 405 */
411 rcu_read_lock(); 406 rcu_read_lock();
412 cgroup_for_each_descendant_pre(pos, freezer->css.cgroup) { 407 css_for_each_descendant_pre(pos, &freezer->css) {
413 struct freezer *pos_f = cgroup_freezer(pos); 408 struct freezer *pos_f = css_freezer(pos);
414 struct freezer *parent = parent_freezer(pos_f); 409 struct freezer *parent = parent_freezer(pos_f);
415 410
416 /* 411 /*