diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2010-03-05 16:42:13 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-06 14:26:26 -0500 |
commit | 452aa6999e6703ffbddd7f6ea124d3968915f3e3 (patch) | |
tree | 48e375fdb60920675f68b444b462903ad8bb6940 /kernel/power/hibernate.c | |
parent | ad2bd7e0e9647cd48593a6b3a2be07dc2c2d28ed (diff) |
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>
Diffstat (limited to 'kernel/power/hibernate.c')
-rw-r--r-- | kernel/power/hibernate.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index bbfe472d7524..da5288ec2392 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c | |||
@@ -323,6 +323,7 @@ static int create_image(int platform_mode) | |||
323 | int hibernation_snapshot(int platform_mode) | 323 | int hibernation_snapshot(int platform_mode) |
324 | { | 324 | { |
325 | int error; | 325 | int error; |
326 | gfp_t saved_mask; | ||
326 | 327 | ||
327 | error = platform_begin(platform_mode); | 328 | error = platform_begin(platform_mode); |
328 | if (error) | 329 | if (error) |
@@ -334,6 +335,7 @@ int hibernation_snapshot(int platform_mode) | |||
334 | goto Close; | 335 | goto Close; |
335 | 336 | ||
336 | suspend_console(); | 337 | suspend_console(); |
338 | saved_mask = clear_gfp_allowed_mask(GFP_IOFS); | ||
337 | error = dpm_suspend_start(PMSG_FREEZE); | 339 | error = dpm_suspend_start(PMSG_FREEZE); |
338 | if (error) | 340 | if (error) |
339 | goto Recover_platform; | 341 | goto Recover_platform; |
@@ -351,6 +353,7 @@ int hibernation_snapshot(int platform_mode) | |||
351 | 353 | ||
352 | dpm_resume_end(in_suspend ? | 354 | dpm_resume_end(in_suspend ? |
353 | (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE); | 355 | (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE); |
356 | set_gfp_allowed_mask(saved_mask); | ||
354 | resume_console(); | 357 | resume_console(); |
355 | Close: | 358 | Close: |
356 | platform_end(platform_mode); | 359 | platform_end(platform_mode); |
@@ -445,14 +448,17 @@ static int resume_target_kernel(bool platform_mode) | |||
445 | int hibernation_restore(int platform_mode) | 448 | int hibernation_restore(int platform_mode) |
446 | { | 449 | { |
447 | int error; | 450 | int error; |
451 | gfp_t saved_mask; | ||
448 | 452 | ||
449 | pm_prepare_console(); | 453 | pm_prepare_console(); |
450 | suspend_console(); | 454 | suspend_console(); |
455 | saved_mask = clear_gfp_allowed_mask(GFP_IOFS); | ||
451 | error = dpm_suspend_start(PMSG_QUIESCE); | 456 | error = dpm_suspend_start(PMSG_QUIESCE); |
452 | if (!error) { | 457 | if (!error) { |
453 | error = resume_target_kernel(platform_mode); | 458 | error = resume_target_kernel(platform_mode); |
454 | dpm_resume_end(PMSG_RECOVER); | 459 | dpm_resume_end(PMSG_RECOVER); |
455 | } | 460 | } |
461 | set_gfp_allowed_mask(saved_mask); | ||
456 | resume_console(); | 462 | resume_console(); |
457 | pm_restore_console(); | 463 | pm_restore_console(); |
458 | return error; | 464 | return error; |
@@ -466,6 +472,7 @@ int hibernation_restore(int platform_mode) | |||
466 | int hibernation_platform_enter(void) | 472 | int hibernation_platform_enter(void) |
467 | { | 473 | { |
468 | int error; | 474 | int error; |
475 | gfp_t saved_mask; | ||
469 | 476 | ||
470 | if (!hibernation_ops) | 477 | if (!hibernation_ops) |
471 | return -ENOSYS; | 478 | return -ENOSYS; |
@@ -481,6 +488,7 @@ int hibernation_platform_enter(void) | |||
481 | 488 | ||
482 | entering_platform_hibernation = true; | 489 | entering_platform_hibernation = true; |
483 | suspend_console(); | 490 | suspend_console(); |
491 | saved_mask = clear_gfp_allowed_mask(GFP_IOFS); | ||
484 | error = dpm_suspend_start(PMSG_HIBERNATE); | 492 | error = dpm_suspend_start(PMSG_HIBERNATE); |
485 | if (error) { | 493 | if (error) { |
486 | if (hibernation_ops->recover) | 494 | if (hibernation_ops->recover) |
@@ -518,6 +526,7 @@ int hibernation_platform_enter(void) | |||
518 | Resume_devices: | 526 | Resume_devices: |
519 | entering_platform_hibernation = false; | 527 | entering_platform_hibernation = false; |
520 | dpm_resume_end(PMSG_RESTORE); | 528 | dpm_resume_end(PMSG_RESTORE); |
529 | set_gfp_allowed_mask(saved_mask); | ||
521 | resume_console(); | 530 | resume_console(); |
522 | 531 | ||
523 | Close: | 532 | Close: |