aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup_freezer.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-08-08 20:11:24 -0400
committerTejun Heo <tj@kernel.org>2013-08-08 20:11:24 -0400
commit182446d087906de40e514573a92a97b203695f71 (patch)
tree6aee96219c82d0a64b9d389c50666c1ce0ec27ee /kernel/cgroup_freezer.c
parent67f4c36f83455b253445b2cb28ac9a2c4f85d99a (diff)
cgroup: pass around cgroup_subsys_state instead of cgroup in file methods
cgroup is currently in the process of transitioning to using struct cgroup_subsys_state * as the primary handle instead of struct cgroup. Please see the previous commit which converts the subsystem methods for rationale. This patch converts all cftype file operations to take @css instead of @cgroup. cftypes for the cgroup core files don't have their subsytem pointer set. These will automatically use the dummy_css added by the previous patch and can be converted the same way. Most subsystem conversions are straight forwards but there are some interesting ones. * freezer: update_if_frozen() is also converted to take @css instead of @cgroup for consistency. This will make the code look simpler too once iterators are converted to use css. * memory/vmpressure: mem_cgroup_from_css() needs to be exported to vmpressure while mem_cgroup_from_cont() can be made static. Updated accordingly. * cpu: cgroup_tg() doesn't have any user left. Removed. * cpuacct: cgroup_ca() doesn't have any user left. Removed. * hugetlb: hugetlb_cgroup_form_cgroup() doesn't have any user left. Removed. * net_cls: cgrp_cls_state() doesn't have any user left. 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> Acked-by: Daniel Wagner <daniel.wagner@bmw-carit.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ingo Molnar <mingo@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> Cc: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/cgroup_freezer.c')
-rw-r--r--kernel/cgroup_freezer.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c
index f03a85719c3c..19613ba51444 100644
--- a/kernel/cgroup_freezer.c
+++ b/kernel/cgroup_freezer.c
@@ -245,7 +245,7 @@ out:
245 245
246/** 246/**
247 * update_if_frozen - update whether a cgroup finished freezing 247 * update_if_frozen - update whether a cgroup finished freezing
248 * @cgroup: cgroup of interest 248 * @css: css of interest
249 * 249 *
250 * Once FREEZING is initiated, transition to FROZEN is lazily updated by 250 * Once FREEZING is initiated, transition to FROZEN is lazily updated by
251 * calling this function. If the current state is FREEZING but not FROZEN, 251 * calling this function. If the current state is FREEZING but not FROZEN,
@@ -256,12 +256,12 @@ out:
256 * update_if_frozen() on all descendants prior to invoking this function. 256 * update_if_frozen() on all descendants prior to invoking this function.
257 * 257 *
258 * Task states and freezer state might disagree while tasks are being 258 * Task states and freezer state might disagree while tasks are being
259 * migrated into or out of @cgroup, so we can't verify task states against 259 * migrated into or out of @css, so we can't verify task states against
260 * @freezer state here. See freezer_attach() for details. 260 * @freezer state here. See freezer_attach() for details.
261 */ 261 */
262static void update_if_frozen(struct cgroup *cgroup) 262static void update_if_frozen(struct cgroup_subsys_state *css)
263{ 263{
264 struct freezer *freezer = cgroup_freezer(cgroup); 264 struct freezer *freezer = css_freezer(css);
265 struct cgroup *pos; 265 struct cgroup *pos;
266 struct cgroup_iter it; 266 struct cgroup_iter it;
267 struct task_struct *task; 267 struct task_struct *task;
@@ -275,7 +275,7 @@ static void update_if_frozen(struct cgroup *cgroup)
275 goto out_unlock; 275 goto out_unlock;
276 276
277 /* are all (live) children frozen? */ 277 /* are all (live) children frozen? */
278 cgroup_for_each_child(pos, cgroup) { 278 cgroup_for_each_child(pos, css->cgroup) {
279 struct freezer *child = cgroup_freezer(pos); 279 struct freezer *child = cgroup_freezer(pos);
280 280
281 if ((child->state & CGROUP_FREEZER_ONLINE) && 281 if ((child->state & CGROUP_FREEZER_ONLINE) &&
@@ -284,9 +284,9 @@ static void update_if_frozen(struct cgroup *cgroup)
284 } 284 }
285 285
286 /* are all tasks frozen? */ 286 /* are all tasks frozen? */
287 cgroup_iter_start(cgroup, &it); 287 cgroup_iter_start(css->cgroup, &it);
288 288
289 while ((task = cgroup_iter_next(cgroup, &it))) { 289 while ((task = cgroup_iter_next(css->cgroup, &it))) {
290 if (freezing(task)) { 290 if (freezing(task)) {
291 /* 291 /*
292 * freezer_should_skip() indicates that the task 292 * freezer_should_skip() indicates that the task
@@ -301,12 +301,12 @@ static void update_if_frozen(struct cgroup *cgroup)
301 301
302 freezer->state |= CGROUP_FROZEN; 302 freezer->state |= CGROUP_FROZEN;
303out_iter_end: 303out_iter_end:
304 cgroup_iter_end(cgroup, &it); 304 cgroup_iter_end(css->cgroup, &it);
305out_unlock: 305out_unlock:
306 spin_unlock_irq(&freezer->lock); 306 spin_unlock_irq(&freezer->lock);
307} 307}
308 308
309static int freezer_read(struct cgroup *cgroup, struct cftype *cft, 309static int freezer_read(struct cgroup_subsys_state *css, struct cftype *cft,
310 struct seq_file *m) 310 struct seq_file *m)
311{ 311{
312 struct cgroup *pos; 312 struct cgroup *pos;
@@ -314,13 +314,13 @@ static int freezer_read(struct cgroup *cgroup, struct cftype *cft,
314 rcu_read_lock(); 314 rcu_read_lock();
315 315
316 /* update states bottom-up */ 316 /* update states bottom-up */
317 cgroup_for_each_descendant_post(pos, cgroup) 317 cgroup_for_each_descendant_post(pos, css->cgroup)
318 update_if_frozen(pos); 318 update_if_frozen(cgroup_css(pos, freezer_subsys_id));
319 update_if_frozen(cgroup); 319 update_if_frozen(css);
320 320
321 rcu_read_unlock(); 321 rcu_read_unlock();
322 322
323 seq_puts(m, freezer_state_strs(cgroup_freezer(cgroup)->state)); 323 seq_puts(m, freezer_state_strs(css_freezer(css)->state));
324 seq_putc(m, '\n'); 324 seq_putc(m, '\n');
325 return 0; 325 return 0;
326} 326}
@@ -426,7 +426,7 @@ static void freezer_change_state(struct freezer *freezer, bool freeze)
426 rcu_read_unlock(); 426 rcu_read_unlock();
427} 427}
428 428
429static int freezer_write(struct cgroup *cgroup, struct cftype *cft, 429static int freezer_write(struct cgroup_subsys_state *css, struct cftype *cft,
430 const char *buffer) 430 const char *buffer)
431{ 431{
432 bool freeze; 432 bool freeze;
@@ -438,20 +438,22 @@ static int freezer_write(struct cgroup *cgroup, struct cftype *cft,
438 else 438 else
439 return -EINVAL; 439 return -EINVAL;
440 440
441 freezer_change_state(cgroup_freezer(cgroup), freeze); 441 freezer_change_state(css_freezer(css), freeze);
442 return 0; 442 return 0;
443} 443}
444 444
445static u64 freezer_self_freezing_read(struct cgroup *cgroup, struct cftype *cft) 445static u64 freezer_self_freezing_read(struct cgroup_subsys_state *css,
446 struct cftype *cft)
446{ 447{
447 struct freezer *freezer = cgroup_freezer(cgroup); 448 struct freezer *freezer = css_freezer(css);
448 449
449 return (bool)(freezer->state & CGROUP_FREEZING_SELF); 450 return (bool)(freezer->state & CGROUP_FREEZING_SELF);
450} 451}
451 452
452static u64 freezer_parent_freezing_read(struct cgroup *cgroup, struct cftype *cft) 453static u64 freezer_parent_freezing_read(struct cgroup_subsys_state *css,
454 struct cftype *cft)
453{ 455{
454 struct freezer *freezer = cgroup_freezer(cgroup); 456 struct freezer *freezer = css_freezer(css);
455 457
456 return (bool)(freezer->state & CGROUP_FREEZING_PARENT); 458 return (bool)(freezer->state & CGROUP_FREEZING_PARENT);
457} 459}