Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753274Ab2KGRuF (ORCPT ); Wed, 7 Nov 2012 12:50:05 -0500 Received: from mail-ea0-f174.google.com ([209.85.215.174]:47358 "EHLO mail-ea0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751955Ab2KGRuB (ORCPT ); Wed, 7 Nov 2012 12:50:01 -0500 Date: Wed, 7 Nov 2012 18:49:58 +0100 From: Michal Hocko To: Tejun Heo Cc: lizefan@huawei.com, rjw@sisk.pl, containers@lists.linux-foundation.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, fweisbec@gmail.com Subject: Re: [PATCH 3/9] cgroup: implement generic child / descendant walk macros Message-ID: <20121107174958.GB24475@dhcp22.suse.cz> References: <1351931915-1701-1-git-send-email-tj@kernel.org> <1351931915-1701-4-git-send-email-tj@kernel.org> <20121107165457.GD4131@dhcp22.suse.cz> <20121107170118.GD2660@mtj.dyndns.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121107170118.GD2660@mtj.dyndns.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1602 Lines: 46 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/