1 From c027a474a68065391c8773f6e83ed5412657e369 Mon Sep 17 00:00:00 2001
2 From: Oleg Nesterov <oleg@redhat.com>
3 Date: Sat, 30 Jul 2011 16:35:02 +0200
4 Subject: oom: task->mm == NULL doesn't mean the memory was freed
6 From: Oleg Nesterov <oleg@redhat.com>
8 commit c027a474a68065391c8773f6e83ed5412657e369 upstream.
10 exit_mm() sets ->mm == NULL then it does mmput()->exit_mmap() which
13 However select_bad_process() checks ->mm != NULL before TIF_MEMDIE,
14 so it continues to kill other tasks even if we have the oom-killed
15 task freeing its memory.
17 Change select_bad_process() to check ->mm after TIF_MEMDIE, but skip
18 the tasks which have already passed exit_notify() to ensure a zombie
19 with TIF_MEMDIE set can't block oom-killer. Alternatively we could
20 probably clear TIF_MEMDIE after exit_mmap().
22 Signed-off-by: Oleg Nesterov <oleg@redhat.com>
23 Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
24 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
25 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
28 mm/oom_kill.c | 4 +++-
29 1 file changed, 3 insertions(+), 1 deletion(-)
33 @@ -303,7 +303,7 @@ static struct task_struct *select_bad_pr
34 do_each_thread(g, p) {
40 if (oom_unkillable_task(p, mem, nodemask))
42 @@ -319,6 +319,8 @@ static struct task_struct *select_bad_pr
44 if (test_tsk_thread_flag(p, TIF_MEMDIE))
49 if (p->flags & PF_EXITING) {