public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] ftrace: updates to tip
@ 2009-01-15  0:02 Steven Rostedt
  2009-01-15  0:02 ` [PATCH 1/4] trace: print ftrace_dump at KERN_EMERG log level Steven Rostedt
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Steven Rostedt @ 2009-01-15  0:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Lai Jiangshan

Ingo,

The following patches are in:

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git

    branch: tip/devel


Frederic Weisbecker (1):
      tracing/function-graph-tracer: fix a regression while suspend to disk

Lai Jiangshan (1):
      ring_buffer: reset write when reserve buffer fail

Steven Rostedt (2):
      trace: print ftrace_dump at KERN_EMERG log level
      trace: stop all recording to ring buffer on ftrace_dump

----
 kernel/trace/ftrace.c      |   27 +++++++++++++++++++++++++++
 kernel/trace/ring_buffer.c |   10 +++++-----
 kernel/trace/trace.c       |    3 ++-
 3 files changed, 34 insertions(+), 6 deletions(-)
-- 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] trace: print ftrace_dump at KERN_EMERG log level
  2009-01-15  0:02 [PATCH 0/4] ftrace: updates to tip Steven Rostedt
@ 2009-01-15  0:02 ` Steven Rostedt
  2009-01-15  0:02 ` [PATCH 2/4] ring_buffer: reset write when reserve buffer fail Steven Rostedt
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2009-01-15  0:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Lai Jiangshan,
	Steven Rostedt

[-- Attachment #1: 0001-trace-print-ftrace_dump-at-KERN_EMERG-log-level.patch --]
[-- Type: text/plain, Size: 1290 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

Impact: fix to print out ftrace_dump when expected

I was debugging a hard race condition to only find out that
after I hit the race, my log level was not at level to show
KERN_INFO. The time it took to trigger the race was wasted because
I did not capture the trace.

Since ftrace_dump is only called from kernel oops (and only when
it is set in the kernel command line to do so), or when a
developer adds it to their own local tree, the log level of
the print should be at KERN_EMERG to make sure the print appears.

ftrace_dump is not called by a normal user setup, and will not
add extra unwanted print out to the console. There is no reason
it should be at KERN_INFO.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 kernel/trace/trace.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 40217fb..408c03f 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3076,7 +3076,7 @@ static struct notifier_block trace_die_notifier = {
  * it if we decide to change what log level the ftrace dump
  * should be at.
  */
-#define KERN_TRACE		KERN_INFO
+#define KERN_TRACE		KERN_EMERG
 
 static void
 trace_printk_seq(struct trace_seq *s)
-- 
1.5.6.5

-- 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] ring_buffer: reset write when reserve buffer fail
  2009-01-15  0:02 [PATCH 0/4] ftrace: updates to tip Steven Rostedt
  2009-01-15  0:02 ` [PATCH 1/4] trace: print ftrace_dump at KERN_EMERG log level Steven Rostedt
@ 2009-01-15  0:02 ` Steven Rostedt
  2009-01-15  0:02 ` [PATCH 3/4] trace: stop all recording to ring buffer on ftrace_dump Steven Rostedt
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2009-01-15  0:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Lai Jiangshan,
	Steven Rostedt

[-- Attachment #1: 0002-ring_buffer-reset-write-when-reserve-buffer-fail.patch --]
[-- Type: text/plain, Size: 1952 bytes --]

From: Lai Jiangshan <laijs@cn.fujitsu.com>

[ The following text is in the "UTF-8" character set. ]
    [ Your display is set for the "ANSI_X3.4-1968" character set.  ]
    [ Some characters may be displayed incorrectly. ]

Impact: reset struct buffer_page.write when interrupt storm

if struct buffer_page.write is not reset, any succedent committing
will corrupted ring_buffer:

static inline void
rb_set_commit_to_write(struct ring_buffer_per_cpu *cpu_buffer)
{
	......
		cpu_buffer->commit_page->commit =
			cpu_buffer->commit_page->write;
	......
}

when "if (RB_WARN_ON(cpu_buffer, next_page == reader_page))", ring_buffer
is disabled, but some reserved buffers may haven't been committed.
we need reset struct buffer_page.write.

when "if (unlikely(next_page == cpu_buffer->commit_page))", ring_buffer
is still available, we should not corrupt it.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 kernel/trace/ring_buffer.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 4832ffa..0b9de5a 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -1017,12 +1017,8 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
 		}
 
 		if (next_page == head_page) {
-			if (!(buffer->flags & RB_FL_OVERWRITE)) {
-				/* reset write */
-				if (tail <= BUF_PAGE_SIZE)
-					local_set(&tail_page->write, tail);
+			if (!(buffer->flags & RB_FL_OVERWRITE))
 				goto out_unlock;
-			}
 
 			/* tail_page has not moved yet? */
 			if (tail_page == cpu_buffer->tail_page) {
@@ -1097,6 +1093,10 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
 	return event;
 
  out_unlock:
+	/* reset write */
+	if (tail <= BUF_PAGE_SIZE)
+		local_set(&tail_page->write, tail);
+
 	__raw_spin_unlock(&cpu_buffer->lock);
 	local_irq_restore(flags);
 	return NULL;
-- 
1.5.6.5

-- 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] trace: stop all recording to ring buffer on ftrace_dump
  2009-01-15  0:02 [PATCH 0/4] ftrace: updates to tip Steven Rostedt
  2009-01-15  0:02 ` [PATCH 1/4] trace: print ftrace_dump at KERN_EMERG log level Steven Rostedt
  2009-01-15  0:02 ` [PATCH 2/4] ring_buffer: reset write when reserve buffer fail Steven Rostedt
@ 2009-01-15  0:02 ` Steven Rostedt
  2009-01-15  0:02 ` [PATCH 4/4] tracing/function-graph-tracer: fix a regression while suspend to disk Steven Rostedt
  2009-01-15  8:46 ` [PATCH 0/4] ftrace: updates to tip Ingo Molnar
  4 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2009-01-15  0:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Lai Jiangshan,
	Steven Rostedt

[-- Attachment #1: 0003-trace-stop-all-recording-to-ring-buffer-on-ftrace_d.patch --]
[-- Type: text/plain, Size: 825 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

Impact: clean up to prevent more output in ftrace dump than needed

Currently ftrace_dump only calls ftrace_kill that is a fast way
to prevent the function tracer functions from being called (just sets
a flag and clears the function to call, nothing else). It is better
to also turn off any recording to the ring buffers as well.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 kernel/trace/trace.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 408c03f..dcb757f 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3110,6 +3110,7 @@ void ftrace_dump(void)
 	dump_ran = 1;
 
 	/* No turning back! */
+	tracing_off();
 	ftrace_kill();
 
 	for_each_tracing_cpu(cpu) {
-- 
1.5.6.5

-- 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] tracing/function-graph-tracer: fix a regression while suspend to disk
  2009-01-15  0:02 [PATCH 0/4] ftrace: updates to tip Steven Rostedt
                   ` (2 preceding siblings ...)
  2009-01-15  0:02 ` [PATCH 3/4] trace: stop all recording to ring buffer on ftrace_dump Steven Rostedt
@ 2009-01-15  0:02 ` Steven Rostedt
  2009-01-15  8:46 ` [PATCH 0/4] ftrace: updates to tip Ingo Molnar
  4 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2009-01-15  0:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Lai Jiangshan,
	Steven Rostedt

[-- Attachment #1: 0004-tracing-function-graph-tracer-fix-a-regression-whil.patch --]
[-- Type: text/plain, Size: 3288 bytes --]

From: Frederic Weisbecker <fweisbec@gmail.com>

Impact: fix a crash while kernel image restore

When the function graph tracer is running and while suspend to disk, some racy
and dangerous things happen against this tracer.

The current task will save its registers including the stack pointer which
contains the return address hooked by the tracer. But the current task will
continue to enter other functions after that to save the memory, and then
it will store other return addresses, and finally loose the old depth which
matches the return address saved in the old stack (during the registers saving).

So on image restore, the code will return to wrong addresses.
And there are other things: on restore, the task will have it's "current"
pointer overwritten during registers restoring....switching from one task to
another... That would be insane to try to trace function graphs at these
stages.

This patch makes the function graph tracer listening on power events, making
it's tracing disabled for the current task (the one that performs the hibernation work)
while suspend/resume to disk, making the tracing safe during hibernation.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 kernel/trace/ftrace.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 8c1c9c0..7e9a20b 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -17,6 +17,7 @@
 #include <linux/clocksource.h>
 #include <linux/kallsyms.h>
 #include <linux/seq_file.h>
+#include <linux/suspend.h>
 #include <linux/debugfs.h>
 #include <linux/hardirq.h>
 #include <linux/kthread.h>
@@ -1957,6 +1958,7 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 
 static atomic_t ftrace_graph_active;
+static struct notifier_block ftrace_suspend_notifier;
 
 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
 {
@@ -2035,6 +2037,27 @@ static int start_graph_tracing(void)
 	return ret;
 }
 
+/*
+ * Hibernation protection.
+ * The state of the current task is too much unstable during
+ * suspend/restore to disk. We want to protect against that.
+ */
+static int
+ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
+							void *unused)
+{
+	switch (state) {
+	case PM_HIBERNATION_PREPARE:
+		pause_graph_tracing();
+		break;
+
+	case PM_POST_HIBERNATION:
+		unpause_graph_tracing();
+		break;
+	}
+	return NOTIFY_DONE;
+}
+
 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
 			trace_func_graph_ent_t entryfunc)
 {
@@ -2042,6 +2065,9 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
 
 	mutex_lock(&ftrace_sysctl_lock);
 
+	ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
+	register_pm_notifier(&ftrace_suspend_notifier);
+
 	atomic_inc(&ftrace_graph_active);
 	ret = start_graph_tracing();
 	if (ret) {
@@ -2067,6 +2093,7 @@ void unregister_ftrace_graph(void)
 	ftrace_graph_return = (trace_func_graph_ret_t)ftrace_stub;
 	ftrace_graph_entry = ftrace_graph_entry_stub;
 	ftrace_shutdown(FTRACE_STOP_FUNC_RET);
+	unregister_pm_notifier(&ftrace_suspend_notifier);
 
 	mutex_unlock(&ftrace_sysctl_lock);
 }
-- 
1.5.6.5

-- 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] ftrace: updates to tip
  2009-01-15  0:02 [PATCH 0/4] ftrace: updates to tip Steven Rostedt
                   ` (3 preceding siblings ...)
  2009-01-15  0:02 ` [PATCH 4/4] tracing/function-graph-tracer: fix a regression while suspend to disk Steven Rostedt
@ 2009-01-15  8:46 ` Ingo Molnar
  4 siblings, 0 replies; 6+ messages in thread
From: Ingo Molnar @ 2009-01-15  8:46 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Andrew Morton, Frederic Weisbecker, Lai Jiangshan


* Steven Rostedt <rostedt@goodmis.org> wrote:

> Ingo,
> 
> The following patches are in:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
> 
>     branch: tip/devel

pulled, thanks Steve!

	Ingo

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-01-15  8:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-15  0:02 [PATCH 0/4] ftrace: updates to tip Steven Rostedt
2009-01-15  0:02 ` [PATCH 1/4] trace: print ftrace_dump at KERN_EMERG log level Steven Rostedt
2009-01-15  0:02 ` [PATCH 2/4] ring_buffer: reset write when reserve buffer fail Steven Rostedt
2009-01-15  0:02 ` [PATCH 3/4] trace: stop all recording to ring buffer on ftrace_dump Steven Rostedt
2009-01-15  0:02 ` [PATCH 4/4] tracing/function-graph-tracer: fix a regression while suspend to disk Steven Rostedt
2009-01-15  8:46 ` [PATCH 0/4] ftrace: updates to tip Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox