diff options
author | Hugh Dickins <hughd@google.com> | 2014-01-23 18:53:32 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-23 19:36:53 -0500 |
commit | d8ad30559715ce97afb7d1a93a12fd90e8fff312 (patch) | |
tree | de34c8716415741701e60981b89cfeb2aef114da /mm/memcontrol.c | |
parent | d2ab70aaae74456ed608740915dc82ef52291f69 (diff) |
mm/memcg: iteration skip memcgs not yet fully initialized
It is surprising that the mem_cgroup iterator can return memcgs which
have not yet been fully initialized. By accident (or trial and error?)
this appears not to present an actual problem; but it may be better to
prevent such surprises, by skipping memcgs not yet online.
Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: Tejun Heo <tj@kernel.org>
Acked-by: Michal Hocko <mhocko@suse.cz>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: <stable@vger.kernel.org> [3.12+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index aa66cc4c9e79..9537e1389ee6 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -1119,10 +1119,8 @@ skip_node: | |||
1119 | * protected by css_get and the tree walk is rcu safe. | 1119 | * protected by css_get and the tree walk is rcu safe. |
1120 | */ | 1120 | */ |
1121 | if (next_css) { | 1121 | if (next_css) { |
1122 | struct mem_cgroup *mem = mem_cgroup_from_css(next_css); | 1122 | if ((next_css->flags & CSS_ONLINE) && css_tryget(next_css)) |
1123 | 1123 | return mem_cgroup_from_css(next_css); | |
1124 | if (css_tryget(&mem->css)) | ||
1125 | return mem; | ||
1126 | else { | 1124 | else { |
1127 | prev_css = next_css; | 1125 | prev_css = next_css; |
1128 | goto skip_node; | 1126 | goto skip_node; |