|
@@ -2954,11 +2954,8 @@ struct cgroup *cgroup_next_descendant_pre(struct cgroup *pos,
|
|
|
WARN_ON_ONCE(!rcu_read_lock_held());
|
|
|
|
|
|
/* if first iteration, pretend we just visited @cgroup */
|
|
|
- if (!pos) {
|
|
|
- if (list_empty(&cgroup->children))
|
|
|
- return NULL;
|
|
|
+ if (!pos)
|
|
|
pos = cgroup;
|
|
|
- }
|
|
|
|
|
|
/* visit the first child if exists */
|
|
|
next = list_first_or_null_rcu(&pos->children, struct cgroup, sibling);
|
|
@@ -2966,14 +2963,14 @@ struct cgroup *cgroup_next_descendant_pre(struct cgroup *pos,
|
|
|
return next;
|
|
|
|
|
|
/* no child, visit my or the closest ancestor's next sibling */
|
|
|
- do {
|
|
|
+ while (pos != cgroup) {
|
|
|
next = list_entry_rcu(pos->sibling.next, struct cgroup,
|
|
|
sibling);
|
|
|
if (&next->sibling != &pos->parent->children)
|
|
|
return next;
|
|
|
|
|
|
pos = pos->parent;
|
|
|
- } while (pos != cgroup);
|
|
|
+ }
|
|
|
|
|
|
return NULL;
|
|
|
}
|