aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2012-01-12 20:18:52 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-12 23:13:07 -0500
commitde077d222d5ca6108cab119a09593344c12100ab (patch)
treec59efc8b4fff063d2c318480881050b1913ed21b /mm
parentc3cecc683446ad54ca587d7123bd3ce94bd7b8e1 (diff)
oom, memcg: fix exclusion of memcg threads after they have detached their mm
The oom killer relies on logic that identifies threads that have already been oom killed when scanning the tasklist and, if found, deferring until such threads have exited. This is done by checking for any candidate threads that have the TIF_MEMDIE bit set. For memcg ooms, candidate threads are first found by calling task_in_mem_cgroup() since the oom killer should not defer if there's an oom killed thread in another memcg. Unfortunately, task_in_mem_cgroup() excludes threads if they have detached their mm in the process of exiting so TIF_MEMDIE is never detected for such conditions. This is different for global, mempolicy, and cpuset oom conditions where a detached mm is only excluded after checking for TIF_MEMDIE and deferring, if necessary, in select_bad_process(). The fix is to return true if a task has a detached mm but is still in the memcg or its hierarchy that is currently oom. This will allow the oom killer to appropriately defer rather than kill unnecessarily or, in the worst case, panic the machine if nothing else is available to kill. Signed-off-by: David Rientjes <rientjes@google.com> Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Balbir Singh <bsingharora@gmail.com> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Acked-by: Michal Hocko <mhocko@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memcontrol.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2a1f7847b6ad..7bc30707d0c6 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1238,10 +1238,21 @@ int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *memcg)
1238 struct task_struct *p; 1238 struct task_struct *p;
1239 1239
1240 p = find_lock_task_mm(task); 1240 p = find_lock_task_mm(task);
1241 if (!p) 1241 if (p) {
1242 return 0; 1242 curr = try_get_mem_cgroup_from_mm(p->mm);
1243 curr = try_get_mem_cgroup_from_mm(p->mm); 1243 task_unlock(p);
1244 task_unlock(p); 1244 } else {
1245 /*
1246 * All threads may have already detached their mm's, but the oom
1247 * killer still needs to detect if they have already been oom
1248 * killed to prevent needlessly killing additional tasks.
1249 */
1250 task_lock(task);
1251 curr = mem_cgroup_from_task(task);
1252 if (curr)
1253 css_get(&curr->css);
1254 task_unlock(task);
1255 }
1245 if (!curr) 1256 if (!curr)
1246 return 0; 1257 return 0;
1247 /* 1258 /*