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

Konstantin Khorenko khorenko at virtuozzo.com
Fri Sep 24 15:04:57 MSK 2021


The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after ark-5.14
------>
commit 981c45865e3afd6d51c87d872ac288b1a9cf5d1e
Author: Vladimir Davydov <vdavydov.dev at gmail.com>
Date:   Fri Sep 24 15:04:57 2021 +0300

    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>
    
    [aryabinin: rh8 rebase]
    Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
    
    (cherry picked from vz8 commit c12f1473ab05296f0d10aa0ab97caf7dc96317a2)
    Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at 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 60c371c655af..f603a954a646 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -1048,11 +1048,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)) {
@@ -1093,6 +1093,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);


More information about the Devel mailing list