aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power/process.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/power/process.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/power/process.c')
-rw-r--r--kernel/power/process.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/kernel/power/process.c b/kernel/power/process.c
index e59676f5811d..ce643838a00c 100644
--- a/kernel/power/process.c
+++ b/kernel/power/process.c
@@ -91,11 +91,6 @@ static int try_to_freeze_tasks(bool sig_only)
91 elapsed_csecs = elapsed_csecs64; 91 elapsed_csecs = elapsed_csecs64;
92 92
93 if (todo) { 93 if (todo) {
94 /* This does not unfreeze processes that are already frozen
95 * (we have slightly ugly calling convention in that respect,
96 * and caller must call thaw_processes() if something fails),
97 * but it cleans up leftover PF_FREEZE requests.
98 */
99 printk("\n"); 94 printk("\n");
100 printk(KERN_ERR "Freezing of tasks %s after %d.%02d seconds " 95 printk(KERN_ERR "Freezing of tasks %s after %d.%02d seconds "
101 "(%d tasks refusing to freeze, wq_busy=%d):\n", 96 "(%d tasks refusing to freeze, wq_busy=%d):\n",
@@ -103,14 +98,11 @@ static int try_to_freeze_tasks(bool sig_only)
103 elapsed_csecs / 100, elapsed_csecs % 100, 98 elapsed_csecs / 100, elapsed_csecs % 100,
104 todo - wq_busy, wq_busy); 99 todo - wq_busy, wq_busy);
105 100
106 thaw_workqueues();
107
108 read_lock(&tasklist_lock); 101 read_lock(&tasklist_lock);
109 do_each_thread(g, p) { 102 do_each_thread(g, p) {
110 if (!wakeup && !freezer_should_skip(p) && 103 if (!wakeup && !freezer_should_skip(p) &&
111 freezing(p) && !frozen(p)) 104 freezing(p) && !frozen(p))
112 sched_show_task(p); 105 sched_show_task(p);
113 cancel_freezing(p);
114 } while_each_thread(g, p); 106 } while_each_thread(g, p);
115 read_unlock(&tasklist_lock); 107 read_unlock(&tasklist_lock);
116 } else { 108 } else {
@@ -123,6 +115,8 @@ static int try_to_freeze_tasks(bool sig_only)
123 115
124/** 116/**
125 * freeze_processes - Signal user space processes to enter the refrigerator. 117 * freeze_processes - Signal user space processes to enter the refrigerator.
118 *
119 * On success, returns 0. On failure, -errno and system is fully thawed.
126 */ 120 */
127int freeze_processes(void) 121int freeze_processes(void)
128{ 122{
@@ -137,11 +131,15 @@ int freeze_processes(void)
137 printk("\n"); 131 printk("\n");
138 BUG_ON(in_atomic()); 132 BUG_ON(in_atomic());
139 133
134 if (error)
135 thaw_processes();
140 return error; 136 return error;
141} 137}
142 138
143/** 139/**
144 * freeze_kernel_threads - Make freezable kernel threads go to the refrigerator. 140 * freeze_kernel_threads - Make freezable kernel threads go to the refrigerator.
141 *
142 * On success, returns 0. On failure, -errno and system is fully thawed.
145 */ 143 */
146int freeze_kernel_threads(void) 144int freeze_kernel_threads(void)
147{ 145{
@@ -155,6 +153,8 @@ int freeze_kernel_threads(void)
155 printk("\n"); 153 printk("\n");
156 BUG_ON(in_atomic()); 154 BUG_ON(in_atomic());
157 155
156 if (error)
157 thaw_processes();
158 return error; 158 return error;
159} 159}
160 160