aboutsummaryrefslogtreecommitdiffstats
path: root/mm/oom_kill.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2011-07-30 16:35:02 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2011-08-04 21:58:42 -0700
commit84416db67616ae44e7111c1c904a53cc79b95b6a (patch)
tree4a87402339a3488109972558c78a8b9c6840d30e /mm/oom_kill.c
parent06b943855b6dbcc8cb3cdca954c19711ce7b76b6 (diff)
downloadkernel_samsung_smdk4412-84416db67616ae44e7111c1c904a53cc79b95b6a.tar.gz
kernel_samsung_smdk4412-84416db67616ae44e7111c1c904a53cc79b95b6a.tar.bz2
kernel_samsung_smdk4412-84416db67616ae44e7111c1c904a53cc79b95b6a.zip
oom: task->mm == NULL doesn't mean the memory was freed
commit c027a474a68065391c8773f6e83ed5412657e369 upstream. exit_mm() sets ->mm == NULL then it does mmput()->exit_mmap() which frees the memory. However select_bad_process() checks ->mm != NULL before TIF_MEMDIE, so it continues to kill other tasks even if we have the oom-killed task freeing its memory. Change select_bad_process() to check ->mm after TIF_MEMDIE, but skip the tasks which have already passed exit_notify() to ensure a zombie with TIF_MEMDIE set can't block oom-killer. Alternatively we could probably clear TIF_MEMDIE after exit_mmap(). Signed-off-by: Oleg Nesterov <oleg@redhat.com> Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'mm/oom_kill.c')
-rw-r--r--mm/oom_kill.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index e4b0991ca35..8093fc766d1 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -303,7 +303,7 @@ static struct task_struct *select_bad_process(unsigned int *ppoints,
do_each_thread(g, p) {
unsigned int points;
- if (!p->mm)
+ if (p->exit_state)
continue;
if (oom_unkillable_task(p, mem, nodemask))
continue;
@@ -319,6 +319,8 @@ static struct task_struct *select_bad_process(unsigned int *ppoints,
*/
if (test_tsk_thread_flag(p, TIF_MEMDIE))
return ERR_PTR(-1UL);
+ if (!p->mm)
+ continue;
if (p->flags & PF_EXITING) {
/*