lkml.org 
[lkml]   [2012]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/9] cgroup: implement generic child / descendant walk macros
On Wed 07-11-12 09:01:18, Tejun Heo wrote:
> Hello, Michal.
>
> On Wed, Nov 07, 2012 at 05:54:57PM +0100, Michal Hocko wrote:
> > > +struct cgroup *cgroup_next_descendant_pre(struct cgroup *pos,
> > > + struct cgroup *cgroup)
> > > +{
> > > + struct cgroup *next;
> > > +
> > > + WARN_ON_ONCE(!rcu_read_lock_held());
> > > +
> > > + /* if first iteration, pretend we just visited @cgroup */
> > > + if (!pos) {
> > > + if (list_empty(&cgroup->children))
> > > + return NULL;
> > > + pos = cgroup;
> > > + }
> >
> > Is there any specific reason why the root of the tree is excluded?
> > This is bit impractical because you have to special case the root
> > in the code.
>
> Yeah, thought about including it but decided against it for two
> reasons.
>
> * To be consistent with cgroup_for_each_children() - it's a bit weird
> for descendants to include self when children don't.
>
> * Iteration root is likely to require different treatment anyway.
> e.g. for cgroup_freezer, the root is updated to the specified config
> while all the descendants inherit config from its immediate parent.
> They are different.

OK if there is a code which handles root differently then let's not
overcomplicate this. The naming should be clear that root needs a
special treatment.

I will continue with the review tomorrow.
--
Michal Hocko
SUSE Labs


\
 
 \ /
  Last update: 2012-11-07 19:41    [W:0.339 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site