X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=mm%2Foom_kill.c;h=2e3ce3a928b97dd8eeb54b42fb6f363d15a6d2ae;hb=450efcfd2e1d941e302a8c89322fbfcef237be98;hp=a5493a3b4851282b879590f653ed9aae1b36b08a;hpb=01017a227044d64face2588fab9427a1da1bdb9f;p=safe%2Fjmp%2Flinux-2.6 diff --git a/mm/oom_kill.c b/mm/oom_kill.c index a5493a3..2e3ce3a 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -15,6 +15,7 @@ * kernel subsystems and hints as to where to find out what things do. */ +#include #include #include #include @@ -216,6 +217,18 @@ static struct task_struct *select_bad_process(unsigned long *ppoints) continue; /* + * This task already has access to memory reserves and is + * being killed. Don't allow any other task access to the + * memory reserve. + * + * Note: this may have a chance of deadlock if it gets + * blocked waiting for another task which itself is waiting + * for memory. Is there a better alternative? + */ + if (test_tsk_thread_flag(p, TIF_MEMDIE)) + return ERR_PTR(-1UL); + + /* * This is in the process of releasing memory so wait for it * to finish before killing some other task by mistake. * @@ -223,16 +236,15 @@ static struct task_struct *select_bad_process(unsigned long *ppoints) * go ahead if it is exiting: this will simply set TIF_MEMDIE, * which will allow it to gain access to memory reserves in * the process of exiting and releasing its resources. - * Otherwise we could get an OOM deadlock. + * Otherwise we could get an easy OOM deadlock. */ - if ((p->flags & PF_EXITING) && p == current) { + if (p->flags & PF_EXITING) { + if (p != current) + return ERR_PTR(-1UL); + chosen = p; *ppoints = ULONG_MAX; - break; } - if ((p->flags & PF_EXITING) || - test_tsk_thread_flag(p, TIF_MEMDIE)) - return ERR_PTR(-1UL); if (p->oomkilladj == OOM_DISABLE) continue;