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 3/7][RFC] powerpc64, tracing: add function graph tracer with dynamic tracing
Date: Wed, 11 Feb 2009 20:10:54 -0500 [thread overview]
Message-ID: <20090212011343.074329920@goodmis.org> (raw)
In-Reply-To: 20090212011051.265346435@goodmis.org
From: Steven Rostedt <srostedt@redhat.com>
This is the port of the function graph tracer to PowerPC with
dynamic tracing.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
arch/powerpc/Kconfig | 2 +-
arch/powerpc/kernel/entry_64.S | 8 ++++++-
arch/powerpc/kernel/ftrace.c | 47 ++++++++++++++++++++++++++++++++++-----
3 files changed, 49 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index ca4647e..6e1ee1b 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -111,7 +111,7 @@ config PPC
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_DYNAMIC_FTRACE
select HAVE_FUNCTION_TRACER
- select HAVE_FUNCTION_GRAPH_TRACER if !DYNAMIC_FTRACE && PPC64
+ select HAVE_FUNCTION_GRAPH_TRACER if PPC64
select ARCH_WANT_OPTIONAL_GPIOLIB
select HAVE_IDE
select HAVE_IOREMAP_PROT
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index a32699e..9f61fd6 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -908,6 +908,12 @@ _GLOBAL(ftrace_caller)
ftrace_call:
bl ftrace_stub
nop
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+.globl ftrace_graph_call
+ftrace_graph_call:
+ b ftrace_graph_stub
+_GLOBAL(ftrace_graph_stub)
+#endif
ld r0, 128(r1)
mtlr r0
addi r1, r1, 112
@@ -946,7 +952,7 @@ _GLOBAL(ftrace_stub)
#endif /* CONFIG_DYNAMIC_FTRACE */
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
-ftrace_graph_caller:
+_GLOBAL(ftrace_graph_caller)
/* load r4 with local address */
ld r4, 128(r1)
subi r4, r4, MCOUNT_INSN_SIZE
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index c9b1547..7538b94 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -43,7 +43,8 @@ static unsigned char *ftrace_nop_replace(void)
return (char *)&ftrace_nop;
}
-static unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr)
+static unsigned char *
+ftrace_call_replace(unsigned long ip, unsigned long addr, int link)
{
static unsigned int op;
@@ -55,8 +56,9 @@ static unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr)
*/
addr = GET_ADDR(addr);
- /* Set to "bl addr" */
- op = 0x48000001 | (ftrace_calc_offset(ip, addr) & 0x03fffffc);
+ /* if (link) set op to 'bl' else 'b' */
+ op = 0x48000000 | (link ? 1 : 0);
+ op |= (ftrace_calc_offset(ip, addr) & 0x03fffffc);
/*
* No locking needed, this must be called via kstop_machine
@@ -344,7 +346,7 @@ int ftrace_make_nop(struct module *mod,
*/
if (test_24bit_addr(ip, addr)) {
/* within range */
- old = ftrace_call_replace(ip, addr);
+ old = ftrace_call_replace(ip, addr, 1);
new = ftrace_nop_replace();
return ftrace_modify_code(ip, old, new);
}
@@ -484,7 +486,7 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
if (test_24bit_addr(ip, addr)) {
/* within range */
old = ftrace_nop_replace();
- new = ftrace_call_replace(ip, addr);
+ new = ftrace_call_replace(ip, addr, 1);
return ftrace_modify_code(ip, old, new);
}
@@ -513,7 +515,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
int ret;
memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
- new = ftrace_call_replace(ip, (unsigned long)func);
+ new = ftrace_call_replace(ip, (unsigned long)func, 1);
ret = ftrace_modify_code(ip, old, new);
return ret;
@@ -532,6 +534,39 @@ int __init ftrace_dyn_arch_init(void *data)
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+#ifdef CONFIG_DYNAMIC_FTRACE
+extern void ftrace_graph_call(void);
+extern void ftrace_graph_stub(void);
+
+int ftrace_enable_ftrace_graph_caller(void)
+{
+ unsigned long ip = (unsigned long)(&ftrace_graph_call);
+ unsigned long addr = (unsigned long)(&ftrace_graph_caller);
+ unsigned long stub = (unsigned long)(&ftrace_graph_stub);
+ unsigned char old[MCOUNT_INSN_SIZE], *new;
+
+ new = ftrace_call_replace(ip, stub, 0);
+ memcpy(old, new, MCOUNT_INSN_SIZE);
+ new = ftrace_call_replace(ip, addr, 0);
+
+ return ftrace_modify_code(ip, old, new);
+}
+
+int ftrace_disable_ftrace_graph_caller(void)
+{
+ unsigned long ip = (unsigned long)(&ftrace_graph_call);
+ unsigned long addr = (unsigned long)(&ftrace_graph_caller);
+ unsigned long stub = (unsigned long)(&ftrace_graph_stub);
+ unsigned char old[MCOUNT_INSN_SIZE], *new;
+
+ new = ftrace_call_replace(ip, addr, 0);
+ memcpy(old, new, MCOUNT_INSN_SIZE);
+ new = ftrace_call_replace(ip, stub, 0);
+
+ return ftrace_modify_code(ip, old, new);
+}
+#endif /* CONFIG_DYNAMIC_FTRACE */
+
/*
* Hook the return address and push it in the stack of return addrs
* in current thread info.
--
1.5.6.5
--
WARNING: multiple messages have this Message-ID (diff)
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
linuxppc-dev@ozlabs.org, Paul Mackerras <paulus@samba.org>,
Steven Rostedt <srostedt@redhat.com>
Subject: [PATCH 3/7][RFC] powerpc64, tracing: add function graph tracer with dynamic tracing
Date: Wed, 11 Feb 2009 20:10:54 -0500 [thread overview]
Message-ID: <20090212011343.074329920@goodmis.org> (raw)
In-Reply-To: 20090212011051.265346435@goodmis.org
[-- Attachment #1: 0003-powerpc64-tracing-add-function-graph-tracer-with-d.patch --]
[-- Type: text/plain, Size: 4609 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
This is the port of the function graph tracer to PowerPC with
dynamic tracing.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
arch/powerpc/Kconfig | 2 +-
arch/powerpc/kernel/entry_64.S | 8 ++++++-
arch/powerpc/kernel/ftrace.c | 47 ++++++++++++++++++++++++++++++++++-----
3 files changed, 49 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index ca4647e..6e1ee1b 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -111,7 +111,7 @@ config PPC
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_DYNAMIC_FTRACE
select HAVE_FUNCTION_TRACER
- select HAVE_FUNCTION_GRAPH_TRACER if !DYNAMIC_FTRACE && PPC64
+ select HAVE_FUNCTION_GRAPH_TRACER if PPC64
select ARCH_WANT_OPTIONAL_GPIOLIB
select HAVE_IDE
select HAVE_IOREMAP_PROT
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index a32699e..9f61fd6 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -908,6 +908,12 @@ _GLOBAL(ftrace_caller)
ftrace_call:
bl ftrace_stub
nop
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+.globl ftrace_graph_call
+ftrace_graph_call:
+ b ftrace_graph_stub
+_GLOBAL(ftrace_graph_stub)
+#endif
ld r0, 128(r1)
mtlr r0
addi r1, r1, 112
@@ -946,7 +952,7 @@ _GLOBAL(ftrace_stub)
#endif /* CONFIG_DYNAMIC_FTRACE */
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
-ftrace_graph_caller:
+_GLOBAL(ftrace_graph_caller)
/* load r4 with local address */
ld r4, 128(r1)
subi r4, r4, MCOUNT_INSN_SIZE
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index c9b1547..7538b94 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -43,7 +43,8 @@ static unsigned char *ftrace_nop_replace(void)
return (char *)&ftrace_nop;
}
-static unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr)
+static unsigned char *
+ftrace_call_replace(unsigned long ip, unsigned long addr, int link)
{
static unsigned int op;
@@ -55,8 +56,9 @@ static unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr)
*/
addr = GET_ADDR(addr);
- /* Set to "bl addr" */
- op = 0x48000001 | (ftrace_calc_offset(ip, addr) & 0x03fffffc);
+ /* if (link) set op to 'bl' else 'b' */
+ op = 0x48000000 | (link ? 1 : 0);
+ op |= (ftrace_calc_offset(ip, addr) & 0x03fffffc);
/*
* No locking needed, this must be called via kstop_machine
@@ -344,7 +346,7 @@ int ftrace_make_nop(struct module *mod,
*/
if (test_24bit_addr(ip, addr)) {
/* within range */
- old = ftrace_call_replace(ip, addr);
+ old = ftrace_call_replace(ip, addr, 1);
new = ftrace_nop_replace();
return ftrace_modify_code(ip, old, new);
}
@@ -484,7 +486,7 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
if (test_24bit_addr(ip, addr)) {
/* within range */
old = ftrace_nop_replace();
- new = ftrace_call_replace(ip, addr);
+ new = ftrace_call_replace(ip, addr, 1);
return ftrace_modify_code(ip, old, new);
}
@@ -513,7 +515,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
int ret;
memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
- new = ftrace_call_replace(ip, (unsigned long)func);
+ new = ftrace_call_replace(ip, (unsigned long)func, 1);
ret = ftrace_modify_code(ip, old, new);
return ret;
@@ -532,6 +534,39 @@ int __init ftrace_dyn_arch_init(void *data)
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+#ifdef CONFIG_DYNAMIC_FTRACE
+extern void ftrace_graph_call(void);
+extern void ftrace_graph_stub(void);
+
+int ftrace_enable_ftrace_graph_caller(void)
+{
+ unsigned long ip = (unsigned long)(&ftrace_graph_call);
+ unsigned long addr = (unsigned long)(&ftrace_graph_caller);
+ unsigned long stub = (unsigned long)(&ftrace_graph_stub);
+ unsigned char old[MCOUNT_INSN_SIZE], *new;
+
+ new = ftrace_call_replace(ip, stub, 0);
+ memcpy(old, new, MCOUNT_INSN_SIZE);
+ new = ftrace_call_replace(ip, addr, 0);
+
+ return ftrace_modify_code(ip, old, new);
+}
+
+int ftrace_disable_ftrace_graph_caller(void)
+{
+ unsigned long ip = (unsigned long)(&ftrace_graph_call);
+ unsigned long addr = (unsigned long)(&ftrace_graph_caller);
+ unsigned long stub = (unsigned long)(&ftrace_graph_stub);
+ unsigned char old[MCOUNT_INSN_SIZE], *new;
+
+ new = ftrace_call_replace(ip, addr, 0);
+ memcpy(old, new, MCOUNT_INSN_SIZE);
+ new = ftrace_call_replace(ip, stub, 0);
+
+ return ftrace_modify_code(ip, old, new);
+}
+#endif /* CONFIG_DYNAMIC_FTRACE */
+
/*
* Hook the return address and push it in the stack of return addrs
* in current thread info.
--
1.5.6.5
--
next prev parent reply other threads:[~2009-02-12 1:13 UTC|newest]
Thread overview: 56+ 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 ` 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 ` Steven Rostedt
2009-02-12 1:10 ` [PATCH 2/7][RFC] powerpc64: port of the function graph tracer Steven Rostedt
2009-02-12 1:10 ` Steven Rostedt
2009-02-13 4:12 ` Benjamin Herrenschmidt
2009-02-13 4:12 ` Benjamin Herrenschmidt
2009-02-13 4:18 ` Steven Rostedt
2009-02-13 4:18 ` Steven Rostedt
2009-02-12 1:10 ` Steven Rostedt [this message]
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:15 ` Benjamin Herrenschmidt
2009-02-13 4:20 ` Steven Rostedt
2009-02-13 4:20 ` Steven Rostedt
2009-02-13 5:22 ` Steven Rostedt
2009-02-13 5:22 ` Steven Rostedt
2009-02-12 1:10 ` [PATCH 4/7][RFC] powerpc64, ftrace: save toc only on modules for function graph Steven Rostedt
2009-02-12 1:10 ` Steven Rostedt
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 ` 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 ` Steven Rostedt
2009-02-12 1:10 ` [PATCH 7/7][RFC] powerpc32, ftrace: dynamic function graph tracer Steven Rostedt
2009-02-12 1:10 ` Steven Rostedt
2009-02-12 1:55 ` [PATCH 0/7][RFC] function graph tracer port to PowerPC Frederic Weisbecker
2009-02-12 1:55 ` Frederic Weisbecker
2009-02-12 2:16 ` Steven Rostedt
2009-02-12 2:16 ` Steven Rostedt
2009-02-12 4:08 ` Frederic Weisbecker
2009-02-12 4:08 ` Frederic Weisbecker
2009-02-12 16:31 ` Steven Rostedt
2009-02-12 16:31 ` Steven Rostedt
2009-02-12 16:47 ` Frederic Weisbecker
2009-02-12 16:47 ` Frederic Weisbecker
2009-02-12 16:58 ` Steven Rostedt
2009-02-12 16:58 ` Steven Rostedt
2009-02-13 4:18 ` Benjamin Herrenschmidt
2009-02-13 4:18 ` Benjamin Herrenschmidt
2009-02-12 2:23 ` Michael Ellerman
2009-02-12 2:23 ` Michael Ellerman
2009-02-12 2:37 ` Steven Rostedt
2009-02-12 2:37 ` Steven Rostedt
2009-02-12 16:35 ` Steven Rostedt
2009-02-12 16:35 ` Steven Rostedt
2009-02-12 23:32 ` Geoff Levand
2009-02-12 23:32 ` Geoff Levand
2009-02-12 23:41 ` Steven Rostedt
2009-02-12 23:41 ` Steven Rostedt
2009-02-12 23:44 ` Josh Boyer
2009-02-12 23:44 ` Josh Boyer
2009-02-12 23:44 ` Geoff Levand
2009-02-12 23:44 ` Geoff Levand
2009-02-12 23:51 ` Steven Rostedt
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.074329920@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.