]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
memcg: use find_lock_task_mm() in memory cgroups oom
authorKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Wed, 11 Aug 2010 01:03:00 +0000 (18:03 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 11 Aug 2010 15:59:19 +0000 (08:59 -0700)
When the OOM killer scans task, it check a task is under memcg or
not when it's called via memcg's context.

But, as Oleg pointed out, a thread group leader may have NULL ->mm
and task_in_mem_cgroup() may do wrong decision. We have to use
find_lock_task_mm() in memcg as generic OOM-Killer does.

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
Reviewed-by: Minchan Kim <minchan.kim@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/oom.h
mm/memcontrol.c
mm/oom_kill.c

index f209b683e118a8f0966ce737217da561149cae67..5e3aa8311c5ed40f2598ccd814162bef5173030e 100644 (file)
@@ -66,6 +66,8 @@ static inline void oom_killer_enable(void)
 extern unsigned long badness(struct task_struct *p, struct mem_cgroup *mem,
                      const nodemask_t *nodemask, unsigned long uptime);
 
+extern struct task_struct *find_lock_task_mm(struct task_struct *p);
+
 /* sysctls */
 extern int sysctl_oom_dump_tasks;
 extern int sysctl_oom_kill_allocating_task;
index ea5f5edf00b79a16f9977e5a5f4172a31be74bff..f52b0a1861c4624b7e99879e4aa538872604c0ac 100644 (file)
@@ -47,6 +47,7 @@
 #include <linux/mm_inline.h>
 #include <linux/page_cgroup.h>
 #include <linux/cpu.h>
+#include <linux/oom.h>
 #include "internal.h"
 
 #include <asm/uaccess.h>
@@ -838,10 +839,13 @@ int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem)
 {
        int ret;
        struct mem_cgroup *curr = NULL;
+       struct task_struct *p;
 
-       task_lock(task);
-       curr = try_get_mem_cgroup_from_mm(task->mm);
-       task_unlock(task);
+       p = find_lock_task_mm(task);
+       if (!p)
+               return 0;
+       curr = try_get_mem_cgroup_from_mm(p->mm);
+       task_unlock(p);
        if (!curr)
                return 0;
        /*
index d3def05a33d99f6699e6dd6ea9472e6e7da54443..5014e50644d1b7528a06fca742677cf1a77cc04f 100644 (file)
@@ -106,7 +106,7 @@ static void boost_dying_task_prio(struct task_struct *p,
  * pointer.  Return p, or any of its subthreads with a valid ->mm, with
  * task_lock() held.
  */
-static struct task_struct *find_lock_task_mm(struct task_struct *p)
+struct task_struct *find_lock_task_mm(struct task_struct *p)
 {
        struct task_struct *t = p;