Skip to content

Commit

Permalink
freezer_cg: simplify freezer_change_state()
Browse files Browse the repository at this point in the history
Just call unfreeze_cgroup() if goal_state == THAWED, and call
try_to_freeze_cgroup() if goal_state == FROZEN.

No behavior has been changed.

Signed-off-by: Li Zefan <[email protected]>
Acked-by: Cedric Le Goater <[email protected]>
Acked-by: Matt Helsley <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Li Zefan authored and torvalds committed Oct 30, 2008
1 parent 00c2e63 commit 51308ee
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions kernel/cgroup_freezer.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,27 +296,22 @@ static int freezer_change_state(struct cgroup *cgroup,
int retval = 0;

freezer = cgroup_freezer(cgroup);

spin_lock_irq(&freezer->lock);

update_freezer_state(cgroup, freezer);
if (goal_state == freezer->state)
goto out;
switch (freezer->state) {

switch (goal_state) {
case CGROUP_THAWED:
retval = try_to_freeze_cgroup(cgroup, freezer);
unfreeze_cgroup(cgroup, freezer);
break;
case CGROUP_FREEZING:
if (goal_state == CGROUP_FROZEN) {
/* Userspace is retrying after
* "/bin/echo FROZEN > freezer.state" returned -EBUSY */
retval = try_to_freeze_cgroup(cgroup, freezer);
break;
}
/* state == FREEZING and goal_state == THAWED, so unfreeze */
case CGROUP_FROZEN:
unfreeze_cgroup(cgroup, freezer);
retval = try_to_freeze_cgroup(cgroup, freezer);
break;
default:
break;
BUG();
}
out:
spin_unlock_irq(&freezer->lock);
Expand Down

0 comments on commit 51308ee

Please sign in to comment.