aboutsummaryrefslogtreecommitdiffstats
path: root/mm/oom_kill.c
diff options
context:
space:
mode:
authorMichal Hocko <mhocko@suse.com>2016-05-19 20:13:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-19 22:12:14 -0400
commit449d777d7ad6d7f9ac5ed8f618fa13e6ff36c32f (patch)
tree8836111f6476fc1ca46042903c98eadc906f87d1 /mm/oom_kill.c
parent3ef22dfff2390e75b379f9715388a852aa56e0d5 (diff)
mm, oom_reaper: clear TIF_MEMDIE for all tasks queued for oom_reaper
Right now the oom reaper will clear TIF_MEMDIE only for tasks which were successfully reaped. This is the safest option because we know that such an oom victim would only block forward progress of the oom killer without a good reason because it is highly unlikely it would release much more memory. Basically most of its memory has been already torn down. We can relax this assumption to catch more corner cases though. The first obvious one is when the oom victim clears its mm and gets stuck later on. oom_reaper would back of on find_lock_task_mm returning NULL. We can safely try to clear TIF_MEMDIE in this case because such a task would be ignored by the oom killer anyway. The flag would be cleared by that time already most of the time anyway. The less obvious one is when the oom reaper fails due to mmap_sem contention. Even if we clear TIF_MEMDIE for this task then it is not very likely that we would select another task too easily because we haven't reaped the last victim and so it would be still the #1 candidate. There is a rare race condition possible when the current victim terminates before the next select_bad_process but considering that oom_reap_task had retried several times before giving up then this sounds like a borderline thing. After this patch we should have a guarantee that the OOM killer will not be block for unbounded amount of time for most cases. Signed-off-by: Michal Hocko <mhocko@suse.com> Cc: Raushaniya Maksudova <rmaksudova@parallels.com> Cc: Michael S. Tsirkin <mst@redhat.com> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: David Rientjes <rientjes@google.com> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: Daniel Vetter <daniel.vetter@intel.com> Cc: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/oom_kill.c')
-rw-r--r--mm/oom_kill.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 850b6ff66bdf..415f7eb913fa 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -510,14 +510,10 @@ static bool __oom_reap_task(struct task_struct *tsk)
510 up_read(&mm->mmap_sem); 510 up_read(&mm->mmap_sem);
511 511
512 /* 512 /*
513 * Clear TIF_MEMDIE because the task shouldn't be sitting on a 513 * This task can be safely ignored because we cannot do much more
514 * reasonably reclaimable memory anymore. OOM killer can continue 514 * to release its memory.
515 * by selecting other victim if unmapping hasn't led to any
516 * improvements. This also means that selecting this task doesn't
517 * make any sense.
518 */ 515 */
519 tsk->signal->oom_score_adj = OOM_SCORE_ADJ_MIN; 516 tsk->signal->oom_score_adj = OOM_SCORE_ADJ_MIN;
520 exit_oom_victim(tsk);
521out: 517out:
522 mmput(mm); 518 mmput(mm);
523 return ret; 519 return ret;
@@ -538,6 +534,15 @@ static void oom_reap_task(struct task_struct *tsk)
538 debug_show_all_locks(); 534 debug_show_all_locks();
539 } 535 }
540 536
537 /*
538 * Clear TIF_MEMDIE because the task shouldn't be sitting on a
539 * reasonably reclaimable memory anymore or it is not a good candidate
540 * for the oom victim right now because it cannot release its memory
541 * itself nor by the oom reaper.
542 */
543 tsk->oom_reaper_list = NULL;
544 exit_oom_victim(tsk);
545
541 /* Drop a reference taken by wake_oom_reaper */ 546 /* Drop a reference taken by wake_oom_reaper */
542 put_task_struct(tsk); 547 put_task_struct(tsk);
543} 548}