Commit c027a474a68065391c8773f6e83ed5412657e369
Committed by
Linus Torvalds
1 parent
cfe22345ad
Exists in
master
and in
6 other branches
oom: task->mm == NULL doesn't mean the memory was freed
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>
Showing 1 changed file with 3 additions and 1 deletions Side-by-side Diff
mm/oom_kill.c
... | ... | @@ -303,7 +303,7 @@ |
303 | 303 | do_each_thread(g, p) { |
304 | 304 | unsigned int points; |
305 | 305 | |
306 | - if (!p->mm) | |
306 | + if (p->exit_state) | |
307 | 307 | continue; |
308 | 308 | if (oom_unkillable_task(p, mem, nodemask)) |
309 | 309 | continue; |
... | ... | @@ -319,6 +319,8 @@ |
319 | 319 | */ |
320 | 320 | if (test_tsk_thread_flag(p, TIF_MEMDIE)) |
321 | 321 | return ERR_PTR(-1UL); |
322 | + if (!p->mm) | |
323 | + continue; | |
322 | 324 | |
323 | 325 | if (p->flags & PF_EXITING) { |
324 | 326 | /* |