Messages in this thread Patch in this message | | | Date | Sun, 10 May 2009 15:07:27 -0700 (PDT) | From | David Rientjes <> | Subject | [patch 11/11 -mmotm] oom: fail allocations if oom killer can't free memory |
| |
The oom killer now reports the potential number of pages that will be freed when an oom kill task finally exits. If the oom killer can't make any progress in freeing memory, however, there is no reason to continue looping endlessly in the page allocator. Instead, the allocation is failed if it is not __GFP_NOFAIL.
Cc: Mel Gorman <mel@csn.ul.ie> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Nick Piggin <npiggin@suse.de> Cc: Christoph Lameter <cl@linux-foundation.org> Cc: Dave Hansen <dave@linux.vnet.ibm.com> Signed-off-by: David Rientjes <rientjes@google.com> --- mm/page_alloc.c | 35 ++++++++++++++++++++--------------- 1 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1524,7 +1524,7 @@ static inline struct page * __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order, struct zonelist *zonelist, enum zone_type high_zoneidx, nodemask_t *nodemask, struct zone *preferred_zone, - int migratetype) + int migratetype, unsigned long *did_some_progress) { struct page *page; @@ -1551,7 +1551,7 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order, goto out; /* Exhausted what can be done so it's blamo time */ - out_of_memory(zonelist, gfp_mask, order); + *did_some_progress += out_of_memory(zonelist, gfp_mask, order); out: clear_zonelist_oom(zonelist, gfp_mask); @@ -1716,7 +1716,6 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, */ alloc_flags = gfp_to_alloc_flags(gfp_mask); -restart: /* This is the last chance, in general, before the goto nopage. */ page = get_page_from_freelist(gfp_mask, nodemask, order, zonelist, high_zoneidx, alloc_flags & ~ALLOC_NO_WATERMARKS, @@ -1760,21 +1759,27 @@ rebalance: page = __alloc_pages_may_oom(gfp_mask, order, zonelist, high_zoneidx, nodemask, preferred_zone, - migratetype); + migratetype, &did_some_progress); 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; - - goto restart; + if (!(gfp_mask & __GFP_NOFAIL)) { + /* + * The OOM killer does not trigger for + * high-order 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) + goto nopage; + + /* + * If the oom killer could not free any memory, + * there is no reason to endlessly loop. + */ + if (!did_some_progress) + goto nopage; + } } }
| |