提交 00c2e63c 编写于 作者: L Li Zefan 提交者: Linus Torvalds

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: NLi Zefan <lizf@cn.fujitsu.com>
Cc: Cedric Le Goater <clg@fr.ibm.com>
Acked-by: NMatt Helsley <matthltc@us.ibm.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 80a6a2cf
...@@ -44,11 +44,6 @@ static inline bool should_send_signal(struct task_struct *p) ...@@ -44,11 +44,6 @@ static inline bool should_send_signal(struct task_struct *p)
return !(p->flags & PF_FREEZER_NOSIG); return !(p->flags & PF_FREEZER_NOSIG);
} }
/*
* Wake up a frozen process
*/
extern int __thaw_process(struct task_struct *p);
/* Takes and releases task alloc lock using task_lock() */ /* Takes and releases task alloc lock using task_lock() */
extern int thaw_process(struct task_struct *p); extern int thaw_process(struct task_struct *p);
......
...@@ -275,25 +275,18 @@ static int try_to_freeze_cgroup(struct cgroup *cgroup, struct freezer *freezer) ...@@ -275,25 +275,18 @@ static int try_to_freeze_cgroup(struct cgroup *cgroup, struct freezer *freezer)
return num_cant_freeze_now ? -EBUSY : 0; return num_cant_freeze_now ? -EBUSY : 0;
} }
static int unfreeze_cgroup(struct cgroup *cgroup, struct freezer *freezer) static void unfreeze_cgroup(struct cgroup *cgroup, struct freezer *freezer)
{ {
struct cgroup_iter it; struct cgroup_iter it;
struct task_struct *task; struct task_struct *task;
cgroup_iter_start(cgroup, &it); cgroup_iter_start(cgroup, &it);
while ((task = cgroup_iter_next(cgroup, &it))) { while ((task = cgroup_iter_next(cgroup, &it))) {
int do_wake; thaw_process(task);
task_lock(task);
do_wake = __thaw_process(task);
task_unlock(task);
if (do_wake)
wake_up_process(task);
} }
cgroup_iter_end(cgroup, &it); cgroup_iter_end(cgroup, &it);
freezer->state = CGROUP_THAWED;
return 0; freezer->state = CGROUP_THAWED;
} }
static int freezer_change_state(struct cgroup *cgroup, static int freezer_change_state(struct cgroup *cgroup,
...@@ -320,7 +313,7 @@ static int freezer_change_state(struct cgroup *cgroup, ...@@ -320,7 +313,7 @@ static int freezer_change_state(struct cgroup *cgroup,
} }
/* state == FREEZING and goal_state == THAWED, so unfreeze */ /* state == FREEZING and goal_state == THAWED, so unfreeze */
case CGROUP_FROZEN: case CGROUP_FROZEN:
retval = unfreeze_cgroup(cgroup, freezer); unfreeze_cgroup(cgroup, freezer);
break; break;
default: default:
break; break;
......
...@@ -121,16 +121,7 @@ void cancel_freezing(struct task_struct *p) ...@@ -121,16 +121,7 @@ void cancel_freezing(struct task_struct *p)
} }
} }
/* static int __thaw_process(struct task_struct *p)
* Wake up a frozen process
*
* task_lock() is needed to prevent the race with refrigerator() which may
* occur if the freezing of tasks fails. Namely, without the lock, if the
* freezing of tasks failed, thaw_tasks() might have run before a task in
* refrigerator() could call frozen_process(), in which case the task would be
* frozen and no one would thaw it.
*/
int __thaw_process(struct task_struct *p)
{ {
if (frozen(p)) { if (frozen(p)) {
p->flags &= ~PF_FROZEN; p->flags &= ~PF_FROZEN;
...@@ -140,6 +131,15 @@ int __thaw_process(struct task_struct *p) ...@@ -140,6 +131,15 @@ int __thaw_process(struct task_struct *p)
return 0; return 0;
} }
/*
* Wake up a frozen process
*
* task_lock() is needed to prevent the race with refrigerator() which may
* occur if the freezing of tasks fails. Namely, without the lock, if the
* freezing of tasks failed, thaw_tasks() might have run before a task in
* refrigerator() could call frozen_process(), in which case the task would be
* frozen and no one would thaw it.
*/
int thaw_process(struct task_struct *p) int thaw_process(struct task_struct *p)
{ {
task_lock(p); task_lock(p);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册