cgroup: update iterators to use cgroup_next_sibling()
authorTejun Heo <tj@kernel.org>
Fri, 24 May 2013 01:55:38 +0000 (10:55 +0900)
committerTejun Heo <tj@kernel.org>
Fri, 24 May 2013 01:55:38 +0000 (10:55 +0900)
commit75501a6d59e989e5c286716e5b3b66ace4660e83
tree087af4f93bba2257ae139c5e4a0f3b850954ed81
parent53fa5261747a90746531e8a1c81eeb78fedc2f71
cgroup: update iterators to use cgroup_next_sibling()

This patch converts cgroup_for_each_child(),
cgroup_next_descendant_pre/post() and thus
cgroup_for_each_descendant_pre/post() to use cgroup_next_sibling()
instead of manually dereferencing ->sibling.next.

The only reason the iterators couldn't allow dropping RCU read lock
while iteration is in progress was because they couldn't determine the
next sibling safely once RCU read lock is dropped.  Using
cgroup_next_sibling() removes that problem and enables all iterators
to allow dropping RCU read lock in the middle.  Comments are updated
accordingly.

This makes the iterators easier to use and will simplify controllers.

Note that @cgroup argument is renamed to @cgrp in
cgroup_for_each_child() because it conflicts with "struct cgroup" used
in the new macro body.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Reviewed-by: Michal Hocko <mhocko@suse.cz>
include/linux/cgroup.h
kernel/cgroup.c