Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Li Zefan and committed by
Linus Torvalds
00c2e63c 80a6a2cf

+14 -26
-5
include/linux/freezer.h
··· 44 44 return !(p->flags & PF_FREEZER_NOSIG); 45 45 } 46 46 47 - /* 48 - * Wake up a frozen process 49 - */ 50 - extern int __thaw_process(struct task_struct *p); 51 - 52 47 /* Takes and releases task alloc lock using task_lock() */ 53 48 extern int thaw_process(struct task_struct *p); 54 49
+4 -11
kernel/cgroup_freezer.c
··· 275 275 return num_cant_freeze_now ? -EBUSY : 0; 276 276 } 277 277 278 - static int unfreeze_cgroup(struct cgroup *cgroup, struct freezer *freezer) 278 + static void unfreeze_cgroup(struct cgroup *cgroup, struct freezer *freezer) 279 279 { 280 280 struct cgroup_iter it; 281 281 struct task_struct *task; 282 282 283 283 cgroup_iter_start(cgroup, &it); 284 284 while ((task = cgroup_iter_next(cgroup, &it))) { 285 - int do_wake; 286 - 287 - task_lock(task); 288 - do_wake = __thaw_process(task); 289 - task_unlock(task); 290 - if (do_wake) 291 - wake_up_process(task); 285 + thaw_process(task); 292 286 } 293 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 299 292 static int freezer_change_state(struct cgroup *cgroup, ··· 313 320 } 314 321 /* state == FREEZING and goal_state == THAWED, so unfreeze */ 315 322 case CGROUP_FROZEN: 316 - retval = unfreeze_cgroup(cgroup, freezer); 323 + unfreeze_cgroup(cgroup, freezer); 317 324 break; 318 325 default: 319 326 break;
+10 -10
kernel/freezer.c
··· 121 121 } 122 122 } 123 123 124 - /* 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 - */ 133 - int __thaw_process(struct task_struct *p) 124 + static int __thaw_process(struct task_struct *p) 134 125 { 135 126 if (frozen(p)) { 136 127 p->flags &= ~PF_FROZEN; ··· 131 140 return 0; 132 141 } 133 142 143 + /* 144 + * Wake up a frozen process 145 + * 146 + * task_lock() is needed to prevent the race with refrigerator() which may 147 + * occur if the freezing of tasks fails. Namely, without the lock, if the 148 + * freezing of tasks failed, thaw_tasks() might have run before a task in 149 + * refrigerator() could call frozen_process(), in which case the task would be 150 + * frozen and no one would thaw it. 151 + */ 134 152 int thaw_process(struct task_struct *p) 135 153 { 136 154 task_lock(p);