From: David Rientjes Date: Tue, 10 Aug 2010 00:18:50 +0000 (-0700) Subject: oom: filter tasks not sharing the same cpuset X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6cf86ac6f36b638459a9a6c2576d5e655d41d451;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git 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 Acked-by: Rik van Riel Acked-by: Nick Piggin Acked-by: Balbir Singh Cc: KOSAKI Motohiro Reviewed-by: KAMEZAWA Hiroyuki Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 0c7c18f78425..6f6e04c40c93 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -183,14 +183,6 @@ unsigned long badness(struct task_struct *p, unsigned long uptime) if (has_capability_noaudit(p, CAP_SYS_RAWIO)) points /= 4; - /* - * If p's nodes don't overlap ours, it may still help to kill p - * because p may have allocated or otherwise mapped memory on - * this node before. However it will be less likely. - */ - if (!has_intersects_mems_allowed(p)) - points /= 8; - /* * Adjust the score by oom_adj. */ @@ -277,6 +269,8 @@ static struct task_struct *select_bad_process(unsigned long *ppoints, continue; if (mem && !task_in_mem_cgroup(p, mem)) continue; + if (!has_intersects_mems_allowed(p)) + continue; /* * This task already has access to memory reserves and is