[PATCH] ftrace: disable tracing for suspend to ram

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Steven Rostedt
Date: Wednesday, August 27, 2008 - 6:14 am

I've been painstakingly debugging the issue with suspend to ram and 
ftraced. The 2.6.28 code does not have this issue, but since the mcount 
recording is not going to be in 27, this must be solved for the ftrace 
daemon version.

The resume from suspend to ram would reboot because it was triple 
faulting. Debugging further, I found that calling the mcount function 
itself was not an issue, but it would fault when it incremented 
preempt_count. preempt_count is on the tasks info structure that is on the 
low memory address of the task's stack.  For some reason, it could not 
write to it. Resuming out of suspend to ram does quite a lot of funny 
tricks to get to work, so it is not surprising at all that simply doing a 
preempt_disable() would cause a fault.

Thanks to Rafael for suggesting to add a "while (1);" to find the place in 
resuming that is causing the fault. I would place the loop somewhere in 
the code, compile and reboot and see if it would either reboot (hit the 
fault) or simply hang (hit the loop).  Doing this over and over again, I 
narrowed it down that it was happening in enable_nonboot_cpus.

At this point, I found that it is easier to simply disable tracing around 
the suspend code, instead of searching for the particular function that 
can not handle doing a preempt_disable.

This patch disables the tracer as it suspends and reenables it on resume.

I tested this patch on my Laptop, and it can resume fine with the patch.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 kernel/power/main.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Index: linux-compile.git/kernel/power/main.c
===================================================================
--- linux-compile.git.orig/kernel/power/main.c	2008-08-27 08:53:11.000000000 -0400
+++ linux-compile.git/kernel/power/main.c	2008-08-27 08:53:58.000000000 -0400
@@ -21,6 +21,7 @@
 #include <linux/freezer.h>
 #include <linux/vmstat.h>
 #include <linux/syscalls.h>
+#include <linux/ftrace.h>
 
 #include "power.h"
 
@@ -310,7 +311,7 @@ static int suspend_enter(suspend_state_t
  */
 int suspend_devices_and_enter(suspend_state_t state)
 {
-	int error;
+	int error, ftrace_save;
 
 	if (!suspend_ops)
 		return -ENOSYS;
@@ -321,6 +322,7 @@ int suspend_devices_and_enter(suspend_st
 			goto Close;
 	}
 	suspend_console();
+	ftrace_save = __ftrace_enabled_save();
 	suspend_test_start();
 	error = device_suspend(PMSG_SUSPEND);
 	if (error) {
@@ -352,6 +354,7 @@ int suspend_devices_and_enter(suspend_st
 	suspend_test_start();
 	device_resume(PMSG_RESUME);
 	suspend_test_finish("resume devices");
+	__ftrace_enabled_restore(ftrace_save);
 	resume_console();
  Close:
 	if (suspend_ops->end)


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
ftraced and suspend to ram, Steven Rostedt, (Thu Aug 21, 8:49 am)
Re: ftraced and suspend to ram, Rafael J. Wysocki, (Thu Aug 21, 11:15 am)
Re: ftraced and suspend to ram, Steven Rostedt, (Thu Aug 21, 11:26 am)
Re: ftraced and suspend to ram, Rafael J. Wysocki, (Thu Aug 21, 11:37 am)
Re: ftraced and suspend to ram, Rafael J. Wysocki, (Thu Aug 21, 12:59 pm)
Re: ftraced and suspend to ram, Ingo Molnar, (Thu Aug 21, 9:46 pm)
Re: ftraced and suspend to ram, Pavel Machek, (Fri Aug 22, 12:23 am)
Re: ftraced and suspend to ram, Rafael J. Wysocki, (Fri Aug 22, 3:22 am)
Re: ftraced and suspend to ram, Marcin Slusarz, (Fri Aug 22, 3:35 am)
Re: ftraced and suspend to ram, Pavel Machek, (Fri Aug 22, 3:46 am)
Re: ftraced and suspend to ram, Rafael J. Wysocki, (Fri Aug 22, 9:39 am)
Re: ftraced and suspend to ram, Steven Rostedt, (Fri Aug 22, 1:33 pm)
Re: ftraced and suspend to ram, Rafael J. Wysocki, (Fri Aug 22, 1:52 pm)
Re: ftraced and suspend to ram, Marcin Slusarz, (Fri Aug 22, 1:54 pm)
Re: ftraced and suspend to ram, Steven Rostedt, (Fri Aug 22, 1:55 pm)
Re: ftraced and suspend to ram, Rafael J. Wysocki, (Fri Aug 22, 2:11 pm)
Re: ftraced and suspend to ram, Rafael J. Wysocki, (Fri Aug 22, 2:17 pm)
[PATCH] ftrace: disable tracing for suspend to ram, Steven Rostedt, (Wed Aug 27, 6:14 am)
Re: [PATCH] ftrace: disable tracing for suspend to ram, Rafael J. Wysocki, (Wed Aug 27, 6:26 am)
Re: [PATCH] ftrace: disable tracing for suspend to ram, Marcin Slusarz, (Wed Aug 27, 2:27 pm)
Re: [PATCH] ftrace: disable tracing for suspend to ram, Pavel Machek, (Thu Aug 28, 12:28 am)
[PATCH] ftrace: disable tracing for hibernation, Rafael J. Wysocki, (Thu Aug 28, 5:39 am)
Re: [PATCH] ftrace: disable tracing for hibernation, Ingo Molnar, (Thu Aug 28, 5:42 am)
Re: [PATCH] ftrace: disable tracing for hibernation, Steven Rostedt, (Thu Aug 28, 5:44 am)
Re: [PATCH] ftrace: disable tracing for suspend to ram, Steven Rostedt, (Fri Aug 29, 6:43 am)
Re: [PATCH] ftrace: disable tracing for hibernation, Pavel Machek, (Fri Aug 29, 4:53 pm)