aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2008-10-29 17:00:53 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-30 14:38:45 -0400
commit00c2e63c31d0f431952ff2a671c5c6997dd4f8b2 (patch)
tree2277b400fef79e55c13d7045aa63d5bed9ad5883 /kernel
parent80a6a2cf3bebcf20285cf05373b9c5ec96816577 (diff)
freezer_cg: use thaw_process() in unfreeze_cgroup()
Don't duplicate the implementation of thaw_process(). [akpm@linux-foundation.org: make __thaw_process() static] Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Cc: Cedric Le Goater <clg@fr.ibm.com> Acked-by: Matt Helsley <matthltc@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cgroup_freezer.c15
-rw-r--r--kernel/freezer.c20
2 files changed, 14 insertions, 21 deletions
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);