[Devel] [PATCH rh7 5/5] oom: make berserker more aggressive
Vladimir Davydov
vdavydov at virtuozzo.com
Tue Apr 12 09:34:27 PDT 2016
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 <vdavydov at virtuozzo.com>
---
mm/oom_kill.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 5bc4ccfcf41f..2d0fcac6f52b 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -757,11 +757,11 @@ static void oom_berserker(unsigned long points, unsigned long overdraft,
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 / totalpages <
- points * 1000 / totalpages)
+ if (tsk_points * 100 / totalpages <
+ points * 100 / totalpages)
continue;
if (__ratelimit(&berserker_rs)) {
@@ -809,8 +809,7 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
if (p->mm && p->flags & PF_EXITING) {
mark_oom_victim(p);
task_unlock(p);
- put_task_struct(p);
- return;
+ goto out;
}
task_unlock(p);
@@ -855,8 +854,7 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
p = find_lock_task_mm(victim);
if (!p) {
- put_task_struct(victim);
- return;
+ goto out;
} else if (victim != p) {
get_task_struct(p);
put_task_struct(victim);
@@ -902,8 +900,8 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
do_send_sig_info(SIGKILL, SEND_SIG_FORCED, victim, true);
mem_cgroup_note_oom_kill(memcg, victim);
+out:
put_task_struct(victim);
-
oom_berserker(points, overdraft, totalpages, memcg, nodemask);
}
#undef K
--
2.1.4
More information about the Devel
mailing list