Skip to content

Commit

Permalink
memcg: fix endless loop in __mem_cgroup_iter_next()
Browse files Browse the repository at this point in the history
Commit 0eef615 ("memcg: fix css reference leak and endless loop in
mem_cgroup_iter") got the interaction with the commit a few before it
d8ad305 ("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: 0eef615 ("memcg: fix css reference leak and endless loop in mem_cgroup_iter").
Signed-off-by: Hugh Dickins <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Greg Thelen <[email protected]>
Cc: <[email protected]>	[3.12+]
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Hugh Dickins authored and torvalds committed Mar 4, 2014
1 parent 5f30fc9 commit ce48225
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1127,8 +1127,8 @@ static struct mem_cgroup *__mem_cgroup_iter_next(struct mem_cgroup *root,
* skipping css reference should be safe.
*/
if (next_css) {
if ((next_css->flags & CSS_ONLINE) &&
(next_css == &root->css || css_tryget(next_css)))
if ((next_css == &root->css) ||
((next_css->flags & CSS_ONLINE) && css_tryget(next_css)))
return mem_cgroup_from_css(next_css);

prev_css = next_css;
Expand Down

0 comments on commit ce48225

Please sign in to comment.