aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/freezer.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2011-11-21 15:32:24 -0500
committerTejun Heo <tj@kernel.org>2011-11-21 15:32:24 -0500
commit03afed8bc296fa70186ba832c1126228bb992465 (patch)
tree96d0a6a9bffdcfc678d31f21caa88e43693bde94 /kernel/freezer.c
parent376fede80e74d98b49d1ba9ac18f23c9fd026ddd (diff)
freezer: clean up freeze_processes() failure path
freeze_processes() failure path is rather messy. Freezing is canceled for workqueues and tasks which aren't frozen yet but frozen tasks are left alone and should be thawed by the caller and of course some callers (xen and kexec) didn't do it. This patch updates __thaw_task() to handle cancelation correctly and makes freeze_processes() and freeze_kernel_threads() call thaw_processes() on failure instead so that the system is fully thawed on failure. Unnecessary [suspend_]thaw_processes() calls are removed from kernel/power/hibernate.c, suspend.c and user.c. While at it, restructure error checking if clause in suspend_prepare() to be less weird. -v2: Srivatsa spotted missing removal of suspend_thaw_processes() in suspend_prepare() and error in commit message. Updated. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Diffstat (limited to 'kernel/freezer.c')
-rw-r--r--kernel/freezer.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/kernel/freezer.c b/kernel/freezer.c
index b8b562124ba9..11e32d419dec 100644
--- a/kernel/freezer.c
+++ b/kernel/freezer.c
@@ -129,21 +129,6 @@ out_unlock:
129 return ret; 129 return ret;
130} 130}
131 131
132void cancel_freezing(struct task_struct *p)
133{
134 unsigned long flags;
135
136 spin_lock_irqsave(&freezer_lock, flags);
137 if (freezing(p)) {
138 pr_debug(" clean up: %s\n", p->comm);
139 clear_freeze_flag(p);
140 spin_lock(&p->sighand->siglock);
141 recalc_sigpending_and_wake(p);
142 spin_unlock(&p->sighand->siglock);
143 }
144 spin_unlock_irqrestore(&freezer_lock, flags);
145}
146
147void __thaw_task(struct task_struct *p) 132void __thaw_task(struct task_struct *p)
148{ 133{
149 unsigned long flags; 134 unsigned long flags;
@@ -153,10 +138,18 @@ void __thaw_task(struct task_struct *p)
153 * be visible to @p as waking up implies wmb. Waking up inside 138 * be visible to @p as waking up implies wmb. Waking up inside
154 * freezer_lock also prevents wakeups from leaking outside 139 * freezer_lock also prevents wakeups from leaking outside
155 * refrigerator. 140 * refrigerator.
141 *
142 * If !FROZEN, @p hasn't reached refrigerator, recalc sigpending to
143 * avoid leaving dangling TIF_SIGPENDING behind.
156 */ 144 */
157 spin_lock_irqsave(&freezer_lock, flags); 145 spin_lock_irqsave(&freezer_lock, flags);
158 clear_freeze_flag(p); 146 clear_freeze_flag(p);
159 if (frozen(p)) 147 if (frozen(p)) {
160 wake_up_process(p); 148 wake_up_process(p);
149 } else {
150 spin_lock(&p->sighand->siglock);
151 recalc_sigpending_and_wake(p);
152 spin_unlock(&p->sighand->siglock);
153 }
161 spin_unlock_irqrestore(&freezer_lock, flags); 154 spin_unlock_irqrestore(&freezer_lock, flags);
162} 155}