From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Steven Rostedt <srostedt@redhat.com>
Subject: [PATCH 1/5] ftrace: add ftrace_graph_stop
Date: Tue, 02 Dec 2008 23:50:02 -0500 [thread overview]
Message-ID: <20081203045043.362050477@goodmis.org> (raw)
In-Reply-To: 20081203045001.367443457@goodmis.org
[-- Attachment #1: 0001-ftrace-add-ftrace_graph_stop.patch --]
[-- Type: text/plain, Size: 2425 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
Impact: new ftrace_graph_stop function
While developing more features of function graph, I hit a bug that
caused the WARN_ON to trigger in the prepare_ftrace_return function.
Well, it was hard for me to find out that was happening because the
bug would not print, it would just cause a hard lockup or reboot.
The reason is that it is not safe to call printk from this function.
Looking further, I also found that it calls unregister_ftrace_graph,
which grabs a mutex and calls kstop machine. This would definitely
lock the box up if it were to trigger.
This patch adds a fast and safe ftrace_graph_stop() which will
stop the function tracer. Then it is safe to call the WARN ON.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
arch/x86/kernel/ftrace.c | 10 ++++++----
include/linux/ftrace.h | 2 ++
kernel/trace/ftrace.c | 5 +++++
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 1a5b8f8..adba8e9 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -484,14 +484,16 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
: "memory"
);
- if (WARN_ON(faulted)) {
- unregister_ftrace_graph();
+ if (unlikely(faulted)) {
+ ftrace_graph_stop();
+ WARN_ON(1);
return;
}
- if (WARN_ON(!__kernel_text_address(old))) {
- unregister_ftrace_graph();
+ if (unlikely(!__kernel_text_address(old))) {
+ ftrace_graph_stop();
*parent = old;
+ WARN_ON(1);
return;
}
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index afba918..58ca1c3 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -376,6 +376,8 @@ typedef void (*trace_func_graph_ent_t)(struct ftrace_graph_ent *); /* entry */
extern int register_ftrace_graph(trace_func_graph_ret_t retfunc,
trace_func_graph_ent_t entryfunc);
+extern void ftrace_graph_stop(void);
+
/* The current handlers in use */
extern trace_func_graph_ret_t ftrace_graph_return;
extern trace_func_graph_ent_t ftrace_graph_entry;
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 2e78628..a44af05 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1769,5 +1769,10 @@ void ftrace_graph_exit_task(struct task_struct *t)
kfree(ret_stack);
}
+
+void ftrace_graph_stop(void)
+{
+ ftrace_stop();
+}
#endif
--
1.5.6.5
--
next prev parent reply other threads:[~2008-12-03 4:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-03 4:50 [PATCH 0/5] ftrace: updates for tip Steven Rostedt
2008-12-03 4:50 ` Steven Rostedt [this message]
2008-12-03 4:50 ` [PATCH 2/5] ring-buffer: change page variables to bpage Steven Rostedt
2008-12-03 4:50 ` [PATCH 3/5] ftrace: print real return in dumpstack for function graph Steven Rostedt
2008-12-03 8:11 ` Ingo Molnar
2008-12-03 11:44 ` Steven Rostedt
2008-12-03 4:50 ` [PATCH 4/5] ftrace: function graph return for function entry Steven Rostedt
2008-12-03 8:13 ` Ingo Molnar
2008-12-03 10:05 ` Ingo Molnar
2008-12-03 11:59 ` Steven Rostedt
2008-12-03 13:23 ` Frédéric Weisbecker
2008-12-03 14:04 ` Steven Rostedt
2008-12-03 11:49 ` Steven Rostedt
2008-12-03 13:19 ` Frédéric Weisbecker
2008-12-03 4:50 ` [PATCH 5/5] ftrace: add checks on ret stack in function graph Steven Rostedt
2008-12-03 8:11 ` [PATCH 0/5] ftrace: updates for tip Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081203045043.362050477@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=srostedt@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox