Skip to content

Commit 6cf86ac

Browse files
rientjestorvalds
authored andcommitted
oom: filter tasks not sharing the same cpuset
Tasks that do not share the same set of allowed nodes with the task that triggered the oom should not be considered as candidates for oom kill. Tasks in other cpusets with a disjoint set of mems would be unfairly penalized otherwise because of oom conditions elsewhere; an extreme example could unfairly kill all other applications on the system if a single task in a user's cpuset sets itself to OOM_DISABLE and then uses more memory than allowed. Killing tasks outside of current's cpuset rarely would free memory for current anyway. To use a sane heuristic, we must ensure that killing a task would likely free memory for current and avoid needlessly killing others at all costs just because their potential memory freeing is unknown. It is better to kill current than another task needlessly. Signed-off-by: David Rientjes <[email protected]> Acked-by: Rik van Riel <[email protected]> Acked-by: Nick Piggin <[email protected]> Acked-by: Balbir Singh <[email protected]> Cc: KOSAKI Motohiro <[email protected]> Reviewed-by: KAMEZAWA Hiroyuki <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 4358997 commit 6cf86ac

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

mm/oom_kill.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,6 @@ unsigned long badness(struct task_struct *p, unsigned long uptime)
183183
if (has_capability_noaudit(p, CAP_SYS_RAWIO))
184184
points /= 4;
185185

186-
/*
187-
* If p's nodes don't overlap ours, it may still help to kill p
188-
* because p may have allocated or otherwise mapped memory on
189-
* this node before. However it will be less likely.
190-
*/
191-
if (!has_intersects_mems_allowed(p))
192-
points /= 8;
193-
194186
/*
195187
* Adjust the score by oom_adj.
196188
*/
@@ -277,6 +269,8 @@ static struct task_struct *select_bad_process(unsigned long *ppoints,
277269
continue;
278270
if (mem && !task_in_mem_cgroup(p, mem))
279271
continue;
272+
if (!has_intersects_mems_allowed(p))
273+
continue;
280274

281275
/*
282276
* This task already has access to memory reserves and is

0 commit comments

Comments
 (0)