diff options
author | Nick Piggin <npiggin@suse.de> | 2006-09-29 13:01:14 +0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-29 20:18:21 +0400 |
commit | b78483a4ba60d5d90930262a533a784e1d9df660 (patch) | |
tree | 0b2cb0f3cf2852bf4138c13179221e58a37f402a /mm/oom_kill.c | |
parent | 01017a227044d64face2588fab9427a1da1bdb9f (diff) | |
download | linux-b78483a4ba60d5d90930262a533a784e1d9df660.tar.xz |
[PATCH] oom: don't kill current when another OOM in progress
A previous patch to allow an exiting task to OOM kill itself (and thereby
avoid a little deadlock) introduced a problem. We don't want the
PF_EXITING task, even if it is 'current', to access mem reserves if there
is already a TIF_MEMDIE process in the system sucking up reserves.
Also make the commenting a little bit clearer, and note that our current
scheme of effectively single threading the OOM killer is not itself
perfect.
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm/oom_kill.c')
-rw-r--r-- | mm/oom_kill.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/mm/oom_kill.c b/mm/oom_kill.c index a5493a3b4851..20f41b082e16 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -216,6 +216,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 +235,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; |