aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/freezer.h5
-rw-r--r--kernel/cgroup_freezer.c15
-rw-r--r--kernel/freezer.c20
3 files changed, 14 insertions, 26 deletions
diff --git a/include/linux/freezer.h b/include/linux/freezer.h
index 8f225339eee9..5a361f85cfec 100644
--- a/include/linux/freezer.h
+++ b/include/linux/freezer.h
@@ -44,11 +44,6 @@ static inline bool should_send_signal(struct task_struct *p)
44 return !(p->flags & PF_FREEZER_NOSIG); 44 return !(p->flags & PF_FREEZER_NOSIG);
45} 45}
46 46
47/*
48 * Wake up a frozen process
49 */
50extern int __thaw_process(struct task_struct *p);
51
52/* Takes and releases task alloc lock using task_lock() */ 47/* Takes and releases task alloc lock using task_lock() */
53extern int thaw_process(struct task_struct *p); 48extern int thaw_process(struct task_struct *p);
54 49
diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c
index e9c856a265c9..5e6d26b66e88 100644
--- a/kernel/cgroup_freezer.c
+++ b/kernel/cgroup_freezer.c
@@ -275,25 +275,18 @@ static int try_to_freeze_cgroup(struct cgroup *cgroup, struct freezer *freezer)
275 return num_cant_freeze_now ? -EBUSY : 0; 275 return num_cant_freeze_now ? -EBUSY : 0;
276} 276}
277 277
278static int unfreeze_cgroup(struct cgroup *cgroup, struct freezer *freezer) 278static void unfreeze_cgroup(struct cgroup *cgroup, struct freezer *freezer)
279{ 279{
280 struct cgroup_iter it; 280 struct cgroup_iter it;
281 struct task_struct *task; 281 struct task_struct *task;
282 282
283 cgroup_iter_start(cgroup, &it); 283 cgroup_iter_start(cgroup, &it);
284 while ((task = cgroup_iter_next(cgroup, &it))) { 284 while ((task = cgroup_iter_next(cgroup, &it))) {
285 int do_wake; 285 thaw_process(task);
286
287 task_lock(task);
288 do_wake = __thaw_process(task);
289 task_unlock(task);
290 if (do_wake)
291 wake_up_process(task);
292 } 286 }
293 cgroup_iter_end(cgroup, &it); 287 cgroup_iter_end(cgroup, &it);
294 freezer->state = CGROUP_THAWED;
295 288
296 return 0; 289 freezer->state = CGROUP_THAWED;
297} 290}
298 291
299static int freezer_change_state(struct cgroup *cgroup, 292static int freezer_change_state(struct cgroup *cgroup,
@@ -320,7 +313,7 @@ static int freezer_change_state(struct cgroup *cgroup,
320 } 313 }
321 /* state == FREEZING and goal_state == THAWED, so unfreeze */ 314 /* state == FREEZING and goal_state == THAWED, so unfreeze */
322 case CGROUP_FROZEN: 315 case CGROUP_FROZEN:
323 retval = unfreeze_cgroup(cgroup, freezer); 316 unfreeze_cgroup(cgroup, freezer);
324 break; 317 break;
325 default: 318 default:
326 break; 319 break;
diff --git a/kernel/freezer.c b/kernel/freezer.c
index ba6248b323ef..2f4936cf7083 100644
--- a/kernel/freezer.c
+++ b/kernel/freezer.c
@@ -121,16 +121,7 @@ void cancel_freezing(struct task_struct *p)
121 } 121 }
122} 122}
123 123
124/* 124static int __thaw_process(struct task_struct *p)
125 * Wake up a frozen process
126 *
127 * task_lock() is needed to prevent the race with refrigerator() which may
128 * occur if the freezing of tasks fails. Namely, without the lock, if the
129 * freezing of tasks failed, thaw_tasks() might have run before a task in
130 * refrigerator() could call frozen_process(), in which case the task would be
131 * frozen and no one would thaw it.
132 */
133int __thaw_process(struct task_struct *p)
134{ 125{
135 if (frozen(p)) { 126 if (frozen(p)) {
136 p->flags &= ~PF_FROZEN; 127 p->flags &= ~PF_FROZEN;
@@ -140,6 +131,15 @@ int __thaw_process(struct task_struct *p)
140 return 0; 131 return 0;
141} 132}
142 133
134/*
135 * Wake up a frozen process
136 *
137 * task_lock() is needed to prevent the race with refrigerator() which may
138 * occur if the freezing of tasks fails. Namely, without the lock, if the
139 * freezing of tasks failed, thaw_tasks() might have run before a task in
140 * refrigerator() could call frozen_process(), in which case the task would be
141 * frozen and no one would thaw it.
142 */
143int thaw_process(struct task_struct *p) 143int thaw_process(struct task_struct *p)
144{ 144{
145 task_lock(p); 145 task_lock(p);