Commit 81dcf33c authored by Matt Helsley's avatar Matt Helsley Committed by Linus Torvalds

container freezer: make freezer state names less generic

Rename cgroup freezer states to be less generic to avoid any name
collisions while also better describing what each state is.
Signed-off-by: default avatarMatt Helsley <matthltc@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 957a4eea
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
#include <linux/seq_file.h> #include <linux/seq_file.h>
enum freezer_state { enum freezer_state {
STATE_RUNNING = 0, CGROUP_THAWED = 0,
STATE_FREEZING, CGROUP_FREEZING,
STATE_FROZEN, CGROUP_FROZEN,
}; };
struct freezer { struct freezer {
...@@ -57,7 +57,7 @@ int cgroup_frozen(struct task_struct *task) ...@@ -57,7 +57,7 @@ int cgroup_frozen(struct task_struct *task)
state = freezer->state; state = freezer->state;
task_unlock(task); task_unlock(task);
return state == STATE_FROZEN; return state == CGROUP_FROZEN;
} }
/* /*
...@@ -65,7 +65,7 @@ int cgroup_frozen(struct task_struct *task) ...@@ -65,7 +65,7 @@ int cgroup_frozen(struct task_struct *task)
* CGROUP_LOCAL_BUFFER_SIZE * CGROUP_LOCAL_BUFFER_SIZE
*/ */
static const char *freezer_state_strs[] = { static const char *freezer_state_strs[] = {
"RUNNING", "THAWED",
"FREEZING", "FREEZING",
"FROZEN", "FROZEN",
}; };
...@@ -75,10 +75,10 @@ static const char *freezer_state_strs[] = { ...@@ -75,10 +75,10 @@ static const char *freezer_state_strs[] = {
* Transitions are caused by userspace writes to the freezer.state file. * Transitions are caused by userspace writes to the freezer.state file.
* The values in parenthesis are state labels. The rest are edge labels. * The values in parenthesis are state labels. The rest are edge labels.
* *
* (RUNNING) --FROZEN--> (FREEZING) --FROZEN--> (FROZEN) * (THAWED) --FROZEN--> (FREEZING) --FROZEN--> (FROZEN)
* ^ ^ | | * ^ ^ | |
* | \_______RUNNING_______/ | * | \_______THAWED_______/ |
* \_____________________________RUNNING___________/ * \__________________________THAWED____________/
*/ */
struct cgroup_subsys freezer_subsys; struct cgroup_subsys freezer_subsys;
...@@ -135,7 +135,7 @@ static struct cgroup_subsys_state *freezer_create(struct cgroup_subsys *ss, ...@@ -135,7 +135,7 @@ static struct cgroup_subsys_state *freezer_create(struct cgroup_subsys *ss,
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
spin_lock_init(&freezer->lock); spin_lock_init(&freezer->lock);
freezer->state = STATE_RUNNING; freezer->state = CGROUP_THAWED;
return &freezer->css; return &freezer->css;
} }
...@@ -170,13 +170,13 @@ static int freezer_can_attach(struct cgroup_subsys *ss, ...@@ -170,13 +170,13 @@ static int freezer_can_attach(struct cgroup_subsys *ss,
return -EBUSY; return -EBUSY;
freezer = cgroup_freezer(new_cgroup); freezer = cgroup_freezer(new_cgroup);
if (freezer->state == STATE_FROZEN) if (freezer->state == CGROUP_FROZEN)
return -EBUSY; return -EBUSY;
retval = 0; retval = 0;
task_lock(task); task_lock(task);
freezer = task_freezer(task); freezer = task_freezer(task);
if (freezer->state == STATE_FROZEN) if (freezer->state == CGROUP_FROZEN)
retval = -EBUSY; retval = -EBUSY;
task_unlock(task); task_unlock(task);
return retval; return retval;
...@@ -190,10 +190,10 @@ static void freezer_fork(struct cgroup_subsys *ss, struct task_struct *task) ...@@ -190,10 +190,10 @@ static void freezer_fork(struct cgroup_subsys *ss, struct task_struct *task)
freezer = task_freezer(task); freezer = task_freezer(task);
task_unlock(task); task_unlock(task);
BUG_ON(freezer->state == STATE_FROZEN); BUG_ON(freezer->state == CGROUP_FROZEN);
spin_lock_irq(&freezer->lock); spin_lock_irq(&freezer->lock);
/* Locking avoids race with FREEZING -> RUNNING transitions. */ /* Locking avoids race with FREEZING -> THAWED transitions. */
if (freezer->state == STATE_FREEZING) if (freezer->state == CGROUP_FREEZING)
freeze_task(task, true); freeze_task(task, true);
spin_unlock_irq(&freezer->lock); spin_unlock_irq(&freezer->lock);
} }
...@@ -221,7 +221,7 @@ static void check_if_frozen(struct cgroup *cgroup, ...@@ -221,7 +221,7 @@ static void check_if_frozen(struct cgroup *cgroup,
* tasks. * tasks.
*/ */
if (nfrozen == ntotal) if (nfrozen == ntotal)
freezer->state = STATE_FROZEN; freezer->state = CGROUP_FROZEN;
cgroup_iter_end(cgroup, &it); cgroup_iter_end(cgroup, &it);
} }
...@@ -237,7 +237,7 @@ static int freezer_read(struct cgroup *cgroup, struct cftype *cft, ...@@ -237,7 +237,7 @@ static int freezer_read(struct cgroup *cgroup, struct cftype *cft,
freezer = cgroup_freezer(cgroup); freezer = cgroup_freezer(cgroup);
spin_lock_irq(&freezer->lock); spin_lock_irq(&freezer->lock);
state = freezer->state; state = freezer->state;
if (state == STATE_FREEZING) { if (state == CGROUP_FREEZING) {
/* We change from FREEZING to FROZEN lazily if the cgroup was /* We change from FREEZING to FROZEN lazily if the cgroup was
* only partially frozen when we exitted write. */ * only partially frozen when we exitted write. */
check_if_frozen(cgroup, freezer); check_if_frozen(cgroup, freezer);
...@@ -257,7 +257,7 @@ static int try_to_freeze_cgroup(struct cgroup *cgroup, struct freezer *freezer) ...@@ -257,7 +257,7 @@ static int try_to_freeze_cgroup(struct cgroup *cgroup, struct freezer *freezer)
struct task_struct *task; struct task_struct *task;
unsigned int num_cant_freeze_now = 0; unsigned int num_cant_freeze_now = 0;
freezer->state = STATE_FREEZING; freezer->state = CGROUP_FREEZING;
cgroup_iter_start(cgroup, &it); cgroup_iter_start(cgroup, &it);
while ((task = cgroup_iter_next(cgroup, &it))) { while ((task = cgroup_iter_next(cgroup, &it))) {
if (!freeze_task(task, true)) if (!freeze_task(task, true))
...@@ -288,7 +288,7 @@ static int unfreeze_cgroup(struct cgroup *cgroup, struct freezer *freezer) ...@@ -288,7 +288,7 @@ static int unfreeze_cgroup(struct cgroup *cgroup, struct freezer *freezer)
wake_up_process(task); wake_up_process(task);
} }
cgroup_iter_end(cgroup, &it); cgroup_iter_end(cgroup, &it);
freezer->state = STATE_RUNNING; freezer->state = CGROUP_THAWED;
return 0; return 0;
} }
...@@ -305,18 +305,18 @@ static int freezer_change_state(struct cgroup *cgroup, ...@@ -305,18 +305,18 @@ static int freezer_change_state(struct cgroup *cgroup,
if (goal_state == freezer->state) if (goal_state == freezer->state)
goto out; goto out;
switch (freezer->state) { switch (freezer->state) {
case STATE_RUNNING: case CGROUP_THAWED:
retval = try_to_freeze_cgroup(cgroup, freezer); retval = try_to_freeze_cgroup(cgroup, freezer);
break; break;
case STATE_FREEZING: case CGROUP_FREEZING:
if (goal_state == STATE_FROZEN) { if (goal_state == CGROUP_FROZEN) {
/* Userspace is retrying after /* Userspace is retrying after
* "/bin/echo FROZEN > freezer.state" returned -EBUSY */ * "/bin/echo FROZEN > freezer.state" returned -EBUSY */
retval = try_to_freeze_cgroup(cgroup, freezer); retval = try_to_freeze_cgroup(cgroup, freezer);
break; break;
} }
/* state == FREEZING and goal_state == RUNNING, so unfreeze */ /* state == FREEZING and goal_state == THAWED, so unfreeze */
case STATE_FROZEN: case CGROUP_FROZEN:
retval = unfreeze_cgroup(cgroup, freezer); retval = unfreeze_cgroup(cgroup, freezer);
break; break;
default: default:
...@@ -335,10 +335,10 @@ static int freezer_write(struct cgroup *cgroup, ...@@ -335,10 +335,10 @@ static int freezer_write(struct cgroup *cgroup,
int retval; int retval;
enum freezer_state goal_state; enum freezer_state goal_state;
if (strcmp(buffer, freezer_state_strs[STATE_RUNNING]) == 0) if (strcmp(buffer, freezer_state_strs[CGROUP_THAWED]) == 0)
goal_state = STATE_RUNNING; goal_state = CGROUP_THAWED;
else if (strcmp(buffer, freezer_state_strs[STATE_FROZEN]) == 0) else if (strcmp(buffer, freezer_state_strs[CGROUP_FROZEN]) == 0)
goal_state = STATE_FROZEN; goal_state = CGROUP_FROZEN;
else else
return -EIO; return -EIO;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment