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 5/5] ftrace: add checks on ret stack in function graph
Date: Tue, 02 Dec 2008 23:50:06 -0500 [thread overview]
Message-ID: <20081203045044.222038233@goodmis.org> (raw)
In-Reply-To: 20081203045001.367443457@goodmis.org
[-- Attachment #1: 0005-ftrace-add-checks-on-ret-stack-in-function-graph.patch --]
[-- Type: text/plain, Size: 1498 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
Import: robustness checks
Add more checks in the function graph code to detect errors and
perhaps print out better information if a bug happens.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
arch/x86/kernel/ftrace.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index d278ad2..f98c407 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -420,6 +420,15 @@ static void pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret)
int index;
index = current->curr_ret_stack;
+
+ if (unlikely(index < 0)) {
+ ftrace_graph_stop();
+ WARN_ON(1);
+ /* Might as well panic, otherwise we have no where to go */
+ *ret = (unsigned long)panic;
+ return;
+ }
+
*ret = current->ret_stack[index].ret;
trace->func = current->ret_stack[index].func;
trace->calltime = current->ret_stack[index].calltime;
@@ -427,6 +436,7 @@ static void pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret)
trace->depth = index;
barrier();
current->curr_ret_stack--;
+
}
/*
@@ -442,6 +452,13 @@ unsigned long ftrace_return_to_handler(void)
trace.rettime = cpu_clock(raw_smp_processor_id());
ftrace_graph_return(&trace);
+ if (unlikely(!ret)) {
+ ftrace_graph_stop();
+ WARN_ON(1);
+ /* Might as well panic. What else to do? */
+ ret = (unsigned long)panic;
+ }
+
return ret;
}
--
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 ` [PATCH 1/5] ftrace: add ftrace_graph_stop Steven Rostedt
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 ` Steven Rostedt [this message]
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=20081203045044.222038233@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