[WATCHDOG] sa1100_wdt.c sparse clean (2)
[pandora-kernel.git] / mm / oom_kill.c
index ac3bf33..b05ab8f 100644 (file)
@@ -263,7 +263,7 @@ static struct mm_struct *oom_kill_process(struct task_struct *p)
  * OR try to be smart about which process to kill. Note that we
  * don't have to be perfect here, we just have to be good.
  */
-void out_of_memory(unsigned int __nocast gfp_mask, int order)
+void out_of_memory(gfp_t gfp_mask, int order)
 {
        struct mm_struct *mm = NULL;
        task_t * p;
@@ -271,9 +271,11 @@ void out_of_memory(unsigned int __nocast 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);
 }