[PATCH 06/10] mm, oom: check oom victims prior to numa placement
From: Michal Hocko
Date: Wed Dec 02 2026 - 04:55:23 EST
From: Michal Hocko <mhocko@xxxxxxxx>
oom_evaluate_task checks oom_cpuset_eligible before potential inflight
oom victims. This allows to have several oom victims on disjunct numa
domains but it also allows to unnecessarily kill more tasks than
necessary. But if we have tasks that consume memory in multiple numa
nodes (e.g. via vma memory policy) then we can bail too early:
TaskA (nodemask=1, vma->mpol=0), TaskB (nodemask=1)
OOM1(nodemask=0): TaskA killed
OOM2(nodemask=1): TaskA invisble due to oom_cpuset_eligible but
it will be freeing memopry from node=1 too.
Check for existing oom victims before numa placement and bail out
if there is any oom victim even if it could be in a different oom
domain. This is a slow path and postponed OOM killing is almost always a
better choice than killing that is too eager.
Reported-by: Chris Mason <mason@xxxxxxxxxx>
Signed-off-by: Michal Hocko <mhocko@xxxxxxxx>
---
mm/oom_kill.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 6dc9424e6a05..6ff1e93ec6e3 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -318,10 +318,6 @@ static int oom_evaluate_task(struct task_struct *task, void *arg)
if (oom_unkillable_task(task))
goto next;
- /* p may not have freeable memory in nodemask */
- if (!is_memcg_oom(oc) && !oom_cpuset_eligible(task, oc))
- goto next;
-
/*
* This task already has access to memory reserves and is being killed.
* Don't allow any other task to have access to the reserves unless
@@ -334,6 +330,10 @@ static int oom_evaluate_task(struct task_struct *task, void *arg)
goto abort;
}
+ /* p may not have freeable memory in nodemask */
+ if (!is_memcg_oom(oc) && !oom_cpuset_eligible(task, oc))
+ goto next;
+
/*
* If task is allocating a lot of memory and has been marked to be
* killed first if it triggers an oom, then select it.
--
2.56.1