From: Vladimir Davydov <vdavy...@virtuozzo.com> In the berserker mode we kill a bunch of tasks that are as bad as the selected victim. We assume two tasks to be equally bad if they consume the same permille of memory. With such a strict check, it might turn out that oom berserker won't kill any tasks in case a fork bomb is running inside a container while the effect of killing a task eating <=1/1000th of memory won't be enough to cope with memory shortage. Let's loosen this check and use percentage instead of permille. In this case, it might still happen that berserker won't kill anyone, but in this case the regular oom should free at least 1/100th of memory, which should be enough even for small containers.
Also, check berserker mode even if the victim has already exited by the time we are about to send SIGKILL to it. Rationale: when the berserker is in rage, it might kill hundreds of tasks so that the next oom kill is likely to select an exiting task. Not triggering berserker in this case will result in oom stalls. Signed-off-by: Vladimir Davydov <vdavy...@virtuozzo.com> [aryabinin: rh8 rebase] Signed-off-by: Andrey Ryabinin <aryabi...@virtuozzo.com> --- mm/oom_kill.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index e746b41d558c..1cf75939aba6 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -1016,11 +1016,11 @@ static void oom_berserker(struct oom_control *oc) continue; /* - * Consider tasks as equally bad if they have equal - * normalized scores. + * Consider tasks as equally bad if they occupy equal + * percentage of available memory. */ - if (tsk_points * 1000 / oc->totalpages < - oc->chosen_points * 1000 / oc->totalpages) + if (tsk_points * 100 / oc->totalpages < + oc->chosen_points * 100 / oc->totalpages) continue; if (__ratelimit(&berserker_rs)) { @@ -1061,6 +1061,7 @@ static void oom_kill_process(struct oom_control *oc, const char *message) wake_oom_reaper(victim); task_unlock(victim); put_task_struct(victim); + oom_berserker(oc); return; } task_unlock(victim); -- 2.26.2 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel