Re: [PATCH 06/12] cgroups: Add res counter common ancestor searching

From: Frederic Weisbecker
Date: Fri Sep 09 2011 - 08:31:37 EST


On Tue, Sep 06, 2011 at 03:21:29PM -0700, Andrew Morton wrote:
> On Tue, 6 Sep 2011 02:13:00 +0200
> Frederic Weisbecker <fweisbec@xxxxxxxxx> wrote:
>
> > +struct res_counter *
> > +res_counter_common_ancestor(struct res_counter *r1, struct res_counter *r2)
> > +{
> > + struct res_counter *iter;
> > +
> > + while (r1) {
> > + iter = r2;
> > + while (iter) {
> > + if (iter == r1)
> > + return iter;
> > + iter = iter->parent;
> > + }
> > +
> > + r1 = r1->parent;
> > + }
> > +
> > + return NULL;
> > +}
>
> cgroup_mutex, one assumes?

No, a cgroup can't move to other parents, they remain stable
as long as they have children (if I understood correctly).
So this mirrors to res_counters.

In fact res counters is just a library, pretty much like
lists, except they are only used by cgroups for now, so it's up
to the caller to guarantee the stability of its objects.

But yeah the documentation for this function is missing. I'm
adding some comments in the file.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/