Skip to content

Commit

Permalink
cgroup: Simplify cgroup_ancestor
Browse files Browse the repository at this point in the history
Simplify cgroup_ancestor function. This is follow-up for
commit 7723628 ("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>
  • Loading branch information
Andrey Ignatov authored and Tejun Heo committed Sep 24, 2018
1 parent 02214bf commit 808c43b
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions include/linux/cgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -567,20 +567,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;
}

/**
Expand Down

0 comments on commit 808c43b

Please sign in to comment.