Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[pandora-kernel.git] / mm / oom_kill.c
index d348b90..b05ab8f 100644 (file)
@@ -271,9 +271,11 @@ void out_of_memory(gfp_t gfp_mask, int order)
        if (printk_ratelimit()) {
                printk("oom-killer: gfp_mask=0x%x, order=%d\n",
                        gfp_mask, order);
+               dump_stack();
                show_mem();
        }
 
+       cpuset_lock();
        read_lock(&tasklist_lock);
 retry:
        p = select_bad_process();
@@ -284,6 +286,7 @@ retry:
        /* Found nothing?!?! Either we hang forever, or we panic. */
        if (!p) {
                read_unlock(&tasklist_lock);
+               cpuset_unlock();
                panic("Out of memory and no killable processes...\n");
        }
 
@@ -293,12 +296,14 @@ retry:
 
  out:
        read_unlock(&tasklist_lock);
+       cpuset_unlock();
        if (mm)
                mmput(mm);
 
        /*
         * Give "p" a good chance of killing itself before we
-        * retry to allocate memory.
+        * retry to allocate memory unless "p" is current
         */
-       schedule_timeout_interruptible(1);
+       if (!test_thread_flag(TIF_MEMDIE))
+               schedule_timeout_interruptible(1);
 }