Commit:     ff0ceb9deb6eb017f52900b708d49cfa77bf25fb
Parent:     098d7f128a4e53cb64930628915ac767785e0e60
Author:     David Rientjes <[EMAIL PROTECTED]>
AuthorDate: Tue Oct 16 23:25:56 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Wed Oct 17 08:42:45 2007 -0700

    oom: serialize out of memory calls
    A final allocation attempt with a very high watermark needs to be attempted
    before invoking out_of_memory().  OOM killer serialization needs to occur
    before this final attempt, otherwise tasks attempting to OOM-lock all zones 
    its zonelist may spin and acquire the lock unnecessarily after the OOM
    condition has already been alleviated.
    If the final allocation does succeed, the zonelist is simply OOM-unlocked 
    __alloc_pages() returns the page.  Otherwise, the OOM killer is invoked.
    If the task cannot acquire OOM-locks on all zones in its zonelist, it is put
    to sleep and the allocation is retried when it gets rescheduled.  One of its
    zones is already marked as being in the OOM killer so it'll hopefully be
    getting some free memory soon, at least enough to satisfy a high watermark
    allocation attempt.  This prevents needlessly killing a task when the OOM
    condition would have already been alleviated if it had simply been given
    enough time.
    Cc: Andrea Arcangeli <[EMAIL PROTECTED]>
    Acked-by: Christoph Lameter <[EMAIL PROTECTED]>
    Signed-off-by: David Rientjes <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
 mm/page_alloc.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index fd2df29..43f757f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1587,6 +1587,11 @@ nofail_alloc:
                if (page)
                        goto got_pg;
        } else if ((gfp_mask & __GFP_FS) && !(gfp_mask & __GFP_NORETRY)) {
+               if (!try_set_zone_oom(zonelist)) {
+                       schedule_timeout_uninterruptible(1);
+                       goto restart;
+               }
                 * Go through the zonelist yet one more time, keep
                 * very high watermark here, this is only to catch
@@ -1595,14 +1600,19 @@ nofail_alloc:
                page = get_page_from_freelist(gfp_mask|__GFP_HARDWALL, order,
                                zonelist, ALLOC_WMARK_HIGH|ALLOC_CPUSET);
-               if (page)
+               if (page) {
+                       clear_zonelist_oom(zonelist);
                        goto got_pg;
+               }
                /* The OOM killer will not help higher order allocs so fail */
-               if (order > PAGE_ALLOC_COSTLY_ORDER)
+               if (order > PAGE_ALLOC_COSTLY_ORDER) {
+                       clear_zonelist_oom(zonelist);
                        goto nopage;
+               }
                out_of_memory(zonelist, gfp_mask, order);
+               clear_zonelist_oom(zonelist);
                goto restart;
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to