Tejun Heo <t...@kernel.org> [Mon, 2018-08-13 07:47 -0700]:
> Hello, Andrey.

Hey Tejun!

> On Fri, Aug 10, 2018 at 10:35:23PM -0700, Andrey Ignatov wrote:
> > +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;
> > +}
> 
> I don't have any objections functionanlity-wise but can we do sth like
> the following instead?
> 
> static inline struct cgroup *cgroup_ancestor(struct cgroup *cgrp,
>                                            int ancestor_level)
> {
>       if (cgrp->level < ancestor_level)
>               return NULL;
> 
>       while (cgrp->level > ancestor_level)
>               cgrp = cgroup_parent(cgrp);
>       return cgrp;
> }

Sure, no problem. I'll send follow-up patch to simplify this part when
bpf-next is open again.

> 
> Thanks.
> 
> -- 
> tejun

-- 
Andrey Ignatov

Reply via email to