]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.0.1/oom-task-mm-null-doesn-t-mean-the-memory-was-freed.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.0.1 / oom-task-mm-null-doesn-t-mean-the-memory-was-freed.patch
CommitLineData
d53dcc05
GKH
1From c027a474a68065391c8773f6e83ed5412657e369 Mon Sep 17 00:00:00 2001
2From: Oleg Nesterov <oleg@redhat.com>
3Date: Sat, 30 Jul 2011 16:35:02 +0200
4Subject: oom: task->mm == NULL doesn't mean the memory was freed
5
6From: Oleg Nesterov <oleg@redhat.com>
7
8commit c027a474a68065391c8773f6e83ed5412657e369 upstream.
9
10exit_mm() sets ->mm == NULL then it does mmput()->exit_mmap() which
11frees the memory.
12
13However select_bad_process() checks ->mm != NULL before TIF_MEMDIE,
14so it continues to kill other tasks even if we have the oom-killed
15task freeing its memory.
16
17Change select_bad_process() to check ->mm after TIF_MEMDIE, but skip
18the tasks which have already passed exit_notify() to ensure a zombie
19with TIF_MEMDIE set can't block oom-killer. Alternatively we could
20probably clear TIF_MEMDIE after exit_mmap().
21
22Signed-off-by: Oleg Nesterov <oleg@redhat.com>
23Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
24Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
25Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
26
27---
28 mm/oom_kill.c | 4 +++-
29 1 file changed, 3 insertions(+), 1 deletion(-)
30
31--- a/mm/oom_kill.c
32+++ b/mm/oom_kill.c
33@@ -303,7 +303,7 @@ static struct task_struct *select_bad_pr
34 do_each_thread(g, p) {
35 unsigned int points;
36
37- if (!p->mm)
38+ if (p->exit_state)
39 continue;
40 if (oom_unkillable_task(p, mem, nodemask))
41 continue;
42@@ -319,6 +319,8 @@ static struct task_struct *select_bad_pr
43 */
44 if (test_tsk_thread_flag(p, TIF_MEMDIE))
45 return ERR_PTR(-1UL);
46+ if (!p->mm)
47+ continue;
48
49 if (p->flags & PF_EXITING) {
50 /*