From patchwork Wed Aug 31 10:21:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 1120622 Received: from smtp1.linux-foundation.org (smtp1.linux-foundation.org [140.211.169.13]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p81KsCJi002754 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Thu, 1 Sep 2011 20:54:33 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 p81KovOp022601; Thu, 1 Sep 2011 13:51:43 -0700 Received: from mail-ew0-f47.google.com (mail-ew0-f47.google.com [209.85.215.47]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p7VALoZR009158 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL); Wed, 31 Aug 2011 03:21:53 -0700 Received: by ewy5 with SMTP id 5so279927ewy.6 for ; Wed, 31 Aug 2011 03:21:50 -0700 (PDT) Received: by 10.213.9.209 with SMTP id m17mr140057ebm.113.1314786110473; Wed, 31 Aug 2011 03:21:50 -0700 (PDT) Received: from mtj.dyndns.org (apc01.spektrum-hotspot.de [212.77.232.233]) by mx.google.com with ESMTPS id b49sm2239688eei.54.2011.08.31.03.21.49 (version=SSLv3 cipher=OTHER); Wed, 31 Aug 2011 03:21:49 -0700 (PDT) Date: Wed, 31 Aug 2011 12:21:43 +0200 From: Tejun Heo To: "Rafael J. Wysocki" , Oleg Nesterov , Paul Menage Message-ID: <20110831102143.GB2828@mtj.dyndns.org> References: <20110831102100.GA2828@mtj.dyndns.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110831102100.GA2828@mtj.dyndns.org> User-Agent: Mutt/1.5.21 (2010-09-15) Received-SPF: pass (domain of htejun@gmail.com designates 209.85.215.47 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 2/4] freezer: set PF_NOFREEZE on a dying task right before TASK_DEAD 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 (demeter2.kernel.org [140.211.167.43]); Thu, 01 Sep 2011 20:54:33 +0000 (UTC) 3fb45733df "freezer: make exiting tasks properly unfreezable" removed clear_freeze_flag() from exit path and set PF_NOFREEZE right after PTRACE_EVENT_EXIT; however, Oleg pointed out that following exit paths may cause interaction with device drivers after PM freezer consider the system frozen. There's no try_to_freeze() call in the exit path and the only necessary guarantee is that freezer doesn't hang waiting for zombies. Set PF_NOFREEZE right before setting tsk->state to TASK_DEAD instead. Signed-off-by: Tejun Heo Reported-by: Oleg Nesterov Cc: "Rafael J. Wysocki" --- kernel/exit.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) Index: work/kernel/exit.c =================================================================== --- work.orig/kernel/exit.c +++ work/kernel/exit.c @@ -913,12 +913,6 @@ NORET_TYPE void do_exit(long code) ptrace_event(PTRACE_EVENT_EXIT, code); - /* - * With ptrace notification done, there's no point in freezing from - * here on. Disallow freezing. - */ - current->flags |= PF_NOFREEZE; - validate_creds_for_do_exit(tsk); /* @@ -1044,6 +1038,10 @@ NORET_TYPE void do_exit(long code) preempt_disable(); exit_rcu(); + + /* this task is now dead and freezer should ignore it */ + current->flags |= PF_NOFREEZE; + /* causes final put_task_struct in finish_task_switch(). */ tsk->state = TASK_DEAD; schedule();