[PATCH 33/60] cgroup/cpuset: ignore private nodes when matching OOM victims
From: Gregory Price via B4 Relay
Date: Fri Nov 20 2026 - 13:20:28 EST
From: "Gregory Price (Meta)" <gourry@xxxxxxxxxx>
The OOM killer only considers a task an eligible victim if its
mems_allowed intersects the allocating task's mems_allowed. The
assumption is that a shared node means shared ordinary memory.
Private nodes break that assumption. If two cpusets partition common
memory but both allow a private node, an OOM in one could kill tasks in
the other and free nothing the allocating task can use.
Initially, private memory allocations will never invoke the OOM killer,
so only common memory pressure reaches this check.
Leave private nodes out of the intersection.
Signed-off-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>
---
kernel/cgroup/cpuset.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 8401b69ee3da..e20f9ccb8ab7 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -4628,15 +4628,19 @@ int cpuset_mem_spread_node(void)
* @tsk2: pointer to task_struct of some other task.
*
* Description: Return true if @tsk1's mems_allowed intersects the
- * mems_allowed of @tsk2. Used by the OOM killer to determine if
- * one of the task's memory usage might impact the memory available
- * to the other.
+ * mems_allowed of @tsk2 outside private memory nodes. Used by the OOM
+ * killer to determine if one of the task's memory usage might impact the
+ * memory available to the other.
**/
int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,
const struct task_struct *tsk2)
{
- return nodes_intersects(tsk1->mems_allowed, tsk2->mems_allowed);
+ nodemask_t shared;
+
+ nodes_and(shared, tsk1->mems_allowed, tsk2->mems_allowed);
+ nodes_andnot(shared, shared, node_states[N_MEMORY_PRIVATE]);
+ return !nodes_empty(shared);
}
/**
--
2.56.1