[Devel] [PATCH RHEL7 COMMIT] oom: make berserker more aggressive

Konstantin Khorenko khorenko at virtuozzo.com
Fri Apr 29 08:29:00 PDT 2016


The commit is pushed to "branch-rh7-3.10.0-327.10.1.vz7.12.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.10.1.vz7.12.15
------>
commit 4ddb655454d7893e6f9f5c3fc202694f6078219f
Author: Vladimir Davydov <vdavydov at virtuozzo.com>
Date:   Fri Apr 29 19:29:00 2016 +0400

    oom: make berserker more aggressive
    
    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>
    Reviewed-by: Kirill Tkhai <ktkhai 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 5bc4ccf..2d0fcac 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


More information about the Devel mailing list