mm/pm: force GFP_NOIO during suspend/hibernation and resume
There are quite a few GFP_KERNEL memory allocations made during suspend/hibernation and resume that may cause the system to hang, because the I/O operations they depend on cannot be completed due to the underlying devices being suspended. Avoid this problem by clearing the __GFP_IO and __GFP_FS bits in gfp_allowed_mask before suspend/hibernation and restoring the original values of these bits in gfp_allowed_mask durig the subsequent resume. [akpm@linux-foundation.org: fix CONFIG_PM=n linkage] Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Reported-by: Maxim Levitsky <maximlevitsky@gmail.com> Cc: Sebastian Ott <sebott@linux.vnet.ibm.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
ad2bd7e0e9
commit
452aa6999e
@@ -323,6 +323,7 @@ static int create_image(int platform_mode)
|
||||
int hibernation_snapshot(int platform_mode)
|
||||
{
|
||||
int error;
|
||||
gfp_t saved_mask;
|
||||
|
||||
error = platform_begin(platform_mode);
|
||||
if (error)
|
||||
@@ -334,6 +335,7 @@ int hibernation_snapshot(int platform_mode)
|
||||
goto Close;
|
||||
|
||||
suspend_console();
|
||||
saved_mask = clear_gfp_allowed_mask(GFP_IOFS);
|
||||
error = dpm_suspend_start(PMSG_FREEZE);
|
||||
if (error)
|
||||
goto Recover_platform;
|
||||
@@ -351,6 +353,7 @@ int hibernation_snapshot(int platform_mode)
|
||||
|
||||
dpm_resume_end(in_suspend ?
|
||||
(error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE);
|
||||
set_gfp_allowed_mask(saved_mask);
|
||||
resume_console();
|
||||
Close:
|
||||
platform_end(platform_mode);
|
||||
@@ -445,14 +448,17 @@ static int resume_target_kernel(bool platform_mode)
|
||||
int hibernation_restore(int platform_mode)
|
||||
{
|
||||
int error;
|
||||
gfp_t saved_mask;
|
||||
|
||||
pm_prepare_console();
|
||||
suspend_console();
|
||||
saved_mask = clear_gfp_allowed_mask(GFP_IOFS);
|
||||
error = dpm_suspend_start(PMSG_QUIESCE);
|
||||
if (!error) {
|
||||
error = resume_target_kernel(platform_mode);
|
||||
dpm_resume_end(PMSG_RECOVER);
|
||||
}
|
||||
set_gfp_allowed_mask(saved_mask);
|
||||
resume_console();
|
||||
pm_restore_console();
|
||||
return error;
|
||||
@@ -466,6 +472,7 @@ int hibernation_restore(int platform_mode)
|
||||
int hibernation_platform_enter(void)
|
||||
{
|
||||
int error;
|
||||
gfp_t saved_mask;
|
||||
|
||||
if (!hibernation_ops)
|
||||
return -ENOSYS;
|
||||
@@ -481,6 +488,7 @@ int hibernation_platform_enter(void)
|
||||
|
||||
entering_platform_hibernation = true;
|
||||
suspend_console();
|
||||
saved_mask = clear_gfp_allowed_mask(GFP_IOFS);
|
||||
error = dpm_suspend_start(PMSG_HIBERNATE);
|
||||
if (error) {
|
||||
if (hibernation_ops->recover)
|
||||
@@ -518,6 +526,7 @@ int hibernation_platform_enter(void)
|
||||
Resume_devices:
|
||||
entering_platform_hibernation = false;
|
||||
dpm_resume_end(PMSG_RESTORE);
|
||||
set_gfp_allowed_mask(saved_mask);
|
||||
resume_console();
|
||||
|
||||
Close:
|
||||
|
Reference in New Issue
Block a user