diff options
-rw-r--r-- | mm/oom_kill.c | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 79e0f3e24831..7e9e9113bd05 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c | |||
@@ -310,26 +310,13 @@ enum oom_scan_t oom_scan_process_thread(struct task_struct *task, | |||
310 | if (!task->mm) | 310 | if (!task->mm) |
311 | return OOM_SCAN_CONTINUE; | 311 | return OOM_SCAN_CONTINUE; |
312 | 312 | ||
313 | if (task->flags & PF_EXITING) { | 313 | if (task->flags & PF_EXITING && !force_kill) { |
314 | /* | 314 | /* |
315 | * If task is current and is in the process of releasing memory, | 315 | * If this task is not being ptraced on exit, then wait for it |
316 | * allow the "kill" to set TIF_MEMDIE, which will allow it to | 316 | * to finish before killing some other task unnecessarily. |
317 | * access memory reserves. Otherwise, it may stall forever. | ||
318 | * | ||
319 | * The iteration isn't broken here, however, in case other | ||
320 | * threads are found to have already been oom killed. | ||
321 | */ | 317 | */ |
322 | if (task == current) | 318 | if (!(task->group_leader->ptrace & PT_TRACE_EXIT)) |
323 | return OOM_SCAN_SELECT; | 319 | return OOM_SCAN_ABORT; |
324 | else if (!force_kill) { | ||
325 | /* | ||
326 | * If this task is not being ptraced on exit, then wait | ||
327 | * for it to finish before killing some other task | ||
328 | * unnecessarily. | ||
329 | */ | ||
330 | if (!(task->group_leader->ptrace & PT_TRACE_EXIT)) | ||
331 | return OOM_SCAN_ABORT; | ||
332 | } | ||
333 | } | 320 | } |
334 | return OOM_SCAN_OK; | 321 | return OOM_SCAN_OK; |
335 | } | 322 | } |
@@ -706,11 +693,11 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, | |||
706 | return; | 693 | return; |
707 | 694 | ||
708 | /* | 695 | /* |
709 | * If current has a pending SIGKILL, then automatically select it. The | 696 | * If current has a pending SIGKILL or is exiting, then automatically |
710 | * goal is to allow it to allocate so that it may quickly exit and free | 697 | * select it. The goal is to allow it to allocate so that it may |
711 | * its memory. | 698 | * quickly exit and free its memory. |
712 | */ | 699 | */ |
713 | if (fatal_signal_pending(current)) { | 700 | if (fatal_signal_pending(current) || current->flags & PF_EXITING) { |
714 | set_thread_flag(TIF_MEMDIE); | 701 | set_thread_flag(TIF_MEMDIE); |
715 | return; | 702 | return; |
716 | } | 703 | } |