UPSTREAM: cgroup: Simplify cgroup_ancestor

Simplify cgroup_ancestor function. This is follow-up for
commit 7723628101 ("bpf: Introduce bpf_skb_ancestor_cgroup_id helper")

Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrey Ignatov <rdna@fb.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

Bug: 154548692
Signed-off-by: Marco Ballesio <balejs@google.com>
(cherry picked from commit 808c43b7c7f70360ed7b9e43e2cf980f388e71fa)
Change-Id: I246d9ab057805abd0fa54ed1c23a15c0c2caf552
This commit is contained in:
Andrey Ignatov 2018-09-21 17:03:27 -07:00 committed by Marco Ballesio
parent 599bf02de4
commit 0e00bb1cf7

View file

@ -581,20 +581,11 @@ static inline bool cgroup_is_descendant(struct cgroup *cgrp,
static inline struct cgroup *cgroup_ancestor(struct cgroup *cgrp,
int ancestor_level)
{
struct cgroup *ptr;
if (cgrp->level < ancestor_level)
return NULL;
for (ptr = cgrp;
ptr && ptr->level > ancestor_level;
ptr = cgroup_parent(ptr))
;
if (ptr && ptr->level == ancestor_level)
return ptr;
return NULL;
while (cgrp && cgrp->level > ancestor_level)
cgrp = cgroup_parent(cgrp);
return cgrp;
}
/**