Commit 3a981f482cc29f7d0aeab509e51ea15519a6e961

Authored by Hugh Dickins
Committed by Linus Torvalds
1 parent 61eafb00d5

memcg: fix use_hierarchy css_is_ancestor oops regression

If use_hierarchy is set, reclaim testing soon oopses in css_is_ancestor()
called from __mem_cgroup_same_or_subtree() called from page_referenced():
when processes are exiting, it's easy for mm_match_cgroup() to pass along
a NULL memcg coming from a NULL mm->owner.

Check for that in __mem_cgroup_same_or_subtree().  Return true or false?
False because we cannot know if it was in the hierarchy, but also false
because it's better not to count a reference from an exiting process.

Signed-off-by: Hugh Dickins <hughd@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
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>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

... ... @@ -1148,7 +1148,7 @@
1148 1148 {
1149 1149 if (root_memcg == memcg)
1150 1150 return true;
1151   - if (!root_memcg->use_hierarchy)
  1151 + if (!root_memcg->use_hierarchy || !memcg)
1152 1152 return false;
1153 1153 return css_is_ancestor(&memcg->css, &root_memcg->css);
1154 1154 }