Skip to content
  • Tejun Heo's avatar
    cgroup: record ancestor IDs and reimplement cgroup_is_descendant() using it · b11cfb58
    Tejun Heo authored
    
    
    cgroup_is_descendant() currently walks up the hierarchy and compares
    each ancestor to the cgroup in question.  While enough for cgroup core
    usages, this can't be used in hot paths to test cgroup membership.
    This patch adds cgroup->ancestor_ids[] which records the IDs of all
    ancestors including self and cgroup->level for the nesting level.
    
    This allows testing whether a given cgroup is a descendant of another
    in three finite steps - testing whether the two belong to the same
    hierarchy, whether the descendant candidate is at the same or a higher
    level than the ancestor and comparing the recorded ancestor_id at the
    matching level.  cgroup_is_descendant() is accordingly reimplmented
    and made inline.
    
    Signed-off-by: default avatarTejun Heo <tj@kernel.org>
    b11cfb58