diff -NurpP linux-2.6.31.5-vs2.3.0.36.22/mm/oom_kill.c linux-2.6.31.5-vs2.3.0.36.22.1/mm/oom_kill.c --- linux-2.6.31.5-vs2.3.0.36.22/mm/oom_kill.c 2009-09-30 02:30:43.000000000 +0200 +++ linux-2.6.31.5-vs2.3.0.36.22.1/mm/oom_kill.c 2009-11-06 19:52:27.000000000 +0100 @@ -225,13 +225,19 @@ static struct task_struct *select_bad_pr if (!p->mm) continue; /* skip the init task, global and per guest */ - if (task_is_init(p)) + if (task_is_init(p)) { + vxwprintk(1, "skipping (guest) init %p[%u#%u]", + p, p->pid, p->xid); continue; + } if (mem && !task_in_mem_cgroup(p, mem)) continue; /* skip other guest and host processes if oom in guest */ - if (xid && p->xid != xid) + if (xid && p->xid != xid) { + vxwprintk(1, "skipping non guest process %p[%u#%u]", + p, p->pid, p->xid); continue; + } /* * This task already has access to memory reserves and is @@ -242,8 +248,11 @@ static struct task_struct *select_bad_pr * blocked waiting for another task which itself is waiting * for memory. Is there a better alternative? */ - if (test_tsk_thread_flag(p, TIF_MEMDIE)) + if (test_tsk_thread_flag(p, TIF_MEMDIE)) { + vxwprintk(1, "deadlock TIF_MEMDIE %p[%u#%u]?", + p, p->pid, p->xid); return ERR_PTR(-1UL); + } /* * This is in the process of releasing memory so wait for it @@ -256,15 +265,21 @@ static struct task_struct *select_bad_pr * Otherwise we could get an easy OOM deadlock. */ if (p->flags & PF_EXITING) { - if (p != current) + if (p != current) { + vxwprintk(1, "deadlock PF_EXITING/TIF_MEMDIE %p[%u#%u]?", + p, p->pid, p->xid); return ERR_PTR(-1UL); + } chosen = p; *ppoints = ULONG_MAX; } - if (p->oomkilladj == OOM_DISABLE) + if (p->oomkilladj == OOM_DISABLE) { + vxwprintk(1, "OOM_DISABLE %p[%u#%u]", + p, p->pid, p->xid); continue; + } points = badness(p, uptime.tv_sec); if (points > *ppoints || !chosen) { @@ -273,6 +288,8 @@ static struct task_struct *select_bad_pr } } while_each_thread(g, p); + vxwprintk(1, "select_bad_process %p[%u#%u]", + chosen, chosen->pid, chosen->xid); return chosen; } @@ -551,6 +568,13 @@ retry: /* Found nothing?!?! Either we hang forever, or we panic. */ if (!p) { + /* avoid panic for guest OOM */ + if (current->xid) { + vxwprintk(0, + "Out of memory and no killable processes in #%u", + current->xid); + return; + } read_unlock(&tasklist_lock); panic("Out of memory and no killable processes...\n"); }