Skip to contentSkip to conversation

Unfreeze tasks after an oops in the freezer

PATCH In review Oliver Neukum 2 participants 3 messages Jul 27, 2011 – Jul 28, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Unfreeze tasks after an oops in the freezer

Quoted 1 line

From ee5849f0bc39d554ef91747ff80c307ac3e05cdd Mon Sep 17 00:00:00 2001

From: Oliver Neukum <[email protected]>
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.

---
 include/linux/freezer.h |    2 ++
 kernel/panic.c          |    8 ++++++++
 kernel/power/process.c  |   11 +++++++++++
 3 files changed, 21 insertions(+), 0 deletions(-)
include/linux/freezer.h +2 -0
index 1effc8b..ab0168a 100644
@@ -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)
kernel/panic.c +8 -0
index 6923167..ccdd834 100644
@@ -23,6 +23,7 @@
 #include <linux/init.h>
 #include <linux/nmi.h>
 #include <linux/dmi.h>
+#include <linux/freezer.h>
 
 #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
kernel/power/process.c +11 -0
index 0cf3a27..c03e88b 100644
@@ -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();
+}
+
Signature · 1 line
1.7.1
#1 lore raw
Quoted 77 lines · Oliver Neukum

From ee5849f0bc39d554ef91747ff80c307ac3e05cdd Mon Sep 17 00:00:00 2001
From: Oliver Neukum <[email protected]>
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.

---
 include/linux/freezer.h |    2 ++
 kernel/panic.c          |    8 ++++++++
 kernel/power/process.c  |   11 +++++++++++
 3 files changed, 21 insertions(+), 0 deletions(-)
include/linux/freezer.h +2 -0
index 1effc8b..ab0168a 100644
@@ -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)
kernel/panic.c +8 -0
index 6923167..ccdd834 100644
@@ -23,6 +23,7 @@
 #include <linux/init.h>
 #include <linux/nmi.h>
 #include <linux/dmi.h>
+#include <linux/freezer.h>
 
 #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
kernel/power/process.c +3 -0
index 0cf3a27..c03e88b 100644
@@ -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) ||

kernel/power/process.c static int try_to_freeze_tasks(bool sig_only) · line 137

Quoted 4 lines
kernel/power/process.c +1 -0
@@ -131,6 +134,7 @@ static int try_to_freeze_tasks(bool sig_only)
 			elapsed_csecs % 100);
 	}
 
+	tasks_frozen = (todo == 0);

I'd prefer it to be set by freeze_processes(), when oom_killer_disable() is called.

Quoted 8 lines
kernel/power/process.c +1 -0
 	return todo ? -EBUSY : 0;
 }
 
@@ -189,7 +193,14 @@ void thaw_processes(void)
 	thaw_workqueues();
 	thaw_tasks(true);
 	thaw_tasks(false);
+	tasks_frozen = false;

kernel/power/process.c void thaw_processes(void) · line 206

Quoted 10 lines
kernel/power/process.c +6 -0
 	schedule();
 	printk("done.\n");
 }
 
+void thaw_in_oops(void)
+{
+	if (tasks_frozen)
+		thaw_processes();
+}
+

Thanks,
Rafael

#2 lore raw
In reply to Oliver Neukum
Quoted 77 lines · Oliver Neukum

From ee5849f0bc39d554ef91747ff80c307ac3e05cdd Mon Sep 17 00:00:00 2001
From: Oliver Neukum <[email protected]>
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.

---
 include/linux/freezer.h |    2 ++
 kernel/panic.c          |    8 ++++++++
 kernel/power/process.c  |   11 +++++++++++
 3 files changed, 21 insertions(+), 0 deletions(-)
include/linux/freezer.h +2 -0
index 1effc8b..ab0168a 100644
@@ -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)
kernel/panic.c +8 -0
index 6923167..ccdd834 100644
@@ -23,6 +23,7 @@
 #include <linux/init.h>
 #include <linux/nmi.h>
 #include <linux/dmi.h>
+#include <linux/freezer.h>
 
 #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
kernel/power/process.c +3 -0
index 0cf3a27..c03e88b 100644
@@ -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) ||

kernel/power/process.c static int try_to_freeze_tasks(bool sig_only) · line 137

Quoted 4 lines
kernel/power/process.c +1 -0
@@ -131,6 +134,7 @@ static int try_to_freeze_tasks(bool sig_only)
 			elapsed_csecs % 100);
 	}
 
+	tasks_frozen = (todo == 0);

I'd prefer it to be set by freeze_processes(), when oom_killer_disable() is called.

Quoted 8 lines
kernel/power/process.c +1 -0
 	return todo ? -EBUSY : 0;
 }
 
@@ -189,7 +193,14 @@ void thaw_processes(void)
 	thaw_workqueues();
 	thaw_tasks(true);
 	thaw_tasks(false);
+	tasks_frozen = false;

kernel/power/process.c void thaw_processes(void) · line 206

Quoted 10 lines
kernel/power/process.c +6 -0
 	schedule();
 	printk("done.\n");
 }
 
+void thaw_in_oops(void)
+{
+	if (tasks_frozen)
+		thaw_processes();
+}
+

Thanks,
Rafael