diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2012-03-28 17:30:21 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2012-03-28 17:30:21 -0400 |
commit | 1e73203cd1157a03facc41ffb54050f5b28e55bd (patch) | |
tree | 12781ea69aa706291949bb1a10141a8a043e09d9 /kernel/power | |
parent | 7b5179ac14dbad945647ac9e76bbbf14ed9e0dbe (diff) |
PM / Sleep: Move disabling of usermode helpers to the freezer
The core suspend/hibernation code calls usermodehelper_disable() to
avoid race conditions between the freezer and the starting of
usermode helpers and each code path has to do that on its own.
However, it is always called right before freeze_processes()
and usermodehelper_enable() is always called right after
thaw_processes(). For this reason, to avoid code duplication and
to make the connection between usermodehelper_disable() and the
freezer more visible, make freeze_processes() call it and remove the
direct usermodehelper_disable() and usermodehelper_enable() calls
from all suspend/hibernation code paths.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: stable@vger.kernel.org
Diffstat (limited to 'kernel/power')
-rw-r--r-- | kernel/power/hibernate.c | 11 | ||||
-rw-r--r-- | kernel/power/process.c | 7 | ||||
-rw-r--r-- | kernel/power/suspend.c | 7 | ||||
-rw-r--r-- | kernel/power/user.c | 10 |
4 files changed, 8 insertions, 27 deletions
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index 639ff6e4ae9e..e09dfbfeecee 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/string.h> | 16 | #include <linux/string.h> |
17 | #include <linux/device.h> | 17 | #include <linux/device.h> |
18 | #include <linux/async.h> | 18 | #include <linux/async.h> |
19 | #include <linux/kmod.h> | ||
20 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
21 | #include <linux/fs.h> | 20 | #include <linux/fs.h> |
22 | #include <linux/mount.h> | 21 | #include <linux/mount.h> |
@@ -620,10 +619,6 @@ int hibernate(void) | |||
620 | sys_sync(); | 619 | sys_sync(); |
621 | printk("done.\n"); | 620 | printk("done.\n"); |
622 | 621 | ||
623 | error = usermodehelper_disable(); | ||
624 | if (error) | ||
625 | goto Exit; | ||
626 | |||
627 | error = freeze_processes(); | 622 | error = freeze_processes(); |
628 | if (error) | 623 | if (error) |
629 | goto Free_bitmaps; | 624 | goto Free_bitmaps; |
@@ -660,7 +655,6 @@ int hibernate(void) | |||
660 | freezer_test_done = false; | 655 | freezer_test_done = false; |
661 | 656 | ||
662 | Free_bitmaps: | 657 | Free_bitmaps: |
663 | usermodehelper_enable(); | ||
664 | free_basic_memory_bitmaps(); | 658 | free_basic_memory_bitmaps(); |
665 | Exit: | 659 | Exit: |
666 | pm_notifier_call_chain(PM_POST_HIBERNATION); | 660 | pm_notifier_call_chain(PM_POST_HIBERNATION); |
@@ -780,10 +774,6 @@ static int software_resume(void) | |||
780 | if (error) | 774 | if (error) |
781 | goto close_finish; | 775 | goto close_finish; |
782 | 776 | ||
783 | error = usermodehelper_disable(); | ||
784 | if (error) | ||
785 | goto close_finish; | ||
786 | |||
787 | pr_debug("PM: Preparing processes for restore.\n"); | 777 | pr_debug("PM: Preparing processes for restore.\n"); |
788 | error = freeze_processes(); | 778 | error = freeze_processes(); |
789 | if (error) { | 779 | if (error) { |
@@ -802,7 +792,6 @@ static int software_resume(void) | |||
802 | swsusp_free(); | 792 | swsusp_free(); |
803 | thaw_processes(); | 793 | thaw_processes(); |
804 | Done: | 794 | Done: |
805 | usermodehelper_enable(); | ||
806 | free_basic_memory_bitmaps(); | 795 | free_basic_memory_bitmaps(); |
807 | Finish: | 796 | Finish: |
808 | pm_notifier_call_chain(PM_POST_RESTORE); | 797 | pm_notifier_call_chain(PM_POST_RESTORE); |
diff --git a/kernel/power/process.c b/kernel/power/process.c index 0d2aeb226108..56eaac7e88ab 100644 --- a/kernel/power/process.c +++ b/kernel/power/process.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/freezer.h> | 16 | #include <linux/freezer.h> |
17 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
18 | #include <linux/workqueue.h> | 18 | #include <linux/workqueue.h> |
19 | #include <linux/kmod.h> | ||
19 | 20 | ||
20 | /* | 21 | /* |
21 | * Timeout for stopping processes | 22 | * Timeout for stopping processes |
@@ -122,6 +123,10 @@ int freeze_processes(void) | |||
122 | { | 123 | { |
123 | int error; | 124 | int error; |
124 | 125 | ||
126 | error = usermodehelper_disable(); | ||
127 | if (error) | ||
128 | return error; | ||
129 | |||
125 | if (!pm_freezing) | 130 | if (!pm_freezing) |
126 | atomic_inc(&system_freezing_cnt); | 131 | atomic_inc(&system_freezing_cnt); |
127 | 132 | ||
@@ -187,6 +192,8 @@ void thaw_processes(void) | |||
187 | } while_each_thread(g, p); | 192 | } while_each_thread(g, p); |
188 | read_unlock(&tasklist_lock); | 193 | read_unlock(&tasklist_lock); |
189 | 194 | ||
195 | usermodehelper_enable(); | ||
196 | |||
190 | schedule(); | 197 | schedule(); |
191 | printk("done.\n"); | 198 | printk("done.\n"); |
192 | } | 199 | } |
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 88e5c967370d..396d262b8fd0 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/delay.h> | 12 | #include <linux/delay.h> |
13 | #include <linux/errno.h> | 13 | #include <linux/errno.h> |
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/kmod.h> | ||
16 | #include <linux/console.h> | 15 | #include <linux/console.h> |
17 | #include <linux/cpu.h> | 16 | #include <linux/cpu.h> |
18 | #include <linux/syscalls.h> | 17 | #include <linux/syscalls.h> |
@@ -102,17 +101,12 @@ static int suspend_prepare(void) | |||
102 | if (error) | 101 | if (error) |
103 | goto Finish; | 102 | goto Finish; |
104 | 103 | ||
105 | error = usermodehelper_disable(); | ||
106 | if (error) | ||
107 | goto Finish; | ||
108 | |||
109 | error = suspend_freeze_processes(); | 104 | error = suspend_freeze_processes(); |
110 | if (!error) | 105 | if (!error) |
111 | return 0; | 106 | return 0; |
112 | 107 | ||
113 | suspend_stats.failed_freeze++; | 108 | suspend_stats.failed_freeze++; |
114 | dpm_save_failed_step(SUSPEND_FREEZE); | 109 | dpm_save_failed_step(SUSPEND_FREEZE); |
115 | usermodehelper_enable(); | ||
116 | Finish: | 110 | Finish: |
117 | pm_notifier_call_chain(PM_POST_SUSPEND); | 111 | pm_notifier_call_chain(PM_POST_SUSPEND); |
118 | pm_restore_console(); | 112 | pm_restore_console(); |
@@ -259,7 +253,6 @@ int suspend_devices_and_enter(suspend_state_t state) | |||
259 | static void suspend_finish(void) | 253 | static void suspend_finish(void) |
260 | { | 254 | { |
261 | suspend_thaw_processes(); | 255 | suspend_thaw_processes(); |
262 | usermodehelper_enable(); | ||
263 | pm_notifier_call_chain(PM_POST_SUSPEND); | 256 | pm_notifier_call_chain(PM_POST_SUSPEND); |
264 | pm_restore_console(); | 257 | pm_restore_console(); |
265 | } | 258 | } |
diff --git a/kernel/power/user.c b/kernel/power/user.c index 33c4329205af..91b0fd021a95 100644 --- a/kernel/power/user.c +++ b/kernel/power/user.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/suspend.h> | 12 | #include <linux/suspend.h> |
13 | #include <linux/syscalls.h> | 13 | #include <linux/syscalls.h> |
14 | #include <linux/reboot.h> | 14 | #include <linux/reboot.h> |
15 | #include <linux/kmod.h> | ||
16 | #include <linux/string.h> | 15 | #include <linux/string.h> |
17 | #include <linux/device.h> | 16 | #include <linux/device.h> |
18 | #include <linux/miscdevice.h> | 17 | #include <linux/miscdevice.h> |
@@ -222,14 +221,8 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd, | |||
222 | sys_sync(); | 221 | sys_sync(); |
223 | printk("done.\n"); | 222 | printk("done.\n"); |
224 | 223 | ||
225 | error = usermodehelper_disable(); | ||
226 | if (error) | ||
227 | break; | ||
228 | |||
229 | error = freeze_processes(); | 224 | error = freeze_processes(); |
230 | if (error) | 225 | if (!error) |
231 | usermodehelper_enable(); | ||
232 | else | ||
233 | data->frozen = 1; | 226 | data->frozen = 1; |
234 | break; | 227 | break; |
235 | 228 | ||
@@ -238,7 +231,6 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd, | |||
238 | break; | 231 | break; |
239 | pm_restore_gfp_mask(); | 232 | pm_restore_gfp_mask(); |
240 | thaw_processes(); | 233 | thaw_processes(); |
241 | usermodehelper_enable(); | ||
242 | data->frozen = 0; | 234 | data->frozen = 0; |
243 | break; | 235 | break; |
244 | 236 | ||