From patchwork Mon Aug 29 14:05:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 1108222 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 p7TEAhe6009709 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Mon, 29 Aug 2011 14:11:03 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 p7TE8a0q015487; Mon, 29 Aug 2011 07:08:36 -0700 Received: from mail-fx0-f47.google.com (mail-fx0-f47.google.com [209.85.161.47]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p7TE4Rq2015073 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL); Mon, 29 Aug 2011 07:05:54 -0700 Received: by mail-fx0-f47.google.com with SMTP id 11so4605036fxg.6 for ; Mon, 29 Aug 2011 07:05:54 -0700 (PDT) Received: by 10.223.54.66 with SMTP id p2mr3930810fag.143.1314626754335; Mon, 29 Aug 2011 07:05:54 -0700 (PDT) Received: from mtj.dyndns.org ([89.204.138.129]) by mx.google.com with ESMTPS id c5sm3780975fai.44.2011.08.29.07.05.52 (version=SSLv3 cipher=OTHER); Mon, 29 Aug 2011 07:05:53 -0700 (PDT) Date: Mon, 29 Aug 2011 16:05:49 +0200 From: Tejun Heo To: "Rafael J. Wysocki" , Oleg Nesterov , Paul Menage Message-ID: <20110829140549.GD18871@mtj.dyndns.org> References: <20110829140418.GB18871@mtj.dyndns.org> <20110829140509.GC18871@mtj.dyndns.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110829140509.GC18871@mtj.dyndns.org> User-Agent: Mutt/1.5.21 (2010-09-15) Received-SPF: pass (localhost is always allowed.) X-Spam-Status: No, hits=-4.268 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 3/4] freezer: check freezing() before leaving FROZEN 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]); Mon, 29 Aug 2011 14:11:03 +0000 (UTC) If another freeze happens before all tasks leave FROZEN state after being thawed, the freezer can see the existing FROZEN and consider the tasks to be frozen but they can clear FROZEN without checking the new freezing(). Check freezing() while holding freezer_lock before clearing FROZEN. Signed-off-by: Tejun Heo Reported-by: Oleg Nesterov Cc: "Rafael J. Wysocki" --- kernel/freezer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) Index: work/kernel/freezer.c =================================================================== --- work.orig/kernel/freezer.c +++ work/kernel/freezer.c @@ -60,6 +60,7 @@ bool __refrigerator(bool check_kthr_stop */ spin_lock_irq(&freezer_lock); current->flags |= PF_FROZEN; +refreeze: spin_unlock_irq(&freezer_lock); save = current->state; @@ -78,8 +79,10 @@ bool __refrigerator(bool check_kthr_stop schedule(); } - /* leave FROZEN */ + /* leave FROZEN after checking freezing() holding freezer_lock */ spin_lock_irq(&freezer_lock); + if (freezing(current)) + goto refreeze; current->flags &= ~PF_FROZEN; spin_unlock_irq(&freezer_lock);