Skip to content

Commit 82553a9

Browse files
rientjestorvalds
authored andcommitted
oom: invoke oom killer for __GFP_NOFAIL
The oom killer must be invoked regardless of the order if the allocation is __GFP_NOFAIL, otherwise it will loop forever when reclaim fails to free some memory. Cc: Nick Piggin <npiggin@suse.de> Acked-by: Rik van Riel <riel@redhat.com> Acked-by: Mel Gorman <mel@csn.ul.ie> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Christoph Lameter <cl@linux-foundation.org> Cc: Dave Hansen <dave@linux.vnet.ibm.com> Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 4d8b913 commit 82553a9

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎mm/page_alloc.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order,
15611561
goto out;
15621562

15631563
/* The OOM killer will not help higher order allocs */
1564-
if (order > PAGE_ALLOC_COSTLY_ORDER)
1564+
if (order > PAGE_ALLOC_COSTLY_ORDER && !(gfp_mask & __GFP_NOFAIL))
15651565
goto out;
15661566

15671567
/* Exhausted what can be done so it's blamo time */
@@ -1781,11 +1781,13 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
17811781
goto got_pg;
17821782

17831783
/*
1784-
* The OOM killer does not trigger for high-order allocations
1785-
* but if no progress is being made, there are no other
1786-
* options and retrying is unlikely to help
1784+
* The OOM killer does not trigger for high-order
1785+
* ~__GFP_NOFAIL allocations so if no progress is being
1786+
* made, there are no other options and retrying is
1787+
* unlikely to help.
17871788
*/
1788-
if (order > PAGE_ALLOC_COSTLY_ORDER)
1789+
if (order > PAGE_ALLOC_COSTLY_ORDER &&
1790+
!(gfp_mask & __GFP_NOFAIL))
17891791
goto nopage;
17901792

17911793
goto restart;

0 commit comments

Comments
 (0)