[Devel] [PATCH RH9 09/33] oom: make berserker more aggressive

Andrey Zhadchenko andrey.zhadchenko at virtuozzo.com
Thu Sep 23 22:08:12 MSK 2021


From: Vladimir Davydov <vdavydov at 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 <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 60c371c..f603a95 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);
-- 
1.8.3.1



More information about the Devel mailing list