提交 ce48225f 编写于 作者: H Hugh Dickins 提交者: Linus Torvalds

memcg: fix endless loop in __mem_cgroup_iter_next()

Commit 0eef6156 ("memcg: fix css reference leak and endless loop in
mem_cgroup_iter") got the interaction with the commit a few before it
d8ad3055 ("mm/memcg: iteration skip memcgs not yet fully
initialized") slightly wrong, and we didn't notice at the time.

It's elusive, and harder to get than the original, but for a couple of
days before rc1, I several times saw a endless loop similar to that
supposedly being fixed.

This time it was a tighter loop in __mem_cgroup_iter_next(): because we
can get here when our root has already been offlined, and the ordering
of conditions was such that we then just cycled around forever.

Fixes: 0eef6156 ("memcg: fix css reference leak and endless loop in mem_cgroup_iter").
Signed-off-by: NHugh Dickins <hughd@google.com>
Acked-by: NMichal Hocko <mhocko@suse.cz>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Greg Thelen <gthelen@google.com>
Cc: <stable@vger.kernel.org>	[3.12+]
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 5f30fc94
...@@ -1127,8 +1127,8 @@ static struct mem_cgroup *__mem_cgroup_iter_next(struct mem_cgroup *root, ...@@ -1127,8 +1127,8 @@ static struct mem_cgroup *__mem_cgroup_iter_next(struct mem_cgroup *root,
* skipping css reference should be safe. * skipping css reference should be safe.
*/ */
if (next_css) { if (next_css) {
if ((next_css->flags & CSS_ONLINE) && if ((next_css == &root->css) ||
(next_css == &root->css || css_tryget(next_css))) ((next_css->flags & CSS_ONLINE) && css_tryget(next_css)))
return mem_cgroup_from_css(next_css); return mem_cgroup_from_css(next_css);
prev_css = next_css; prev_css = next_css;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册