cgroup: Simplify cgroup_ancestor
Simplify cgroup_ancestor function. This is follow-up for
commit 7723628101aa ("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>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
This commit is contained in:
parent
037bcd6574
commit
0526640b1d
1 changed files with 3 additions and 12 deletions
|
|
@ -577,20 +577,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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue