Re: [patch -mm 8/9 v2] oom: avoid oom killer for lowmem allocations

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: David Rientjes
Date: Tuesday, February 16, 2010 - 5:21 pm

On Wed, 17 Feb 2010, KAMEZAWA Hiroyuki wrote:


out_of_memory() doesn't return a value to specify whether the page 
allocator should retry the allocation or just return NULL, all that policy 
is kept in mm/page_alloc.c.  For highzone_idx < ZONE_NORMAL, we want to 
fail the allocation when !(gfp_mask & __GFP_NOFAIL) and call the oom 
killer when it's __GFP_NOFAIL.
---
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1696,6 +1696,9 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order,
 		/* The OOM killer will not help higher order allocs */
 		if (order > PAGE_ALLOC_COSTLY_ORDER)
 			goto out;
+		/* The OOM killer does not needlessly kill tasks for lowmem */
+		if (high_zoneidx < ZONE_NORMAL)
+			goto out;
 		/*
 		 * GFP_THISNODE contains __GFP_NORETRY and we never hit this.
 		 * Sanity check for bare calls of __GFP_THISNODE, not real OOM.
@@ -1924,15 +1927,23 @@ rebalance:
 			if (page)
 				goto got_pg;
 
-			/*
-			 * The OOM killer does not trigger for high-order
-			 * ~__GFP_NOFAIL allocations so if no progress is being
-			 * made, there are no other options and retrying is
-			 * unlikely to help.
-			 */
-			if (order > PAGE_ALLOC_COSTLY_ORDER &&
-						!(gfp_mask & __GFP_NOFAIL))
-				goto nopage;
+			if (!(gfp_mask & __GFP_NOFAIL)) {
+				/*
+				 * The oom killer is not called for high-order
+				 * allocations that may fail, so if no progress
+				 * is being made, there are no other options and
+				 * retrying is unlikely to help.
+				 */
+				if (order > PAGE_ALLOC_COSTLY_ORDER)
+					goto nopage;
+				/*
+				 * The oom killer is not called for lowmem
+				 * allocations to prevent needlessly killing
+				 * innocent tasks.
+				 */
+				if (high_zoneidx < ZONE_NORMAL)
+					goto nopage;
+			}
 
 			goto restart;
 		}
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch -mm 0/9 v2] oom killer rewrite, David Rientjes, (Mon Feb 15, 3:19 pm)
[patch -mm 5/9 v2] oom: badness heuristic rewrite, David Rientjes, (Mon Feb 15, 3:20 pm)
[patch -mm 6/9 v2] oom: deprecate oom_adj tunable, David Rientjes, (Mon Feb 15, 3:20 pm)
[patch -mm 7/9 v2] oom: replace sysctls with quick mode, David Rientjes, (Mon Feb 15, 3:20 pm)
Re: [patch -mm 6/9 v2] oom: deprecate oom_adj tunable, David Rientjes, (Mon Feb 15, 3:35 pm)
Re: [patch -mm 8/9 v2] oom: avoid oom killer for lowmem al ..., KAMEZAWA Hiroyuki, (Mon Feb 15, 4:57 pm)
Re: [patch -mm 4/9 v2] oom: remove compulsory panic_on_oom ..., KAMEZAWA Hiroyuki, (Mon Feb 15, 5:00 pm)
Re: [patch -mm 8/9 v2] oom: avoid oom killer for lowmem al ..., KAMEZAWA Hiroyuki, (Mon Feb 15, 5:21 pm)
Re: [patch -mm 4/9 v2] oom: remove compulsory panic_on_oom ..., KAMEZAWA Hiroyuki, (Mon Feb 15, 5:23 pm)
[patch] mm: add comment about deprecation of __GFP_NOFAIL, David Rientjes, (Mon Feb 15, 6:13 pm)
Re: [patch] mm: add comment about deprecation of __GFP_NOFAIL, KAMEZAWA Hiroyuki, (Mon Feb 15, 6:26 pm)
Re: [patch -mm 4/9 v2] oom: remove compulsory panic_on_oom ..., KAMEZAWA Hiroyuki, (Tue Feb 16, 1:10 am)
Re: [patch -mm 4/9 v2] oom: remove compulsory panic_on_oom ..., KAMEZAWA Hiroyuki, (Tue Feb 16, 4:42 pm)
Re: [patch -mm 8/9 v2] oom: avoid oom killer for lowmem al ..., KAMEZAWA Hiroyuki, (Tue Feb 16, 4:48 pm)
Re: [patch -mm 4/9 v2] oom: remove compulsory panic_on_oom ..., KAMEZAWA Hiroyuki, (Tue Feb 16, 5:01 pm)
Re: [patch -mm 8/9 v2] oom: avoid oom killer for lowmem al ..., KAMEZAWA Hiroyuki, (Tue Feb 16, 5:03 pm)
Re: [patch -mm 8/9 v2] oom: avoid oom killer for lowmem al ..., David Rientjes, (Tue Feb 16, 5:21 pm)
Re: [patch -mm 4/9 v2] oom: remove compulsory panic_on_oom ..., KAMEZAWA Hiroyuki, (Tue Feb 16, 5:41 pm)
Re: [patch -mm 4/9 v2] oom: remove compulsory panic_on_oom ..., KAMEZAWA Hiroyuki, (Tue Feb 16, 6:03 pm)
Re: [patch -mm 4/9 v2] oom: remove compulsory panic_on_oom ..., KAMEZAWA Hiroyuki, (Tue Feb 16, 7:13 pm)
Re: [patch -mm 4/9 v2] oom: remove compulsory panic_on_oom ..., KAMEZAWA Hiroyuki, (Tue Feb 16, 7:23 pm)
Re: [patch -mm 4/9 v2] oom: remove compulsory panic_on_oom ..., KAMEZAWA Hiroyuki, (Tue Feb 16, 7:34 pm)
Re: [patch -mm 4/9 v2] oom: remove compulsory panic_on_oom ..., KAMEZAWA Hiroyuki, (Tue Feb 16, 8:21 pm)
Re: [patch -mm 4/9 v2] oom: remove compulsory panic_on_oom ..., Daisuke Nishimura, (Sun Feb 21, 10:31 pm)
Re: [patch -mm 4/9 v2] oom: remove compulsory panic_on_oom ..., KAMEZAWA Hiroyuki, (Sun Feb 21, 11:15 pm)
Re: [patch -mm 4/9 v2] oom: remove compulsory panic_on_oom ..., Daisuke Nishimura, (Mon Feb 22, 4:42 am)
Re: [patch -mm 4/9 v2] oom: remove compulsory panic_on_oom ..., KAMEZAWA Hiroyuki, (Mon Feb 22, 4:51 pm)