mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
cgroup: Replace cgroup->ancestor_ids[] with ->ancestors[]
Every cgroup knows all its ancestors through its ->ancestor_ids[]. There's no advantage to remembering the IDs instead of the pointers directly and this makes the array useless for finding an actual ancestor cgroup forcing cgroup_ancestor() to iteratively walk up the hierarchy instead. Let's replace cgroup->ancestor_ids[] with ->ancestors[] and remove the walking-up from cgroup_ancestor(). While at it, improve comments around cgroup_root->cgrp_ancestor_storage. This patch shouldn't cause user-visible behavior differences. v2: Update cgroup_ancestor() to use ->ancestors[]. v3: cgroup_root->cgrp_ancestor_storage's type is updated to match cgroup->ancestors[]. Better comments. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
@@ -574,7 +574,7 @@ static inline bool cgroup_is_descendant(struct cgroup *cgrp,
|
||||
{
|
||||
if (cgrp->root != ancestor->root || cgrp->level < ancestor->level)
|
||||
return false;
|
||||
return cgrp->ancestor_ids[ancestor->level] == cgroup_id(ancestor);
|
||||
return cgrp->ancestors[ancestor->level] == ancestor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -591,11 +591,9 @@ static inline bool cgroup_is_descendant(struct cgroup *cgrp,
|
||||
static inline struct cgroup *cgroup_ancestor(struct cgroup *cgrp,
|
||||
int ancestor_level)
|
||||
{
|
||||
if (cgrp->level < ancestor_level)
|
||||
if (ancestor_level < 0 || ancestor_level > cgrp->level)
|
||||
return NULL;
|
||||
while (cgrp && cgrp->level > ancestor_level)
|
||||
cgrp = cgroup_parent(cgrp);
|
||||
return cgrp;
|
||||
return cgrp->ancestors[ancestor_level];
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user