mm: page_alloc: embed OOM killing naturally into allocation slowpath
authorJohannes Weiner <hannes@cmpxchg.org>
Mon, 26 Jan 2015 20:58:32 +0000 (12:58 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 26 Jan 2015 21:37:18 +0000 (13:37 -0800)
commit9879de7373fcfb466ec198293b6ccc1ad7a42dd8
tree047533253898e317ce7e41a1078433e1e19d625f
parent26bc420b59a38e4e6685a73345a0def461136dce
mm: page_alloc: embed OOM killing naturally into allocation slowpath

The OOM killing invocation does a lot of duplicative checks against the
task's allocation context.  Rework it to take advantage of the existing
checks in the allocator slowpath.

The OOM killer is invoked when the allocator is unable to reclaim any
pages but the allocation has to keep looping.  Instead of having a check
for __GFP_NORETRY hidden in oom_gfp_allowed(), just move the OOM
invocation to the true branch of should_alloc_retry().  The __GFP_FS
check from oom_gfp_allowed() can then be moved into the OOM avoidance
branch in __alloc_pages_may_oom(), along with the PF_DUMPCORE test.

__alloc_pages_may_oom() can then signal to the caller whether the OOM
killer was invoked, instead of requiring it to duplicate the order and
high_zoneidx checks to guess this when deciding whether to continue.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.cz>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/oom.h
mm/page_alloc.c