Oom killer should avoid unnecessary kills. To prevent them, during the tasks list traverse we check for task which was previously selected as oom victims. If there is such a task, new victim is not selected.
This approach is sub-optimal (we're doing costly iteration over the task list every time) and will not work for the cgroup-aware oom killer. We already have oom_victims counter, which can be effectively used for the task. If there are victims in flight, don't do anything; if the counter falls to 0, there are no more oom victims left. So, it's a good time to start looking for a new victim. Signed-off-by: Roman Gushchin <g...@fb.com> Cc: Michal Hocko <mho...@kernel.org> Cc: Vladimir Davydov <vdavydov....@gmail.com> Cc: Johannes Weiner <han...@cmpxchg.org> Cc: Tejun Heo <t...@kernel.org> Cc: Tetsuo Handa <penguin-ker...@i-love.sakura.ne.jp> Cc: kernel-t...@fb.com Cc: cgro...@vger.kernel.org Cc: linux-doc@vger.kernel.org Cc: linux-ker...@vger.kernel.org Cc: linux...@kvack.org --- mm/oom_kill.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 0e2c925..e3aaf5c8 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -992,6 +992,13 @@ bool out_of_memory(struct oom_control *oc) if (oom_killer_disabled) return false; + /* + * If there are oom victims in flight, we don't need to select + * a new victim. + */ + if (atomic_read(&oom_victims) > 0) + return true; + if (!is_memcg_oom(oc)) { blocking_notifier_call_chain(&oom_notify_list, 0, &freed); if (freed > 0) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html