Power management fix for 3.3-rc2

Fix for a hibernate (s2disk) regression introduced during the 3.2
 merge window that causes s2disk to trigger BUG_ON() in
 freeze_workqueues_begin() if there is not enough swap space to save
 the image.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.18 (GNU/Linux)
 
 iQIcBAABAgAGBQJPJak+AAoJEKhOf7ml8uNsS1oP/3z1em/LJvuwhXAf/cg11kAW
 LxNXK8FKKI55fE/T556oNyWHL6Bew5YtrGuLQdNQLMlWS//lVTBayUVbp9z1z+5Q
 VHPWoZfwbkT7kf0Wvuf/b4NGXRLg3gHcq+xoXJCu9zr7JV4lrHmZnm/f2N1usoAW
 kTb+w078fKT702tvBYkLJDYXkPW+cd+yqTu6H2aPO6vk3m0kq/XSeLtSs1S8ExBo
 Z0koDNJbi2S5S7RYooGwIrC0jgdl60pUcM9pI1x79uDLIz8rSHFX/VdrlVK6M70l
 +3PdccnUmKo92qaSnv1DSYVpGaWSI6KQjy1I12mpbzAgJagZNxc7NtzguhUWzhLe
 W7/rJaTupg8UozDfq0wFpekIjO8v+E8ZbtUzE/EISZ/+espZIUAQpuPCq6Suf7W1
 lraYhHvReXUX/BPKkRTf+9WTMvZbLElfF6DTSOZZ4+fztP+BD1M+1a0uy4BIQ8n7
 Gwz5FDvlyFR+YTEewmWSVhdZlBY8hiJw4fgMwimca8m9DCrFeT+uiXjL0BQsrdYB
 aN1PWiAZQNrPbW6LAoUu9rLzebyuXCd2/RAuR+nIDvxIdBMqV6yz9hkEUMGwftTP
 PvQIBSRxS6t8bLXrVTToGE90sTx1dBs+EorPMq4dPoXGG2VEEbLo+xGgM1lfKFU2
 eIbgOdJxarAph9zI4X30
 =m9yn
 -----END PGP SIGNATURE-----

Merge tag 'pm-fix-for-3.3-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Power management fix for 3.3-rc2

Fix for a hibernate (s2disk) regression introduced during the 3.2
merge window that causes s2disk to trigger BUG_ON() in
freeze_workqueues_begin() if there is not enough swap space to save
the image.

* tag 'pm-fix-for-3.3-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  PM / Hibernate: Fix s2disk regression related to freezing workqueues
This commit is contained in:
Linus Torvalds 2012-01-30 08:33:40 -08:00
commit a51f67a4b4
3 changed files with 30 additions and 0 deletions

View file

@ -39,6 +39,7 @@ extern bool __refrigerator(bool check_kthr_stop);
extern int freeze_processes(void);
extern int freeze_kernel_threads(void);
extern void thaw_processes(void);
extern void thaw_kernel_threads(void);
static inline bool try_to_freeze(void)
{
@ -174,6 +175,7 @@ static inline bool __refrigerator(bool check_kthr_stop) { return false; }
static inline int freeze_processes(void) { return -ENOSYS; }
static inline int freeze_kernel_threads(void) { return -ENOSYS; }
static inline void thaw_processes(void) {}
static inline void thaw_kernel_threads(void) {}
static inline bool try_to_freeze(void) { return false; }

View file

@ -188,3 +188,22 @@ void thaw_processes(void)
printk("done.\n");
}
void thaw_kernel_threads(void)
{
struct task_struct *g, *p;
pm_nosig_freezing = false;
printk("Restarting kernel threads ... ");
thaw_workqueues();
read_lock(&tasklist_lock);
do_each_thread(g, p) {
if (p->flags & (PF_KTHREAD | PF_WQ_WORKER))
__thaw_task(p);
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
schedule();
printk("done.\n");
}

View file

@ -274,6 +274,15 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
swsusp_free();
memset(&data->handle, 0, sizeof(struct snapshot_handle));
data->ready = 0;
/*
* It is necessary to thaw kernel threads here, because
* SNAPSHOT_CREATE_IMAGE may be invoked directly after
* SNAPSHOT_FREE. In that case, if kernel threads were not
* thawed, the preallocation of memory carried out by
* hibernation_snapshot() might run into problems (i.e. it
* might fail or even deadlock).
*/
thaw_kernel_threads();
break;
case SNAPSHOT_PREF_IMAGE_SIZE: