aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-08-08 20:11:24 -0400
committerTejun Heo <tj@kernel.org>2013-08-08 20:11:24 -0400
commitf48e3924dca268c677c4e338e5d91ad9e6fe6b9e (patch)
tree8056aa4023c6a359851b27677560948835a59465
parent3b287a505ef4024634beb12a93773254909d5dae (diff)
cgroup: always use cgroup_next_child() to walk the children list
There are several places where the children list is accessed directly. This patch converts those places to use cgroup_next_child(). This will help updating the hierarchy iterators to use @css instead of @cgrp. While cgroup_next_child() can be heavy in pathological cases - e.g. a lot of dead children, this shouldn't cause any noticeable behavior differences. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com>
-rw-r--r--include/linux/cgroup.h5
-rw-r--r--kernel/cgroup.c7
2 files changed, 5 insertions, 7 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 5f9ba5881717..c288bce428f8 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -800,9 +800,8 @@ struct cgroup *cgroup_next_child(struct cgroup *pos, struct cgroup *cgrp);
800 * the start of the next iteration by, for example, bumping the css refcnt. 800 * the start of the next iteration by, for example, bumping the css refcnt.
801 */ 801 */
802#define cgroup_for_each_child(pos, cgrp) \ 802#define cgroup_for_each_child(pos, cgrp) \
803 for ((pos) = list_first_or_null_rcu(&(cgrp)->children, \ 803 for ((pos) = cgroup_next_child(NULL, (cgrp)); (pos); \
804 struct cgroup, sibling); \ 804 (pos) = cgroup_next_child((pos), (cgrp)))
805 (pos); (pos) = cgroup_next_child((pos), (cgrp)))
806 805
807struct cgroup *cgroup_next_descendant_pre(struct cgroup *pos, 806struct cgroup *cgroup_next_descendant_pre(struct cgroup *pos,
808 struct cgroup *cgroup); 807 struct cgroup *cgroup);
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index dd55244952bd..2b7354faaca7 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -3112,7 +3112,7 @@ struct cgroup *cgroup_next_descendant_pre(struct cgroup *pos,
3112 pos = cgroup; 3112 pos = cgroup;
3113 3113
3114 /* visit the first child if exists */ 3114 /* visit the first child if exists */
3115 next = list_first_or_null_rcu(&pos->children, struct cgroup, sibling); 3115 next = cgroup_next_child(NULL, pos);
3116 if (next) 3116 if (next)
3117 return next; 3117 return next;
3118 3118
@@ -3151,7 +3151,7 @@ struct cgroup *cgroup_rightmost_descendant(struct cgroup *pos)
3151 last = pos; 3151 last = pos;
3152 /* ->prev isn't RCU safe, walk ->next till the end */ 3152 /* ->prev isn't RCU safe, walk ->next till the end */
3153 pos = NULL; 3153 pos = NULL;
3154 list_for_each_entry_rcu(tmp, &last->children, sibling) 3154 cgroup_for_each_child(tmp, last)
3155 pos = tmp; 3155 pos = tmp;
3156 } while (pos); 3156 } while (pos);
3157 3157
@@ -3165,8 +3165,7 @@ static struct cgroup *cgroup_leftmost_descendant(struct cgroup *pos)
3165 3165
3166 do { 3166 do {
3167 last = pos; 3167 last = pos;
3168 pos = list_first_or_null_rcu(&pos->children, struct cgroup, 3168 pos = cgroup_next_child(NULL, pos);
3169 sibling);
3170 } while (pos); 3169 } while (pos);
3171 3170
3172 return last; 3171 return last;