Commit 808c43b7 authored by Andrey Ignatov's avatar Andrey Ignatov Committed by Tejun Heo

cgroup: Simplify cgroup_ancestor

Simplify cgroup_ancestor function. This is follow-up for
commit 77236281 ("bpf: Introduce bpf_skb_ancestor_cgroup_id helper")
Suggested-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarAndrey Ignatov <rdna@fb.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 02214bfc
...@@ -567,20 +567,11 @@ static inline bool cgroup_is_descendant(struct cgroup *cgrp, ...@@ -567,20 +567,11 @@ static inline bool cgroup_is_descendant(struct cgroup *cgrp,
static inline struct cgroup *cgroup_ancestor(struct cgroup *cgrp, static inline struct cgroup *cgroup_ancestor(struct cgroup *cgrp,
int ancestor_level) int ancestor_level)
{ {
struct cgroup *ptr;
if (cgrp->level < ancestor_level) if (cgrp->level < ancestor_level)
return NULL; return NULL;
while (cgrp && cgrp->level > ancestor_level)
for (ptr = cgrp; cgrp = cgroup_parent(cgrp);
ptr && ptr->level > ancestor_level; return cgrp;
ptr = cgroup_parent(ptr))
;
if (ptr && ptr->level == ancestor_level)
return ptr;
return NULL;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment