[vz8,3/3] oom: make berserker more aggressive

Submitted by Andrey Ryabinin on Nov. 11, 2020, 5:21 p.m.

Details

Message ID 20201111172111.19300-3-aryabinin@virtuozzo.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Andrey Ryabinin Nov. 11, 2020, 5:21 p.m.
From: Vladimir Davydov <vdavydov@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@virtuozzo.com>

[aryabinin: rh8 rebase]
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 mm/oom_kill.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

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);