diff options
Diffstat (limited to 'extras/recipes-kernel/linux/linux-omap/linus/0036-memcg-fix-wrong-VM_BUG_ON-in-try_charge-s-mm-owner-c.patch')
-rw-r--r-- | extras/recipes-kernel/linux/linux-omap/linus/0036-memcg-fix-wrong-VM_BUG_ON-in-try_charge-s-mm-owner-c.patch | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/extras/recipes-kernel/linux/linux-omap/linus/0036-memcg-fix-wrong-VM_BUG_ON-in-try_charge-s-mm-owner-c.patch b/extras/recipes-kernel/linux/linux-omap/linus/0036-memcg-fix-wrong-VM_BUG_ON-in-try_charge-s-mm-owner-c.patch new file mode 100644 index 00000000..cbdc9bea --- /dev/null +++ b/extras/recipes-kernel/linux/linux-omap/linus/0036-memcg-fix-wrong-VM_BUG_ON-in-try_charge-s-mm-owner-c.patch | |||
@@ -0,0 +1,63 @@ | |||
1 | From 06410121f430702f9f482331a1f6d9ba3ebe5911 Mon Sep 17 00:00:00 2001 | ||
2 | From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> | ||
3 | Date: Wed, 29 Dec 2010 14:07:11 -0800 | ||
4 | Subject: [PATCH 36/65] memcg: fix wrong VM_BUG_ON() in try_charge()'s mm->owner check | ||
5 | |||
6 | At __mem_cgroup_try_charge(), VM_BUG_ON(!mm->owner) is checked. | ||
7 | But as commented in mem_cgroup_from_task(), mm->owner can be NULL | ||
8 | in some racy case. This check of VM_BUG_ON() is bad. | ||
9 | |||
10 | A possible story to hit this is at swapoff()->try_to_unuse(). It passes | ||
11 | mm_struct to mem_cgroup_try_charge_swapin() while mm->owner is NULL. If we | ||
12 | can't get proper mem_cgroup from swap_cgroup information, mm->owner is used | ||
13 | as charge target and we see NULL. | ||
14 | |||
15 | Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> | ||
16 | Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> | ||
17 | Reported-by: Hugh Dickins <hughd@google.com> | ||
18 | Reported-by: Thomas Meyer <thomas@m3y3r.de> | ||
19 | Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> | ||
20 | Reviewed-by: Balbir Singh <balbir@linux.vnet.ibm.com> | ||
21 | Signed-off-by: Hugh Dickins <hughd@google.com> | ||
22 | Cc: stable@kernel.org | ||
23 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | ||
24 | --- | ||
25 | mm/memcontrol.c | 19 +++++++++---------- | ||
26 | 1 files changed, 9 insertions(+), 10 deletions(-) | ||
27 | |||
28 | diff --git a/mm/memcontrol.c b/mm/memcontrol.c | ||
29 | index 7a22b41..00bb8a6 100644 | ||
30 | --- a/mm/memcontrol.c | ||
31 | +++ b/mm/memcontrol.c | ||
32 | @@ -1925,19 +1925,18 @@ again: | ||
33 | |||
34 | rcu_read_lock(); | ||
35 | p = rcu_dereference(mm->owner); | ||
36 | - VM_BUG_ON(!p); | ||
37 | /* | ||
38 | - * because we don't have task_lock(), "p" can exit while | ||
39 | - * we're here. In that case, "mem" can point to root | ||
40 | - * cgroup but never be NULL. (and task_struct itself is freed | ||
41 | - * by RCU, cgroup itself is RCU safe.) Then, we have small | ||
42 | - * risk here to get wrong cgroup. But such kind of mis-account | ||
43 | - * by race always happens because we don't have cgroup_mutex(). | ||
44 | - * It's overkill and we allow that small race, here. | ||
45 | + * Because we don't have task_lock(), "p" can exit. | ||
46 | + * In that case, "mem" can point to root or p can be NULL with | ||
47 | + * race with swapoff. Then, we have small risk of mis-accouning. | ||
48 | + * But such kind of mis-account by race always happens because | ||
49 | + * we don't have cgroup_mutex(). It's overkill and we allo that | ||
50 | + * small race, here. | ||
51 | + * (*) swapoff at el will charge against mm-struct not against | ||
52 | + * task-struct. So, mm->owner can be NULL. | ||
53 | */ | ||
54 | mem = mem_cgroup_from_task(p); | ||
55 | - VM_BUG_ON(!mem); | ||
56 | - if (mem_cgroup_is_root(mem)) { | ||
57 | + if (!mem || mem_cgroup_is_root(mem)) { | ||
58 | rcu_read_unlock(); | ||
59 | goto done; | ||
60 | } | ||
61 | -- | ||
62 | 1.6.6.1 | ||
63 | |||