From patchwork Wed Aug 31 10:21:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 1120602 Received: from smtp1.linux-foundation.org (smtp1.linux-foundation.org [140.211.169.13]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p81KjkZZ021083 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Thu, 1 Sep 2011 20:46:06 GMT Received: from daredevil.linux-foundation.org (localhost [127.0.0.1]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p81Kgw97020766; Thu, 1 Sep 2011 13:43:48 -0700 Received: from mail-ey0-f169.google.com (mail-ey0-f169.google.com [209.85.215.169]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p7VALFTv009108 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL); Wed, 31 Aug 2011 03:21:18 -0700 Received: by eye22 with SMTP id 22so527646eye.0 for ; Wed, 31 Aug 2011 03:21:15 -0700 (PDT) Received: by 10.213.28.143 with SMTP id m15mr167005ebc.40.1314786075240; Wed, 31 Aug 2011 03:21:15 -0700 (PDT) Received: from mtj.dyndns.org (apc01.spektrum-hotspot.de [212.77.232.233]) by mx.google.com with ESMTPS id y9sm4259961eeh.13.2011.08.31.03.21.12 (version=SSLv3 cipher=OTHER); Wed, 31 Aug 2011 03:21:14 -0700 (PDT) Date: Wed, 31 Aug 2011 12:21:07 +0200 From: Tejun Heo To: "Rafael J. Wysocki" , Oleg Nesterov , Paul Menage Message-ID: <20110831102100.GA2828@mtj.dyndns.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Received-SPF: pass (domain of htejun@gmail.com designates 209.85.215.169 as permitted sender) X-Spam-Status: No, hits=-3.812 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SPF_PASS, OSDL_HEADER_SUBJECT_BRACKETED X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.21 Cc: containers@lists.linux-foundation.org, linux-pm@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [linux-pm] [PATCH pm-freezer 1/4] cgroup_freezer: fix freezer->state setting bug in freezer_change_state() X-BeenThere: linux-pm@lists.linux-foundation.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux power management List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 01 Sep 2011 20:46:31 +0000 (UTC) d02f52811d0e "cgroup_freezer: prepare for removal of TIF_FREEZE" moved setting of freezer->state into freezer_change_state(); unfortunately, while doing so, when it's beginning to freeze tasks, it sets the state to CGROUP_FROZEN instead of CGROUP_FREEZING ending up skipping the whole freezing state. Fix it. -v2: Oleg pointed out that re-freezing FROZEN cgroup could increment system_freezing_cnt. Fixed. Signed-off-by: Tejun Heo Reported-by: Oleg Nesterov Cc: Paul Menage Cc: "Rafael J. Wysocki" --- I'm in the process of moving and can only use a quite old laptop. I tested compile but couldn't really do much else, so please proceed with caution. Oleg, can you please ack the patches if you agree with the updated versions? Thanks. kernel/cgroup_freezer.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) Index: work/kernel/cgroup_freezer.c =================================================================== --- work.orig/kernel/cgroup_freezer.c +++ work/kernel/cgroup_freezer.c @@ -308,24 +308,26 @@ static int freezer_change_state(struct c spin_lock_irq(&freezer->lock); update_if_frozen(cgroup, freezer); - if (goal_state == freezer->state) - goto out; - - freezer->state = goal_state; switch (goal_state) { case CGROUP_THAWED: - atomic_dec(&system_freezing_cnt); - unfreeze_cgroup(cgroup, freezer); + if (freezer->state != CGROUP_THAWED) { + freezer->state = CGROUP_THAWED; + atomic_dec(&system_freezing_cnt); + unfreeze_cgroup(cgroup, freezer); + } break; case CGROUP_FROZEN: - atomic_inc(&system_freezing_cnt); - retval = try_to_freeze_cgroup(cgroup, freezer); + if (freezer->state == CGROUP_THAWED) { + freezer->state = CGROUP_FREEZING; + atomic_inc(&system_freezing_cnt); + retval = try_to_freeze_cgroup(cgroup, freezer); + } break; default: BUG(); } -out: + spin_unlock_irq(&freezer->lock); return retval;