android_kernel_motorola_sm6225/kernel/power
Rafael J. Wysocki 7f33d49a2e mm, PM/Freezer: Disable OOM killer when tasks are frozen
Currently, the following scenario appears to be possible in theory:

* Tasks are frozen for hibernation or suspend.
* Free pages are almost exhausted.
* Certain piece of code in the suspend code path attempts to allocate
  some memory using GFP_KERNEL and allocation order less than or
  equal to PAGE_ALLOC_COSTLY_ORDER.
* __alloc_pages_internal() cannot find a free page so it invokes the
  OOM killer.
* The OOM killer attempts to kill a task, but the task is frozen, so
  it doesn't die immediately.
* __alloc_pages_internal() jumps to 'restart', unsuccessfully tries
  to find a free page and invokes the OOM killer.
* No progress can be made.

Although it is now hard to trigger during hibernation due to the memory
shrinking carried out by the hibernation code, it is theoretically
possible to trigger during suspend after the memory shrinking has been
removed from that code path.  Moreover, since memory allocations are
going to be used for the hibernation memory shrinking, it will be even
more likely to happen during hibernation.

To prevent it from happening, introduce the oom_killer_disabled switch
that will cause __alloc_pages_internal() to fail in the situations in
which the OOM killer would have been called and make the freezer set
this switch after tasks have been successfully frozen.

[akpm@linux-foundation.org: be nicer to the namespace]
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Fengguang Wu <fengguang.wu@gmail.com>
Cc: David Rientjes <rientjes@google.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Cc: Mel Gorman <mel@csn.ul.ie>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-06-16 19:47:40 -07:00
..
console.c PM: Wait for console in resume 2009-02-21 14:17:17 -08:00
hibernate.c PM/Hibernate: Rename disk.c to hibernate.c 2009-06-12 21:32:33 +02:00
hibernate_nvs.c PM/Hibernate: Move NVS routines into a seperate file (v2). 2009-06-12 21:32:33 +02:00
Kconfig PM/Hibernate: Move NVS routines into a seperate file (v2). 2009-06-12 21:32:33 +02:00
main.c PM: Separate suspend to RAM functionality from core 2009-06-12 21:32:33 +02:00
Makefile PM/Hibernate: Move NVS routines into a seperate file (v2). 2009-06-12 21:32:33 +02:00
power.h PM/Hibernate: Rename disk.c to hibernate.c 2009-06-12 21:32:33 +02:00
poweroff.c trivial: kernel/power/poweroff.c: whitespace fix 2009-06-12 18:01:46 +02:00
process.c mm, PM/Freezer: Disable OOM killer when tasks are frozen 2009-06-16 19:47:40 -07:00
snapshot.c PM/Hibernate: Move memory shrinking to snapshot.c (rev. 2) 2009-06-12 21:32:32 +02:00
suspend.c PM: Separate suspend to RAM functionality from core 2009-06-12 21:32:33 +02:00
suspend_test.c PM: Separate suspend to RAM functionality from core 2009-06-12 21:32:33 +02:00
swap.c swap: Remove code handling bio_alloc failure with __GFP_WAIT 2009-04-15 12:10:13 +02:00
swsusp.c PM/Hibernate: Move NVS routines into a seperate file (v2). 2009-06-12 21:32:33 +02:00
user.c PM/Hibernate: Wait for SCSI devices scan to complete during resume 2009-04-13 11:37:07 -07:00