summaryrefslogtreecommitdiff
path: root/include/linux/cgroup.h
diff options
context:
space:
mode:
authorAndrey Ignatov <rdna@fb.com>2018-09-21 17:03:27 -0700
committerTejun Heo <tj@kernel.org>2018-09-24 10:38:16 -0700
commit808c43b7c7f70360ed7b9e43e2cf980f388e71fa (patch)
treeac8a47eb5ec5c786815ddc4c46e7087bfe073ea6 /include/linux/cgroup.h
parent02214bfc89c71bcc5167f653994cfa5c57f10ff1 (diff)
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>
Diffstat (limited to 'include/linux/cgroup.h')
-rw-r--r--include/linux/cgroup.h15
1 files changed, 3 insertions, 12 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 32c553556bbd..e03a92430383 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -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;
}
/**