lineage_android_kernel_sams.../include
Michal Hocko 7655f8554e OOM, PM: OOM killed task shouldn't escape PM suspend
commit 5695be142e203167e3cb515ef86a88424f3524eb upstream.

PM freezer relies on having all tasks frozen by the time devices are
getting frozen so that no task will touch them while they are getting
frozen. But OOM killer is allowed to kill an already frozen task in
order to handle OOM situtation. In order to protect from late wake ups
OOM killer is disabled after all tasks are frozen. This, however, still
keeps a window open when a killed task didn't manage to die by the time
freeze_processes finishes.

Reduce the race window by checking all tasks after OOM killer has been
disabled. This is still not race free completely unfortunately because
oom_killer_disable cannot stop an already ongoing OOM killer so a task
might still wake up from the fridge and get killed without
freeze_processes noticing. Full synchronization of OOM and freezer is,
however, too heavy weight for this highly unlikely case.

Introduce and check oom_kills counter which gets incremented early when
the allocator enters __alloc_pages_may_oom path and only check all the
tasks if the counter changes during the freezing attempt. The counter
is updated so early to reduce the race window since allocator checked
oom_killer_disabled which is set by PM-freezing code. A false positive
will push the PM-freezer into a slow path but that is not a big deal.

Changes since v1
- push the re-check loop out of freeze_processes into
  check_frozen_processes and invert the condition to make the code more
  readable as per Rafael

Fixes: f660daac47 (oom: thaw threads if oom killed thread is frozen before deferring)
Signed-off-by: Michal Hocko <mhocko@suse.cz>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Zefan Li <lizefan@huawei.com>
2015-02-02 17:04:55 +08:00
..
acpi
asm-generic mm: allow arch code to control the user page table ceiling 2013-05-07 19:51:55 -07:00
crypto crypto: scatterwalk - Use sg_chain_ptr on chain entries 2013-12-11 22:34:12 -08:00
drm introduce SIZE_MAX 2014-07-31 12:54:53 -07:00
keys
linux OOM, PM: OOM killed task shouldn't escape PM suspend 2015-02-02 17:04:55 +08:00
math-emu
media media: v4l2: added missing mutex.h include to v4l2-ctrls.h 2013-09-26 17:15:49 -07:00
misc
mtd
net regulatory: add NUL to alpha2 2014-12-01 18:02:22 +08:00
pcmcia
rdma infiniband: pass rdma_cm module to netlink_dump_start 2012-10-28 10:14:15 -07:00
rxrpc
scsi ore: Fix wrong math in allocation of per device BIO 2014-02-13 11:51:11 -08:00
sound ALSA: control: Protect user controls against concurrent access 2014-06-26 15:10:29 -04:00
target target: Add link_magic for fabric allow_link destination target_items 2013-01-21 11:45:24 -08:00
trace tracing: Fix syscall_*regfunc() vs copy_process() race 2014-07-06 18:49:20 -07:00
video atmel_lcdfb: fix 16-bpp modes on older SOCs 2013-03-20 13:05:00 -07:00
xen xen-netfront: reduce gso_max_size to account for max TCP header 2014-06-07 16:02:15 -07:00
Kbuild