linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/oom_kill: kill current in OOM when binding to cpu-less nodes
@ 2025-09-04 13:44 Jinjiang Tu
  2025-09-04 14:25 ` Michal Hocko
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Jinjiang Tu @ 2025-09-04 13:44 UTC (permalink / raw)
  To: mhocko, rientjes, shakeel.butt, akpm, david, ziy, matthew.brost,
	joshua.hahnjy, rakie.kim, byungchul, gourry, ying.huang, apopple,
	linux-mm
  Cc: wangkefeng.wang, tujinjiang

out_of_memory() selects tasks without considering mempolicy. Assuming a
cpu-less NUMA Node, ordinary process that don't set mempolicy don't
allocate memory from this cpu-less Node, unless other NUMA Nodes are below
low watermark. If a task binds to this cpu-less Node and triggers OOM, many
tasks may be killed wrongly that don't occupy memory from this Node.

To fix it, only kill current if oc->nodemask are all nodes without any cpu.

Signed-off-by: Jinjiang Tu <tujinjiang@huawei.com>
---
 mm/oom_kill.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 25923cfec9c6..8ae4b2ecfe12 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -1100,6 +1100,20 @@ int unregister_oom_notifier(struct notifier_block *nb)
 }
 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
 
+static bool should_oom_kill_allocating_task(struct oom_control *oc)
+{
+	if (sysctl_oom_kill_allocating_task)
+		return true;
+
+	if (!oc->nodemask)
+		return false;
+
+	if (nodes_intersects(*oc->nodemask, node_states[N_CPU]))
+		return false;
+
+	return true;
+}
+
 /**
  * out_of_memory - kill the "best" process when we run out of memory
  * @oc: pointer to struct oom_control
@@ -1151,7 +1165,7 @@ bool out_of_memory(struct oom_control *oc)
 		oc->nodemask = NULL;
 	check_panic_on_oom(oc);
 
-	if (!is_memcg_oom(oc) && sysctl_oom_kill_allocating_task &&
+	if (!is_memcg_oom(oc) && should_oom_kill_allocating_task(oc) &&
 	    current->mm && !oom_unkillable_task(current) &&
 	    oom_cpuset_eligible(current, oc) &&
 	    current->signal->oom_score_adj != OOM_SCORE_ADJ_MIN) {
-- 
2.43.0



^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2025-09-08 17:50 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-04 13:44 [PATCH] mm/oom_kill: kill current in OOM when binding to cpu-less nodes Jinjiang Tu
2025-09-04 14:25 ` Michal Hocko
2025-09-05  1:56   ` Jinjiang Tu
2025-09-05  8:08     ` Michal Hocko
2025-09-05  8:18       ` Jinjiang Tu
2025-09-05  9:10         ` Michal Hocko
2025-09-05  9:25           ` Jinjiang Tu
2025-09-05  9:42             ` Michal Hocko
2025-09-06  1:56               ` Jinjiang Tu
2025-09-08  7:46                 ` Michal Hocko
2025-09-08  8:16                   ` Jinjiang Tu
2025-09-08  9:11                     ` Michal Hocko
2025-09-08 11:07                       ` Jinjiang Tu
2025-09-08 11:13                       ` Jinjiang Tu
2025-09-08 11:26                         ` Michal Hocko
2025-09-05  9:13   ` Michal Hocko
2025-09-04 14:26 ` Joshua Hahn
2025-09-04 14:36   ` Michal Hocko
2025-09-04 14:43     ` Joshua Hahn
2025-09-05  2:05       ` Jinjiang Tu
2025-09-08 17:50 ` Gregory Price

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox