From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: linuxppc-dev@ozlabs.org, Steven Rostedt <srostedt@redhat.com>,
Paul Mackerras <paulus@samba.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 4/7][RFC] powerpc64, ftrace: save toc only on modules for function graph
Date: Wed, 11 Feb 2009 20:10:55 -0500 [thread overview]
Message-ID: <20090212011343.322127562@goodmis.org> (raw)
In-Reply-To: 20090212011051.265346435@goodmis.org
From: Steven Rostedt <srostedt@redhat.com>
The TOCS used by modules are different than the one used by
the core kernel code. The function graph tracer must save and
restore the TOC whenever it traces a module call. But this
is an added overhead to burden the majority of core kernel
code being traced.
Benjamin Herrenschmidt suggested in testing the entry of
the call to tell if it is a core kernel function or a module.
He recommended using the REGION_ID() macro to perform this test.
This patch implements Benjamin's idea, and uses a different
return_to_handler routine dependent on if the entry is a core
kernel function or not. The module version saves the TOC, where as
the core kernel version does not.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
arch/powerpc/kernel/entry_64.S | 27 ++++++++++++++++++++++++++-
arch/powerpc/kernel/ftrace.c | 13 +++++++++++--
2 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 9f61fd6..abfc323 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -971,6 +971,28 @@ _GLOBAL(ftrace_graph_caller)
_GLOBAL(return_to_handler)
/* need to save return values */
+ std r4, -24(r1)
+ std r3, -16(r1)
+ std r31, -8(r1)
+ mr r31, r1
+ stdu r1, -112(r1)
+
+ bl .ftrace_return_to_handler
+ nop
+
+ /* return value has real return address */
+ mtlr r3
+
+ ld r1, 0(r1)
+ ld r4, -24(r1)
+ ld r3, -16(r1)
+ ld r31, -8(r1)
+
+ /* Jump back to real return address */
+ blr
+
+_GLOBAL(mod_return_to_handler)
+ /* need to save return values */
std r4, -32(r1)
std r3, -24(r1)
/* save TOC */
@@ -979,7 +1001,10 @@ _GLOBAL(return_to_handler)
mr r31, r1
stdu r1, -112(r1)
- /* update the TOC */
+ /*
+ * We are in a module using the module's TOC.
+ * Switch to our TOC to run inside the core kernel.
+ */
LOAD_REG_IMMEDIATE(r4,ftrace_return_to_handler)
ld r2, 8(r4)
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index 7538b94..5c6dfa9 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -567,6 +567,10 @@ int ftrace_disable_ftrace_graph_caller(void)
}
#endif /* CONFIG_DYNAMIC_FTRACE */
+#ifdef CONFIG_PPC64
+extern void mod_return_to_handler(void);
+#endif
+
/*
* Hook the return address and push it in the stack of return addrs
* in current thread info.
@@ -577,12 +581,17 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
unsigned long long calltime;
int faulted;
struct ftrace_graph_ent trace;
- unsigned long return_hooker = (unsigned long)
- &return_to_handler;
+ unsigned long return_hooker = (unsigned long)&return_to_handler;
if (unlikely(atomic_read(¤t->tracing_graph_pause)))
return;
+#if CONFIG_PPC64
+ /* non core kernel code needs to save and restore the TOC */
+ if (REGION_ID(self_addr) != KERNEL_REGION_ID)
+ return_hooker = (unsigned long)&mod_return_to_handler;
+#endif
+
return_hooker = GET_ADDR(return_hooker);
/*
--
1.5.6.5
--
next prev parent reply other threads:[~2009-02-12 1:13 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-12 1:10 [PATCH 0/7][RFC] function graph tracer port to PowerPC Steven Rostedt
2009-02-12 1:10 ` [PATCH 1/7][RFC] tracing/function-graph-tracer: make arch generic push pop functions Steven Rostedt
2009-02-12 1:10 ` [PATCH 2/7][RFC] powerpc64: port of the function graph tracer Steven Rostedt
2009-02-13 4:12 ` Benjamin Herrenschmidt
2009-02-13 4:18 ` Steven Rostedt
2009-02-12 1:10 ` [PATCH 3/7][RFC] powerpc64, tracing: add function graph tracer with dynamic tracing Steven Rostedt
2009-02-13 4:15 ` Benjamin Herrenschmidt
2009-02-13 4:20 ` Steven Rostedt
2009-02-13 5:22 ` Steven Rostedt
2009-02-12 1:10 ` Steven Rostedt [this message]
2009-02-12 1:10 ` [PATCH 5/7][RFC] powerpc32, ftrace: save and restore mcount regs with macro Steven Rostedt
2009-02-12 1:10 ` [PATCH 6/7][RFC] powerpc32, ftrace: port function graph tracer to ppc32, static only Steven Rostedt
2009-02-12 1:10 ` [PATCH 7/7][RFC] powerpc32, ftrace: dynamic function graph tracer Steven Rostedt
2009-02-12 1:55 ` [PATCH 0/7][RFC] function graph tracer port to PowerPC Frederic Weisbecker
2009-02-12 2:16 ` Steven Rostedt
2009-02-12 4:08 ` Frederic Weisbecker
2009-02-12 16:31 ` Steven Rostedt
2009-02-12 16:47 ` Frederic Weisbecker
2009-02-12 16:58 ` Steven Rostedt
2009-02-13 4:18 ` Benjamin Herrenschmidt
2009-02-12 2:23 ` Michael Ellerman
2009-02-12 2:37 ` Steven Rostedt
2009-02-12 16:35 ` Steven Rostedt
2009-02-12 23:32 ` Geoff Levand
2009-02-12 23:41 ` Steven Rostedt
2009-02-12 23:44 ` Josh Boyer
2009-02-12 23:44 ` Geoff Levand
2009-02-12 23:51 ` Steven Rostedt
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=20090212011343.322127562@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--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;
as well as URLs for NNTP newsgroup(s).