diff options
author | David Rientjes <rientjes@google.com> | 2010-08-09 20:18:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-09 23:44:56 -0400 |
commit | 03668b3ceb0c7a95e09f1b6169f5270ffc1a19f6 (patch) | |
tree | 755ea207b968af12e195f6fb3e3b52b4d68e8630 /mm/page_alloc.c | |
parent | ad915c432eccb482427c1bbd77c74e6f7bfe60b3 (diff) |
oom: avoid oom killer for lowmem allocations
If memory has been depleted in lowmem zones even with the protection
afforded to it by /proc/sys/vm/lowmem_reserve_ratio, it is unlikely that
killing current users will help. The memory is either reclaimable (or
migratable) already, in which case we should not invoke the oom killer at
all, or it is pinned by an application for I/O. Killing such an
application may leave the hardware in an unspecified state and there is no
guarantee that it will be able to make a timely exit.
Lowmem allocations are now failed in oom conditions when __GFP_NOFAIL is
not used so that the task can perhaps recover or try again later.
Previously, the heuristic provided some protection for those tasks with
CAP_SYS_RAWIO, but this is no longer necessary since we will not be
killing tasks for the purposes of ISA allocations.
high_zoneidx is gfp_zone(gfp_flags), meaning that ZONE_NORMAL will be the
default for all allocations that are not __GFP_DMA, __GFP_DMA32,
__GFP_HIGHMEM, and __GFP_MOVABLE on kernels configured to support those
flags. Testing for high_zoneidx being less than ZONE_NORMAL will only
return true for allocations that have either __GFP_DMA or __GFP_DMA32.
Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: David Rientjes <rientjes@google.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r-- | mm/page_alloc.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 9bd339eb04c6..527f73e4c63f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -1759,6 +1759,9 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order, | |||
1759 | /* The OOM killer will not help higher order allocs */ | 1759 | /* The OOM killer will not help higher order allocs */ |
1760 | if (order > PAGE_ALLOC_COSTLY_ORDER) | 1760 | if (order > PAGE_ALLOC_COSTLY_ORDER) |
1761 | goto out; | 1761 | goto out; |
1762 | /* The OOM killer does not needlessly kill tasks for lowmem */ | ||
1763 | if (high_zoneidx < ZONE_NORMAL) | ||
1764 | goto out; | ||
1762 | /* | 1765 | /* |
1763 | * GFP_THISNODE contains __GFP_NORETRY and we never hit this. | 1766 | * GFP_THISNODE contains __GFP_NORETRY and we never hit this. |
1764 | * Sanity check for bare calls of __GFP_THISNODE, not real OOM. | 1767 | * Sanity check for bare calls of __GFP_THISNODE, not real OOM. |
@@ -2052,15 +2055,23 @@ rebalance: | |||
2052 | if (page) | 2055 | if (page) |
2053 | goto got_pg; | 2056 | goto got_pg; |
2054 | 2057 | ||
2055 | /* | 2058 | if (!(gfp_mask & __GFP_NOFAIL)) { |
2056 | * The OOM killer does not trigger for high-order | 2059 | /* |
2057 | * ~__GFP_NOFAIL allocations so if no progress is being | 2060 | * The oom killer is not called for high-order |
2058 | * made, there are no other options and retrying is | 2061 | * allocations that may fail, so if no progress |
2059 | * unlikely to help. | 2062 | * is being made, there are no other options and |
2060 | */ | 2063 | * retrying is unlikely to help. |
2061 | if (order > PAGE_ALLOC_COSTLY_ORDER && | 2064 | */ |
2062 | !(gfp_mask & __GFP_NOFAIL)) | 2065 | if (order > PAGE_ALLOC_COSTLY_ORDER) |
2063 | goto nopage; | 2066 | goto nopage; |
2067 | /* | ||
2068 | * The oom killer is not called for lowmem | ||
2069 | * allocations to prevent needlessly killing | ||
2070 | * innocent tasks. | ||
2071 | */ | ||
2072 | if (high_zoneidx < ZONE_NORMAL) | ||
2073 | goto nopage; | ||
2074 | } | ||
2064 | 2075 | ||
2065 | goto restart; | 2076 | goto restart; |
2066 | } | 2077 | } |