Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754677Ab2KGLBE (ORCPT ); Wed, 7 Nov 2012 06:01:04 -0500 Received: from cantor2.suse.de ([195.135.220.15]:59522 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754285Ab2KGLBB (ORCPT ); Wed, 7 Nov 2012 06:01:01 -0500 Date: Wed, 7 Nov 2012 12:00:57 +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 9/9] cgroup_freezer: implement proper hierarchy support Message-ID: <20121107110024.GA4143@dhcp22.suse.cz> References: <1351931915-1701-1-git-send-email-tj@kernel.org> <1351931915-1701-10-git-send-email-tj@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1351931915-1701-10-git-send-email-tj@kernel.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: 2167 Lines: 61 On Sat 03-11-12 01:38:35, Tejun Heo wrote: [...] > diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c > index 4f12d31..3262537 100644 > --- a/kernel/cgroup_freezer.c > +++ b/kernel/cgroup_freezer.c [...] > @@ -320,14 +388,39 @@ static void freezer_apply_state(struct freezer *freezer, bool freeze, > * @freezer: freezer of interest > * @freeze: whether to freeze or thaw > * > - * Freeze or thaw @cgroup according to @freeze. > + * Freeze or thaw @freezer according to @freeze. The operations are > + * recursive - all descendants of @freezer will be affected. > */ > static void freezer_change_state(struct freezer *freezer, bool freeze) > { > + struct cgroup *pos; > + > /* update @freezer */ > spin_lock_irq(&freezer->lock); > freezer_apply_state(freezer, freeze, CGROUP_FREEZING_SELF); > spin_unlock_irq(&freezer->lock); > + > + /* > + * Update all its descendants in pre-order traversal. Each > + * descendant will try to inherit its parent's FREEZING state as > + * CGROUP_FREEZING_PARENT. > + */ > + rcu_read_lock(); > + cgroup_for_each_descendant_pre(pos, freezer->css.cgroup) { > + struct freezer *pos_f = cgroup_freezer(pos); > + struct freezer *parent = parent_freezer(freezer); This doesn't seem right. Why are we interested in freezer->parent here at all? We should either care about freezer->state & CGROUP_FREEZING or parent = parent_freezer(pos_f), right? > + > + /* > + * Our update to @parent->state is already visible which is > + * all we need. No need to lock @parent. For more info on > + * synchronization, see freezer_post_create(). > + */ > + spin_lock_irq(&pos_f->lock); > + freezer_apply_state(pos_f, parent->state & CGROUP_FREEZING, > + CGROUP_FREEZING_PARENT); > + spin_unlock_irq(&pos_f->lock); > + } > + rcu_read_unlock(); > } > > static int freezer_write(struct cgroup *cgroup, struct cftype *cft, -- 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/