From patchwork Wed Jul 27 10:35:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Neukum X-Patchwork-Id: 1011312 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 p6RAYm7U014221 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Wed, 27 Jul 2011 10:35:09 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 p6RAXIOl023334; Wed, 27 Jul 2011 03:33:18 -0700 Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p6RAXDtA023319 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 27 Jul 2011 03:33:15 -0700 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id AFB138F903; Wed, 27 Jul 2011 12:33:12 +0200 (CEST) From: Oliver Neukum Organization: SUSE To: Andrew Morton , "Rafael J. Wysocki" , linux-pm@lists.linux-foundation.org, linux-kernel@vger.kernel.org Date: Wed, 27 Jul 2011 12:35:58 +0200 User-Agent: KMail/1.13.5 (Linux/3.0.0-rc7-12-desktop+; KDE/4.4.4; x86_64; ; ) MIME-Version: 1.0 Message-Id: <201107271235.58734.oneukum@suse.de> Received-SPF: pass (localhost is always allowed.) X-Spam-Status: No, hits=-105.499 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SUBJECT_BRACKETED, PATCH_SUBJECT_OSDL, USER_IN_WHITELIST 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 Subject: [linux-pm] [PATCH] Unfreeze tasks after an oops in the freezer 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]); Wed, 27 Jul 2011 10:35:27 +0000 (UTC) From ee5849f0bc39d554ef91747ff80c307ac3e05cdd Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Wed, 27 Jul 2011 12:27:00 +0200 Subject: [PATCH] Unfreeze tasks after an oops in the freezer If an oops kills the task suspending or snapshotting is system, the system is dead because the action is never completed and the tasks never thawed. Signed-off-by: Oliver Neukum --- include/linux/freezer.h | 2 ++ kernel/panic.c | 8 ++++++++ kernel/power/process.c | 11 +++++++++++ 3 files changed, 21 insertions(+), 0 deletions(-) diff --git a/include/linux/freezer.h b/include/linux/freezer.h index 1effc8b..ab0168a 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h @@ -50,6 +50,7 @@ extern int thaw_process(struct task_struct *p); extern void refrigerator(void); extern int freeze_processes(void); extern void thaw_processes(void); +extern void thaw_in_oops(void); static inline int try_to_freeze(void) { @@ -181,6 +182,7 @@ static inline void freezer_count(void) {} static inline int freezer_should_skip(struct task_struct *p) { return 0; } static inline void set_freezable(void) {} static inline void set_freezable_with_signal(void) {} +static inline void thaw_in_oops(void) {} #define wait_event_freezable(wq, condition) \ wait_event_interruptible(wq, condition) diff --git a/kernel/panic.c b/kernel/panic.c index 6923167..ccdd834 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -23,6 +23,7 @@ #include #include #include +#include #define PANIC_TIMER_STEP 100 #define PANIC_BLINK_SPD 18 @@ -355,6 +356,13 @@ void oops_exit(void) do_oops_enter_exit(); print_oops_end_marker(); kmsg_dump(KMSG_DUMP_OOPS); + /* + * if we oops while tasks are frozen, the system + * will stop dead because the task that would thaw it + * has been killed. So the system must be explicitly + * thawed here. + */ + thaw_in_oops(); } #ifdef WANT_WARN_ON_SLOWPATH diff --git a/kernel/power/process.c b/kernel/power/process.c index 0cf3a27..c03e88b 100644 --- a/kernel/power/process.c +++ b/kernel/power/process.c @@ -22,6 +22,9 @@ */ #define TIMEOUT (20 * HZ) +/* in case we oops while processes are frozen */ +static bool tasks_frozen = false; + static inline int freezable(struct task_struct * p) { if ((p == current) || @@ -131,6 +134,7 @@ static int try_to_freeze_tasks(bool sig_only) elapsed_csecs % 100); } + tasks_frozen = (todo == 0); return todo ? -EBUSY : 0; } @@ -189,7 +193,14 @@ void thaw_processes(void) thaw_workqueues(); thaw_tasks(true); thaw_tasks(false); + tasks_frozen = false; schedule(); printk("done.\n"); } +void thaw_in_oops(void) +{ + if (tasks_frozen) + thaw_processes(); +} +