diff options
-rw-r--r-- | kernel/cgroup_freezer.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c index df884022fbd9..6e4280d77429 100644 --- a/kernel/cgroup_freezer.c +++ b/kernel/cgroup_freezer.c | |||
@@ -22,9 +22,9 @@ | |||
22 | #include <linux/seq_file.h> | 22 | #include <linux/seq_file.h> |
23 | 23 | ||
24 | enum freezer_state { | 24 | enum freezer_state { |
25 | STATE_RUNNING = 0, | 25 | CGROUP_THAWED = 0, |
26 | STATE_FREEZING, | 26 | CGROUP_FREEZING, |
27 | STATE_FROZEN, | 27 | CGROUP_FROZEN, |
28 | }; | 28 | }; |
29 | 29 | ||
30 | struct freezer { | 30 | struct freezer { |
@@ -57,7 +57,7 @@ int cgroup_frozen(struct task_struct *task) | |||
57 | state = freezer->state; | 57 | state = freezer->state; |
58 | task_unlock(task); | 58 | task_unlock(task); |
59 | 59 | ||
60 | return state == STATE_FROZEN; | 60 | return state == CGROUP_FROZEN; |
61 | } | 61 | } |
62 | 62 | ||
63 | /* | 63 | /* |
@@ -65,7 +65,7 @@ int cgroup_frozen(struct task_struct *task) | |||
65 | * CGROUP_LOCAL_BUFFER_SIZE | 65 | * CGROUP_LOCAL_BUFFER_SIZE |
66 | */ | 66 | */ |
67 | static const char *freezer_state_strs[] = { | 67 | static const char *freezer_state_strs[] = { |
68 | "RUNNING", | 68 | "THAWED", |
69 | "FREEZING", | 69 | "FREEZING", |
70 | "FROZEN", | 70 | "FROZEN", |
71 | }; | 71 | }; |
@@ -75,10 +75,10 @@ static const char *freezer_state_strs[] = { | |||
75 | * Transitions are caused by userspace writes to the freezer.state file. | 75 | * Transitions are caused by userspace writes to the freezer.state file. |
76 | * The values in parenthesis are state labels. The rest are edge labels. | 76 | * The values in parenthesis are state labels. The rest are edge labels. |
77 | * | 77 | * |
78 | * (RUNNING) --FROZEN--> (FREEZING) --FROZEN--> (FROZEN) | 78 | * (THAWED) --FROZEN--> (FREEZING) --FROZEN--> (FROZEN) |
79 | * ^ ^ | | | 79 | * ^ ^ | | |
80 | * | \_______RUNNING_______/ | | 80 | * | \_______THAWED_______/ | |
81 | * \_____________________________RUNNING___________/ | 81 | * \__________________________THAWED____________/ |
82 | */ | 82 | */ |
83 | 83 | ||
84 | struct cgroup_subsys freezer_subsys; | 84 | struct cgroup_subsys freezer_subsys; |
@@ -135,7 +135,7 @@ static struct cgroup_subsys_state *freezer_create(struct cgroup_subsys *ss, | |||
135 | return ERR_PTR(-ENOMEM); | 135 | return ERR_PTR(-ENOMEM); |
136 | 136 | ||
137 | spin_lock_init(&freezer->lock); | 137 | spin_lock_init(&freezer->lock); |
138 | freezer->state = STATE_RUNNING; | 138 | freezer->state = CGROUP_THAWED; |
139 | return &freezer->css; | 139 | return &freezer->css; |
140 | } | 140 | } |
141 | 141 | ||
@@ -170,13 +170,13 @@ static int freezer_can_attach(struct cgroup_subsys *ss, | |||
170 | return -EBUSY; | 170 | return -EBUSY; |
171 | 171 | ||
172 | freezer = cgroup_freezer(new_cgroup); | 172 | freezer = cgroup_freezer(new_cgroup); |
173 | if (freezer->state == STATE_FROZEN) | 173 | if (freezer->state == CGROUP_FROZEN) |
174 | return -EBUSY; | 174 | return -EBUSY; |
175 | 175 | ||
176 | retval = 0; | 176 | retval = 0; |
177 | task_lock(task); | 177 | task_lock(task); |
178 | freezer = task_freezer(task); | 178 | freezer = task_freezer(task); |
179 | if (freezer->state == STATE_FROZEN) | 179 | if (freezer->state == CGROUP_FROZEN) |
180 | retval = -EBUSY; | 180 | retval = -EBUSY; |
181 | task_unlock(task); | 181 | task_unlock(task); |
182 | return retval; | 182 | return retval; |
@@ -190,10 +190,10 @@ static void freezer_fork(struct cgroup_subsys *ss, struct task_struct *task) | |||
190 | freezer = task_freezer(task); | 190 | freezer = task_freezer(task); |
191 | task_unlock(task); | 191 | task_unlock(task); |
192 | 192 | ||
193 | BUG_ON(freezer->state == STATE_FROZEN); | 193 | BUG_ON(freezer->state == CGROUP_FROZEN); |
194 | spin_lock_irq(&freezer->lock); | 194 | spin_lock_irq(&freezer->lock); |
195 | /* Locking avoids race with FREEZING -> RUNNING transitions. */ | 195 | /* Locking avoids race with FREEZING -> THAWED transitions. */ |
196 | if (freezer->state == STATE_FREEZING) | 196 | if (freezer->state == CGROUP_FREEZING) |
197 | freeze_task(task, true); | 197 | freeze_task(task, true); |
198 | spin_unlock_irq(&freezer->lock); | 198 | spin_unlock_irq(&freezer->lock); |
199 | } | 199 | } |
@@ -221,7 +221,7 @@ static void check_if_frozen(struct cgroup *cgroup, | |||
221 | * tasks. | 221 | * tasks. |
222 | */ | 222 | */ |
223 | if (nfrozen == ntotal) | 223 | if (nfrozen == ntotal) |
224 | freezer->state = STATE_FROZEN; | 224 | freezer->state = CGROUP_FROZEN; |
225 | cgroup_iter_end(cgroup, &it); | 225 | cgroup_iter_end(cgroup, &it); |
226 | } | 226 | } |
227 | 227 | ||
@@ -237,7 +237,7 @@ static int freezer_read(struct cgroup *cgroup, struct cftype *cft, | |||
237 | freezer = cgroup_freezer(cgroup); | 237 | freezer = cgroup_freezer(cgroup); |
238 | spin_lock_irq(&freezer->lock); | 238 | spin_lock_irq(&freezer->lock); |
239 | state = freezer->state; | 239 | state = freezer->state; |
240 | if (state == STATE_FREEZING) { | 240 | if (state == CGROUP_FREEZING) { |
241 | /* We change from FREEZING to FROZEN lazily if the cgroup was | 241 | /* We change from FREEZING to FROZEN lazily if the cgroup was |
242 | * only partially frozen when we exitted write. */ | 242 | * only partially frozen when we exitted write. */ |
243 | check_if_frozen(cgroup, freezer); | 243 | check_if_frozen(cgroup, freezer); |
@@ -257,7 +257,7 @@ static int try_to_freeze_cgroup(struct cgroup *cgroup, struct freezer *freezer) | |||
257 | struct task_struct *task; | 257 | struct task_struct *task; |
258 | unsigned int num_cant_freeze_now = 0; | 258 | unsigned int num_cant_freeze_now = 0; |
259 | 259 | ||
260 | freezer->state = STATE_FREEZING; | 260 | freezer->state = CGROUP_FREEZING; |
261 | cgroup_iter_start(cgroup, &it); | 261 | cgroup_iter_start(cgroup, &it); |
262 | while ((task = cgroup_iter_next(cgroup, &it))) { | 262 | while ((task = cgroup_iter_next(cgroup, &it))) { |
263 | if (!freeze_task(task, true)) | 263 | if (!freeze_task(task, true)) |
@@ -288,7 +288,7 @@ static int unfreeze_cgroup(struct cgroup *cgroup, struct freezer *freezer) | |||
288 | wake_up_process(task); | 288 | wake_up_process(task); |
289 | } | 289 | } |
290 | cgroup_iter_end(cgroup, &it); | 290 | cgroup_iter_end(cgroup, &it); |
291 | freezer->state = STATE_RUNNING; | 291 | freezer->state = CGROUP_THAWED; |
292 | 292 | ||
293 | return 0; | 293 | return 0; |
294 | } | 294 | } |
@@ -305,18 +305,18 @@ static int freezer_change_state(struct cgroup *cgroup, | |||
305 | if (goal_state == freezer->state) | 305 | if (goal_state == freezer->state) |
306 | goto out; | 306 | goto out; |
307 | switch (freezer->state) { | 307 | switch (freezer->state) { |
308 | case STATE_RUNNING: | 308 | case CGROUP_THAWED: |
309 | retval = try_to_freeze_cgroup(cgroup, freezer); | 309 | retval = try_to_freeze_cgroup(cgroup, freezer); |
310 | break; | 310 | break; |
311 | case STATE_FREEZING: | 311 | case CGROUP_FREEZING: |
312 | if (goal_state == STATE_FROZEN) { | 312 | if (goal_state == CGROUP_FROZEN) { |
313 | /* Userspace is retrying after | 313 | /* Userspace is retrying after |
314 | * "/bin/echo FROZEN > freezer.state" returned -EBUSY */ | 314 | * "/bin/echo FROZEN > freezer.state" returned -EBUSY */ |
315 | retval = try_to_freeze_cgroup(cgroup, freezer); | 315 | retval = try_to_freeze_cgroup(cgroup, freezer); |
316 | break; | 316 | break; |
317 | } | 317 | } |
318 | /* state == FREEZING and goal_state == RUNNING, so unfreeze */ | 318 | /* state == FREEZING and goal_state == THAWED, so unfreeze */ |
319 | case STATE_FROZEN: | 319 | case CGROUP_FROZEN: |
320 | retval = unfreeze_cgroup(cgroup, freezer); | 320 | retval = unfreeze_cgroup(cgroup, freezer); |
321 | break; | 321 | break; |
322 | default: | 322 | default: |
@@ -335,10 +335,10 @@ static int freezer_write(struct cgroup *cgroup, | |||
335 | int retval; | 335 | int retval; |
336 | enum freezer_state goal_state; | 336 | enum freezer_state goal_state; |
337 | 337 | ||
338 | if (strcmp(buffer, freezer_state_strs[STATE_RUNNING]) == 0) | 338 | if (strcmp(buffer, freezer_state_strs[CGROUP_THAWED]) == 0) |
339 | goal_state = STATE_RUNNING; | 339 | goal_state = CGROUP_THAWED; |
340 | else if (strcmp(buffer, freezer_state_strs[STATE_FROZEN]) == 0) | 340 | else if (strcmp(buffer, freezer_state_strs[CGROUP_FROZEN]) == 0) |
341 | goal_state = STATE_FROZEN; | 341 | goal_state = CGROUP_FROZEN; |
342 | else | 342 | else |
343 | return -EIO; | 343 | return -EIO; |
344 | 344 | ||