* [PATCH 0/7] [git pull] powerpc function graph tracer
@ 2009-02-13 5:23 Steven Rostedt
2009-02-13 5:23 ` [PATCH 1/7] tracing/function-graph-tracer: make arch generic push pop functions Steven Rostedt
` (6 more replies)
0 siblings, 7 replies; 15+ messages in thread
From: Steven Rostedt @ 2009-02-13 5:23 UTC (permalink / raw)
To: linux-kernel
Cc: Benjamin Herrenschmidt, Paul Mackerras, Ingo Molnar,
Andrew Morton, Frederic Weisbecker, Geoff Levand
Benjamin,
I figured you can run it through your test boxes.
Please pull the latest ppc/ftrace tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
ppc/ftrace
Steven Rostedt (7):
tracing/function-graph-tracer: make arch generic push pop functions
powerpc64: port of the function graph tracer
powerpc64, tracing: add function graph tracer with dynamic tracing
powerpc64, ftrace: save toc only on modules for function graph
powerpc32, ftrace: save and restore mcount regs with macro
powerpc32, ftrace: port function graph tracer to ppc32, static only
powerpc32, ftrace: dynamic function graph tracer
----
arch/powerpc/Kconfig | 1 +
arch/powerpc/include/asm/ftrace.h | 39 ++++++++++-
arch/powerpc/kernel/Makefile | 9 +-
arch/powerpc/kernel/entry_32.S | 115 ++++++++++++++---------------
arch/powerpc/kernel/entry_64.S | 89 +++++++++++++++++++++-
arch/powerpc/kernel/ftrace.c | 135 ++++++++++++++++++++++++++++++++--
arch/powerpc/kernel/process.c | 16 ++++
arch/powerpc/kernel/vmlinux.lds.S | 1 +
arch/x86/include/asm/ftrace.h | 25 ------
arch/x86/kernel/ftrace.c | 75 +------------------
include/linux/ftrace.h | 24 ++++++
kernel/trace/trace_functions_graph.c | 75 +++++++++++++++++++
12 files changed, 428 insertions(+), 176 deletions(-)
--
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 1/7] tracing/function-graph-tracer: make arch generic push pop functions
2009-02-13 5:23 [PATCH 0/7] [git pull] powerpc function graph tracer Steven Rostedt
@ 2009-02-13 5:23 ` Steven Rostedt
2009-02-17 4:49 ` Steven Rostedt
2009-02-13 5:24 ` [PATCH 2/7] powerpc64: port of the function graph tracer Steven Rostedt
` (5 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Steven Rostedt @ 2009-02-13 5:23 UTC (permalink / raw)
To: linux-kernel
Cc: Benjamin Herrenschmidt, Paul Mackerras, Ingo Molnar,
Andrew Morton, Frederic Weisbecker, Geoff Levand, Steven Rostedt
[-- Attachment #1: 0001-tracing-function-graph-tracer-make-arch-generic-pus.patch --]
[-- Type: text/plain, Size: 7126 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
There is nothing really arch specific of the push and pop functions
used by the function graph tracer. This patch moves them to generic
code.
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
arch/x86/include/asm/ftrace.h | 25 -----------
arch/x86/kernel/ftrace.c | 75 +---------------------------------
include/linux/ftrace.h | 24 +++++++++++
kernel/trace/trace_functions_graph.c | 75 ++++++++++++++++++++++++++++++++++
4 files changed, 100 insertions(+), 99 deletions(-)
diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
index b55b4a7..db24c22 100644
--- a/arch/x86/include/asm/ftrace.h
+++ b/arch/x86/include/asm/ftrace.h
@@ -55,29 +55,4 @@ struct dyn_arch_ftrace {
#endif /* __ASSEMBLY__ */
#endif /* CONFIG_FUNCTION_TRACER */
-#ifdef CONFIG_FUNCTION_GRAPH_TRACER
-
-#ifndef __ASSEMBLY__
-
-/*
- * Stack of return addresses for functions
- * of a thread.
- * Used in struct thread_info
- */
-struct ftrace_ret_stack {
- unsigned long ret;
- unsigned long func;
- unsigned long long calltime;
-};
-
-/*
- * Primary handler of a function return.
- * It relays on ftrace_return_to_handler.
- * Defined in entry_32/64.S
- */
-extern void return_to_handler(void);
-
-#endif /* __ASSEMBLY__ */
-#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
-
#endif /* _ASM_X86_FTRACE_H */
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 1b43086..258c8d5 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -389,79 +389,6 @@ void ftrace_nmi_exit(void)
#endif /* !CONFIG_DYNAMIC_FTRACE */
-/* Add a function return address to the trace stack on thread info.*/
-static int push_return_trace(unsigned long ret, unsigned long long time,
- unsigned long func, int *depth)
-{
- int index;
-
- if (!current->ret_stack)
- return -EBUSY;
-
- /* The return trace stack is full */
- if (current->curr_ret_stack == FTRACE_RETFUNC_DEPTH - 1) {
- atomic_inc(¤t->trace_overrun);
- return -EBUSY;
- }
-
- index = ++current->curr_ret_stack;
- barrier();
- current->ret_stack[index].ret = ret;
- current->ret_stack[index].func = func;
- current->ret_stack[index].calltime = time;
- *depth = index;
-
- return 0;
-}
-
-/* Retrieve a function return address to the trace stack on thread info.*/
-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;
- trace->overrun = atomic_read(¤t->trace_overrun);
- trace->depth = index;
- barrier();
- current->curr_ret_stack--;
-
-}
-
-/*
- * Send the trace to the ring-buffer.
- * @return the original return address.
- */
-unsigned long ftrace_return_to_handler(void)
-{
- struct ftrace_graph_ret trace;
- unsigned long ret;
-
- pop_return_trace(&trace, &ret);
- 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;
-}
-
/*
* Hook the return address and push it in the stack of return addrs
* in current thread info.
@@ -520,7 +447,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
calltime = cpu_clock(raw_smp_processor_id());
- if (push_return_trace(old, calltime,
+ if (ftrace_push_return_trace(old, calltime,
self_addr, &trace.depth) == -EBUSY) {
*parent = old;
return;
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 677432b..a7f8134 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -380,6 +380,30 @@ struct ftrace_graph_ret {
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
/*
+ * Stack of return addresses for functions
+ * of a thread.
+ * Used in struct thread_info
+ */
+struct ftrace_ret_stack {
+ unsigned long ret;
+ unsigned long func;
+ unsigned long long calltime;
+};
+
+/*
+ * Primary handler of a function return.
+ * It relays on ftrace_return_to_handler.
+ * Defined in entry_32/64.S
+ */
+extern void return_to_handler(void);
+
+extern int
+ftrace_push_return_trace(unsigned long ret, unsigned long long time,
+ unsigned long func, int *depth);
+extern void
+ftrace_pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret);
+
+/*
* Sometimes we don't want to trace a function with the function
* graph tracer but we want them to keep traced by the usual function
* tracer if the function graph tracer is not configured.
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index 930c08e..dce71a5 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -42,6 +42,81 @@ static struct tracer_flags tracer_flags = {
/* pid on the last trace processed */
static pid_t last_pid[NR_CPUS] = { [0 ... NR_CPUS-1] = -1 };
+/* Add a function return address to the trace stack on thread info.*/
+int
+ftrace_push_return_trace(unsigned long ret, unsigned long long time,
+ unsigned long func, int *depth)
+{
+ int index;
+
+ if (!current->ret_stack)
+ return -EBUSY;
+
+ /* The return trace stack is full */
+ if (current->curr_ret_stack == FTRACE_RETFUNC_DEPTH - 1) {
+ atomic_inc(¤t->trace_overrun);
+ return -EBUSY;
+ }
+
+ index = ++current->curr_ret_stack;
+ barrier();
+ current->ret_stack[index].ret = ret;
+ current->ret_stack[index].func = func;
+ current->ret_stack[index].calltime = time;
+ *depth = index;
+
+ return 0;
+}
+
+/* Retrieve a function return address to the trace stack on thread info.*/
+void
+ftrace_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;
+ trace->overrun = atomic_read(¤t->trace_overrun);
+ trace->depth = index;
+ barrier();
+ current->curr_ret_stack--;
+
+}
+
+/*
+ * Send the trace to the ring-buffer.
+ * @return the original return address.
+ */
+unsigned long ftrace_return_to_handler(void)
+{
+ struct ftrace_graph_ret trace;
+ unsigned long ret;
+
+ ftrace_pop_return_trace(&trace, &ret);
+ 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;
+}
+
static int graph_trace_init(struct trace_array *tr)
{
int cpu, ret;
--
1.5.6.5
--
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/7] powerpc64: port of the function graph tracer
2009-02-13 5:23 [PATCH 0/7] [git pull] powerpc function graph tracer Steven Rostedt
2009-02-13 5:23 ` [PATCH 1/7] tracing/function-graph-tracer: make arch generic push pop functions Steven Rostedt
@ 2009-02-13 5:24 ` Steven Rostedt
2009-02-13 5:24 ` [PATCH 3/7] powerpc64, tracing: add function graph tracer with dynamic tracing Steven Rostedt
` (4 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2009-02-13 5:24 UTC (permalink / raw)
To: linux-kernel
Cc: Benjamin Herrenschmidt, Paul Mackerras, Ingo Molnar,
Andrew Morton, Frederic Weisbecker, Geoff Levand, Steven Rostedt
[-- Attachment #1: 0002-powerpc64-port-of-the-function-graph-tracer.patch --]
[-- Type: text/plain, Size: 8838 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
This is a port of the function graph tracer that was written by
Frederic Weisbecker for the x86.
This only works for PPC64 at the moment and only for static tracing.
PPC32 and dynamic function graph tracing support will come later.
The trace produces a visual calling of functions:
# tracer: function_graph
#
# CPU DURATION FUNCTION CALLS
# | | | | | | |
0) 2.224 us | }
0) ! 271.024 us | }
0) ! 320.080 us | }
0) ! 324.656 us | }
0) ! 329.136 us | }
0) | .put_prev_task_fair() {
0) | .update_curr() {
0) 2.240 us | .update_min_vruntime();
0) 6.512 us | }
0) 2.528 us | .__enqueue_entity();
0) + 15.536 us | }
0) | .pick_next_task_fair() {
0) 2.032 us | .__pick_next_entity();
0) 2.064 us | .__clear_buddies();
0) | .set_next_entity() {
0) 2.672 us | .__dequeue_entity();
0) 6.864 us | }
Geoff Lavand tested on PS3.
Tested-by: Geoff Levand <geoffrey.levand@am.sony.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
arch/powerpc/Kconfig | 1 +
arch/powerpc/kernel/Makefile | 9 ++--
arch/powerpc/kernel/entry_64.S | 58 +++++++++++++++++++++++++-
arch/powerpc/kernel/ftrace.c | 79 ++++++++++++++++++++++++++++++++++++-
arch/powerpc/kernel/process.c | 16 +++++++
arch/powerpc/kernel/vmlinux.lds.S | 1 +
6 files changed, 154 insertions(+), 10 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 74cc312..ca4647e 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -111,6 +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 ARCH_WANT_OPTIONAL_GPIOLIB
select HAVE_IDE
select HAVE_IOREMAP_PROT
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 8d1a419..a70aeea 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -18,12 +18,10 @@ CFLAGS_REMOVE_cputable.o = -pg -mno-sched-epilog
CFLAGS_REMOVE_prom_init.o = -pg -mno-sched-epilog
CFLAGS_REMOVE_btext.o = -pg -mno-sched-epilog
CFLAGS_REMOVE_prom.o = -pg -mno-sched-epilog
-
-ifdef CONFIG_DYNAMIC_FTRACE
-# dynamic ftrace setup.
+# do not trace tracer code
CFLAGS_REMOVE_ftrace.o = -pg -mno-sched-epilog
-endif
-
+# timers used by tracing
+CFLAGS_REMOVE_time.o = -pg -mno-sched-epilog
endif
obj-y := cputable.o ptrace.o syscalls.o \
@@ -94,6 +92,7 @@ obj-$(CONFIG_AUDIT) += audit.o
obj64-$(CONFIG_AUDIT) += compat_audit.o
obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o
+obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o
obj-$(CONFIG_8XX_MINIMAL_FPEMU) += softemu8xx.o
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 383ed6e..a32699e 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -931,13 +931,65 @@ _GLOBAL(_mcount)
ld r5,0(r5)
mtctr r5
bctrl
-
nop
+
+
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ b ftrace_graph_caller
+#endif
ld r0, 128(r1)
mtlr r0
addi r1, r1, 112
_GLOBAL(ftrace_stub)
blr
-#endif
-#endif
+#endif /* CONFIG_DYNAMIC_FTRACE */
+
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ftrace_graph_caller:
+ /* load r4 with local address */
+ ld r4, 128(r1)
+ subi r4, r4, MCOUNT_INSN_SIZE
+
+ /* get the parent address */
+ ld r11, 112(r1)
+ addi r3, r11, 16
+
+ bl .prepare_ftrace_return
+ nop
+
+ ld r0, 128(r1)
+ mtlr r0
+ addi r1, r1, 112
+ blr
+
+_GLOBAL(return_to_handler)
+ /* need to save return values */
+ std r4, -32(r1)
+ std r3, -24(r1)
+ /* save TOC */
+ std r2, -16(r1)
+ std r31, -8(r1)
+ mr r31, r1
+ stdu r1, -112(r1)
+
+ /* update the TOC */
+ LOAD_REG_IMMEDIATE(r4,ftrace_return_to_handler)
+ ld r2, 8(r4)
+
+ bl .ftrace_return_to_handler
+ nop
+
+ /* return value has real return address */
+ mtlr r3
+
+ ld r1, 0(r1)
+ ld r4, -32(r1)
+ ld r3, -24(r1)
+ ld r2, -16(r1)
+ ld r31, -8(r1)
+
+ /* Jump back to real return address */
+ blr
+#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
+#endif /* CONFIG_FUNCTION_TRACER */
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index 4112175..c9b1547 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -5,6 +5,9 @@
*
* Thanks goes out to P.A. Semi, Inc for supplying me with a PPC64 box.
*
+ * Added function graph tracer code, taken from x86 that was written
+ * by Frederic Weisbecker, and ported to PPC by Steven Rostedt.
+ *
*/
#include <linux/spinlock.h>
@@ -20,8 +23,6 @@
#include <asm/code-patching.h>
#include <asm/ftrace.h>
-static unsigned int ftrace_nop = PPC_NOP_INSTR;
-
#ifdef CONFIG_PPC32
# define GET_ADDR(addr) addr
#else
@@ -29,6 +30,8 @@ static unsigned int ftrace_nop = PPC_NOP_INSTR;
# define GET_ADDR(addr) (*(unsigned long *)addr)
#endif
+#ifdef CONFIG_DYNAMIC_FTRACE
+static unsigned int ftrace_nop = PPC_NOP_INSTR;
static unsigned int ftrace_calc_offset(long ip, long addr)
{
@@ -525,3 +528,75 @@ int __init ftrace_dyn_arch_init(void *data)
return 0;
}
+#endif /* CONFIG_DYNAMIC_FTRACE */
+
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+
+/*
+ * Hook the return address and push it in the stack of return addrs
+ * in current thread info.
+ */
+void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
+{
+ unsigned long old;
+ unsigned long long calltime;
+ int faulted;
+ struct ftrace_graph_ent trace;
+ unsigned long return_hooker = (unsigned long)
+ &return_to_handler;
+
+ if (unlikely(atomic_read(¤t->tracing_graph_pause)))
+ return;
+
+ return_hooker = GET_ADDR(return_hooker);
+
+ /*
+ * Protect against fault, even if it shouldn't
+ * happen. This tool is too much intrusive to
+ * ignore such a protection.
+ */
+ asm volatile(
+ "1: " PPC_LL "%[old], 0(%[parent])\n"
+ "2: " PPC_STL "%[return_hooker], 0(%[parent])\n"
+ " li %[faulted], 0\n"
+ "3:"
+
+ ".section .fixup, \"ax\"\n"
+ "4: li %[faulted], 1\n"
+ " b 3b\n"
+ ".previous\n"
+
+ ".section __ex_table,\"a\"\n"
+ PPC_LONG_ALIGN "\n"
+ PPC_LONG "1b,4b\n"
+ PPC_LONG "2b,4b\n"
+ ".previous"
+
+ : [old] "=r" (old), [faulted] "=r" (faulted)
+ : [parent] "r" (parent), [return_hooker] "r" (return_hooker)
+ : "memory"
+ );
+
+ if (unlikely(faulted)) {
+ ftrace_graph_stop();
+ WARN_ON(1);
+ return;
+ }
+
+ calltime = cpu_clock(raw_smp_processor_id());
+
+ if (ftrace_push_return_trace(old, calltime,
+ self_addr, &trace.depth) == -EBUSY) {
+ *parent = old;
+ return;
+ }
+
+ trace.func = self_addr;
+
+ /* Only trace if the calling function expects to */
+ if (!ftrace_graph_entry(&trace)) {
+ current->curr_ret_stack--;
+ *parent = old;
+ }
+}
+#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index fb7049c..8ede428 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -33,6 +33,7 @@
#include <linux/mqueue.h>
#include <linux/hardirq.h>
#include <linux/utsname.h>
+#include <linux/ftrace.h>
#include <linux/kernel_stat.h>
#include <asm/pgtable.h>
@@ -1008,6 +1009,14 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
unsigned long sp, ip, lr, newsp;
int count = 0;
int firstframe = 1;
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ int curr_frame = current->curr_ret_stack;
+ extern void return_to_handler(void);
+ unsigned long addr = (unsigned long)return_to_handler;
+#ifdef CONFIG_PPC64
+ addr = *(unsigned long*)addr;
+#endif
+#endif
sp = (unsigned long) stack;
if (tsk == NULL)
@@ -1030,6 +1039,13 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
ip = stack[STACK_FRAME_LR_SAVE];
if (!firstframe || ip != lr) {
printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ if (ip == addr && curr_frame >= 0) {
+ printk(" (%pS)",
+ (void *)current->ret_stack[curr_frame].ret);
+ curr_frame--;
+ }
+#endif
if (firstframe)
printk(" (unreliable)");
printk("\n");
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index 161b9b9..895af44 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -58,6 +58,7 @@ SECTIONS
SCHED_TEXT
LOCK_TEXT
KPROBES_TEXT
+ IRQENTRY_TEXT
#ifdef CONFIG_PPC32
*(.got1)
--
1.5.6.5
--
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 3/7] powerpc64, tracing: add function graph tracer with dynamic tracing
2009-02-13 5:23 [PATCH 0/7] [git pull] powerpc function graph tracer Steven Rostedt
2009-02-13 5:23 ` [PATCH 1/7] tracing/function-graph-tracer: make arch generic push pop functions Steven Rostedt
2009-02-13 5:24 ` [PATCH 2/7] powerpc64: port of the function graph tracer Steven Rostedt
@ 2009-02-13 5:24 ` Steven Rostedt
2009-02-13 5:24 ` [PATCH 4/7] powerpc64, ftrace: save toc only on modules for function graph Steven Rostedt
` (3 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2009-02-13 5:24 UTC (permalink / raw)
To: linux-kernel
Cc: Benjamin Herrenschmidt, Paul Mackerras, Ingo Molnar,
Andrew Morton, Frederic Weisbecker, Geoff Levand, Steven Rostedt
[-- Attachment #1: 0003-powerpc64-tracing-add-function-graph-tracer-with-d.patch --]
[-- Type: text/plain, Size: 4752 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
This is the port of the function graph tracer to PowerPC with
dynamic tracing.
Geoff Lavand tested on PS3.
Tested-by: Geoff Levand <geoffrey.levand@am.sony.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
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
--
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 4/7] powerpc64, ftrace: save toc only on modules for function graph
2009-02-13 5:23 [PATCH 0/7] [git pull] powerpc function graph tracer Steven Rostedt
` (2 preceding siblings ...)
2009-02-13 5:24 ` [PATCH 3/7] powerpc64, tracing: add function graph tracer with dynamic tracing Steven Rostedt
@ 2009-02-13 5:24 ` Steven Rostedt
2009-02-13 5:24 ` [PATCH 5/7] powerpc32, ftrace: save and restore mcount regs with macro Steven Rostedt
` (2 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2009-02-13 5:24 UTC (permalink / raw)
To: linux-kernel
Cc: Benjamin Herrenschmidt, Paul Mackerras, Ingo Molnar,
Andrew Morton, Frederic Weisbecker, Geoff Levand, Steven Rostedt
[-- Attachment #1: 0004-powerpc64-ftrace-save-toc-only-on-modules-for-func.patch --]
[-- Type: text/plain, Size: 3204 bytes --]
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.
Geoff Lavand tested on PS3.
Tested-by: Geoff Levand <geoffrey.levand@am.sony.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
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
--
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 5/7] powerpc32, ftrace: save and restore mcount regs with macro
2009-02-13 5:23 [PATCH 0/7] [git pull] powerpc function graph tracer Steven Rostedt
` (3 preceding siblings ...)
2009-02-13 5:24 ` [PATCH 4/7] powerpc64, ftrace: save toc only on modules for function graph Steven Rostedt
@ 2009-02-13 5:24 ` Steven Rostedt
2009-02-13 5:24 ` [PATCH 6/7] powerpc32, ftrace: port function graph tracer to ppc32, static only Steven Rostedt
2009-02-13 5:24 ` [PATCH 7/7] powerpc32, ftrace: dynamic function graph tracer Steven Rostedt
6 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2009-02-13 5:24 UTC (permalink / raw)
To: linux-kernel
Cc: Benjamin Herrenschmidt, Paul Mackerras, Ingo Molnar,
Andrew Morton, Frederic Weisbecker, Geoff Levand
[-- Attachment #1: 0005-powerpc32-ftrace-save-and-restore-mcount-regs-with.patch --]
[-- Type: text/plain, Size: 3400 bytes --]
From: Steven Rostedt <rostedt@goodmis.org>
Impact: clean up
Use a macro to save and restore the registers for PowerPC32,
since that code is duplicated.
This is similar to the work done by Cyrill Gorcunov for the
mcount code in x86_64.
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
arch/powerpc/include/asm/ftrace.h | 39 ++++++++++++++++++++-
arch/powerpc/kernel/entry_32.S | 68 +++++--------------------------------
2 files changed, 47 insertions(+), 60 deletions(-)
diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
index e5f2ae8..dde1296 100644
--- a/arch/powerpc/include/asm/ftrace.h
+++ b/arch/powerpc/include/asm/ftrace.h
@@ -5,7 +5,44 @@
#define MCOUNT_ADDR ((long)(_mcount))
#define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */
-#ifndef __ASSEMBLY__
+#ifdef __ASSEMBLY__
+
+/* Based off of objdump optput from glibc */
+
+#define MCOUNT_SAVE_FRAME \
+ stwu r1,-48(r1); \
+ stw r3, 12(r1); \
+ stw r4, 16(r1); \
+ stw r5, 20(r1); \
+ stw r6, 24(r1); \
+ mflr r3; \
+ lwz r4, 52(r1); \
+ mfcr r5; \
+ stw r7, 28(r1); \
+ stw r8, 32(r1); \
+ stw r9, 36(r1); \
+ stw r10,40(r1); \
+ stw r3, 44(r1); \
+ stw r5, 8(r1)
+
+#define MCOUNT_RESTORE_FRAME \
+ lwz r6, 8(r1); \
+ lwz r0, 44(r1); \
+ lwz r3, 12(r1); \
+ mtctr r0; \
+ lwz r4, 16(r1); \
+ mtcr r6; \
+ lwz r5, 20(r1); \
+ lwz r6, 24(r1); \
+ lwz r0, 52(r1); \
+ lwz r7, 28(r1); \
+ lwz r8, 32(r1); \
+ mtlr r0; \
+ lwz r9, 36(r1); \
+ lwz r10,40(r1); \
+ addi r1, r1, 48
+
+#else /* !__ASSEMBLY__ */
extern void _mcount(void);
#ifdef CONFIG_DYNAMIC_FTRACE
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 6f7eb7e..eb0c13e 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -1176,59 +1176,22 @@ _GLOBAL(_mcount)
bctr
_GLOBAL(ftrace_caller)
- /* Based off of objdump optput from glibc */
- stwu r1,-48(r1)
- stw r3, 12(r1)
- stw r4, 16(r1)
- stw r5, 20(r1)
- stw r6, 24(r1)
- mflr r3
- lwz r4, 52(r1)
- mfcr r5
- stw r7, 28(r1)
- stw r8, 32(r1)
- stw r9, 36(r1)
- stw r10,40(r1)
- stw r3, 44(r1)
- stw r5, 8(r1)
+ MCOUNT_SAVE_FRAME
+ /* r3 ends up with link register */
subi r3, r3, MCOUNT_INSN_SIZE
.globl ftrace_call
ftrace_call:
bl ftrace_stub
nop
- lwz r6, 8(r1)
- lwz r0, 44(r1)
- lwz r3, 12(r1)
- mtctr r0
- lwz r4, 16(r1)
- mtcr r6
- lwz r5, 20(r1)
- lwz r6, 24(r1)
- lwz r0, 52(r1)
- lwz r7, 28(r1)
- lwz r8, 32(r1)
- mtlr r0
- lwz r9, 36(r1)
- lwz r10,40(r1)
- addi r1, r1, 48
+
+ MCOUNT_RESTORE_FRAME
+ /* old link register ends up in ctr reg */
bctr
#else
_GLOBAL(mcount)
_GLOBAL(_mcount)
- stwu r1,-48(r1)
- stw r3, 12(r1)
- stw r4, 16(r1)
- stw r5, 20(r1)
- stw r6, 24(r1)
- mflr r3
- lwz r4, 52(r1)
- mfcr r5
- stw r7, 28(r1)
- stw r8, 32(r1)
- stw r9, 36(r1)
- stw r10,40(r1)
- stw r3, 44(r1)
- stw r5, 8(r1)
+
+ MCOUNT_SAVE_FRAME
subi r3, r3, MCOUNT_INSN_SIZE
LOAD_REG_ADDR(r5, ftrace_trace_function)
@@ -1239,21 +1202,8 @@ _GLOBAL(_mcount)
nop
- lwz r6, 8(r1)
- lwz r0, 44(r1)
- lwz r3, 12(r1)
- mtctr r0
- lwz r4, 16(r1)
- mtcr r6
- lwz r5, 20(r1)
- lwz r6, 24(r1)
- lwz r0, 52(r1)
- lwz r7, 28(r1)
- lwz r8, 32(r1)
- mtlr r0
- lwz r9, 36(r1)
- lwz r10,40(r1)
- addi r1, r1, 48
+ MCOUNT_RESTORE_FRAME
+
bctr
#endif
--
1.5.6.5
--
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 6/7] powerpc32, ftrace: port function graph tracer to ppc32, static only
2009-02-13 5:23 [PATCH 0/7] [git pull] powerpc function graph tracer Steven Rostedt
` (4 preceding siblings ...)
2009-02-13 5:24 ` [PATCH 5/7] powerpc32, ftrace: save and restore mcount regs with macro Steven Rostedt
@ 2009-02-13 5:24 ` Steven Rostedt
2009-02-13 5:24 ` [PATCH 7/7] powerpc32, ftrace: dynamic function graph tracer Steven Rostedt
6 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2009-02-13 5:24 UTC (permalink / raw)
To: linux-kernel
Cc: Benjamin Herrenschmidt, Paul Mackerras, Ingo Molnar,
Andrew Morton, Frederic Weisbecker, Geoff Levand
[-- Attachment #1: 0006-powerpc32-ftrace-port-function-graph-tracer-to-ppc.patch --]
[-- Type: text/plain, Size: 2583 bytes --]
From: Steven Rostedt <rostedt@goodmis.org>
This patch ports the function graph tracer for PowerPC, but only
for static function tracing.
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
arch/powerpc/Kconfig | 2 +-
arch/powerpc/kernel/entry_32.S | 43 +++++++++++++++++++++++++++++++++++++++-
arch/powerpc/kernel/ftrace.c | 2 +-
3 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 6e1ee1b..9e4bd20 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 PPC64
+ select HAVE_FUNCTION_GRAPH_TRACER if PPC64 || !DYNAMIC_FTRACE
select ARCH_WANT_OPTIONAL_GPIOLIB
select HAVE_IDE
select HAVE_IOREMAP_PROT
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index eb0c13e..9cf7083 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -1199,9 +1199,11 @@ _GLOBAL(_mcount)
mtctr r5
bctrl
-
nop
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ b ftrace_graph_caller
+#endif
MCOUNT_RESTORE_FRAME
bctr
@@ -1210,4 +1212,43 @@ _GLOBAL(_mcount)
_GLOBAL(ftrace_stub)
blr
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+_GLOBAL(ftrace_graph_caller)
+ /* load r4 with local address */
+ lwz r4, 44(r1)
+ subi r4, r4, MCOUNT_INSN_SIZE
+
+ /* get the parent address */
+ addi r3, r1, 52
+
+ bl prepare_ftrace_return
+ nop
+
+ MCOUNT_RESTORE_FRAME
+ /* old link register ends up in ctr reg */
+ bctr
+
+_GLOBAL(return_to_handler)
+ /* need to save return values */
+ stwu r1, -32(r1)
+ stw r3, 20(r1)
+ stw r4, 16(r1)
+ stw r31, 12(r1)
+ mr r31, r1
+
+ bl ftrace_return_to_handler
+ nop
+
+ /* return value has real return address */
+ mtlr r3
+
+ lwz r3, 20(r1)
+ lwz r4, 16(r1)
+ lwz r31,12(r1)
+ lwz r1, 0(r1)
+
+ /* Jump back to real return address */
+ blr
+#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
+
#endif /* CONFIG_MCOUNT */
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index 5c6dfa9..dddd99b 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -603,7 +603,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
"1: " PPC_LL "%[old], 0(%[parent])\n"
"2: " PPC_STL "%[return_hooker], 0(%[parent])\n"
" li %[faulted], 0\n"
- "3:"
+ "3:\n"
".section .fixup, \"ax\"\n"
"4: li %[faulted], 1\n"
--
1.5.6.5
--
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 7/7] powerpc32, ftrace: dynamic function graph tracer
2009-02-13 5:23 [PATCH 0/7] [git pull] powerpc function graph tracer Steven Rostedt
` (5 preceding siblings ...)
2009-02-13 5:24 ` [PATCH 6/7] powerpc32, ftrace: port function graph tracer to ppc32, static only Steven Rostedt
@ 2009-02-13 5:24 ` Steven Rostedt
6 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2009-02-13 5:24 UTC (permalink / raw)
To: linux-kernel
Cc: Benjamin Herrenschmidt, Paul Mackerras, Ingo Molnar,
Andrew Morton, Frederic Weisbecker, Geoff Levand
[-- Attachment #1: 0007-powerpc32-ftrace-dynamic-function-graph-tracer.patch --]
[-- Type: text/plain, Size: 1452 bytes --]
From: Steven Rostedt <rostedt@goodmis.org>
This patch gets function graph tracing working with dynamic function
tracer on PowerPC32.
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
arch/powerpc/Kconfig | 2 +-
arch/powerpc/kernel/entry_32.S | 8 ++++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 9e4bd20..40b7981 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 PPC64 || !DYNAMIC_FTRACE
+ select HAVE_FUNCTION_GRAPH_TRACER
select ARCH_WANT_OPTIONAL_GPIOLIB
select HAVE_IDE
select HAVE_IOREMAP_PROT
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 9cf7083..529bfbb 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -1183,7 +1183,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
MCOUNT_RESTORE_FRAME
/* old link register ends up in ctr reg */
bctr
@@ -1205,7 +1210,6 @@ _GLOBAL(_mcount)
b ftrace_graph_caller
#endif
MCOUNT_RESTORE_FRAME
-
bctr
#endif
--
1.5.6.5
--
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 1/7] tracing/function-graph-tracer: make arch generic push pop functions
2009-02-13 5:23 ` [PATCH 1/7] tracing/function-graph-tracer: make arch generic push pop functions Steven Rostedt
@ 2009-02-17 4:49 ` Steven Rostedt
2009-02-18 1:00 ` Ingo Molnar
0 siblings, 1 reply; 15+ messages in thread
From: Steven Rostedt @ 2009-02-17 4:49 UTC (permalink / raw)
To: Ingo Molnar
Cc: Benjamin Herrenschmidt, Paul Mackerras, Andrew Morton,
Frederic Weisbecker, Geoff Levand, LKML, Steven Rostedt
Ingo,
This patch is to make function graph arch generic. But since the PowerPC
changes depend on it, we want to push it through the PowerPC tree. But
since it touches x86 code, can you give an Acked-by to it?
Thanks,
-- Steve
On Fri, 13 Feb 2009, Steven Rostedt wrote:
> From: Steven Rostedt <srostedt@redhat.com>
>
> There is nothing really arch specific of the push and pop functions
> used by the function graph tracer. This patch moves them to generic
> code.
>
> Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
> Signed-off-by: Steven Rostedt <srostedt@redhat.com>
> ---
> arch/x86/include/asm/ftrace.h | 25 -----------
> arch/x86/kernel/ftrace.c | 75 +---------------------------------
> include/linux/ftrace.h | 24 +++++++++++
> kernel/trace/trace_functions_graph.c | 75 ++++++++++++++++++++++++++++++++++
> 4 files changed, 100 insertions(+), 99 deletions(-)
>
> diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
> index b55b4a7..db24c22 100644
> --- a/arch/x86/include/asm/ftrace.h
> +++ b/arch/x86/include/asm/ftrace.h
> @@ -55,29 +55,4 @@ struct dyn_arch_ftrace {
> #endif /* __ASSEMBLY__ */
> #endif /* CONFIG_FUNCTION_TRACER */
>
> -#ifdef CONFIG_FUNCTION_GRAPH_TRACER
> -
> -#ifndef __ASSEMBLY__
> -
> -/*
> - * Stack of return addresses for functions
> - * of a thread.
> - * Used in struct thread_info
> - */
> -struct ftrace_ret_stack {
> - unsigned long ret;
> - unsigned long func;
> - unsigned long long calltime;
> -};
> -
> -/*
> - * Primary handler of a function return.
> - * It relays on ftrace_return_to_handler.
> - * Defined in entry_32/64.S
> - */
> -extern void return_to_handler(void);
> -
> -#endif /* __ASSEMBLY__ */
> -#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
> -
> #endif /* _ASM_X86_FTRACE_H */
> diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
> index 1b43086..258c8d5 100644
> --- a/arch/x86/kernel/ftrace.c
> +++ b/arch/x86/kernel/ftrace.c
> @@ -389,79 +389,6 @@ void ftrace_nmi_exit(void)
>
> #endif /* !CONFIG_DYNAMIC_FTRACE */
>
> -/* Add a function return address to the trace stack on thread info.*/
> -static int push_return_trace(unsigned long ret, unsigned long long time,
> - unsigned long func, int *depth)
> -{
> - int index;
> -
> - if (!current->ret_stack)
> - return -EBUSY;
> -
> - /* The return trace stack is full */
> - if (current->curr_ret_stack == FTRACE_RETFUNC_DEPTH - 1) {
> - atomic_inc(¤t->trace_overrun);
> - return -EBUSY;
> - }
> -
> - index = ++current->curr_ret_stack;
> - barrier();
> - current->ret_stack[index].ret = ret;
> - current->ret_stack[index].func = func;
> - current->ret_stack[index].calltime = time;
> - *depth = index;
> -
> - return 0;
> -}
> -
> -/* Retrieve a function return address to the trace stack on thread info.*/
> -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;
> - trace->overrun = atomic_read(¤t->trace_overrun);
> - trace->depth = index;
> - barrier();
> - current->curr_ret_stack--;
> -
> -}
> -
> -/*
> - * Send the trace to the ring-buffer.
> - * @return the original return address.
> - */
> -unsigned long ftrace_return_to_handler(void)
> -{
> - struct ftrace_graph_ret trace;
> - unsigned long ret;
> -
> - pop_return_trace(&trace, &ret);
> - 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;
> -}
> -
> /*
> * Hook the return address and push it in the stack of return addrs
> * in current thread info.
> @@ -520,7 +447,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
>
> calltime = cpu_clock(raw_smp_processor_id());
>
> - if (push_return_trace(old, calltime,
> + if (ftrace_push_return_trace(old, calltime,
> self_addr, &trace.depth) == -EBUSY) {
> *parent = old;
> return;
> diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
> index 677432b..a7f8134 100644
> --- a/include/linux/ftrace.h
> +++ b/include/linux/ftrace.h
> @@ -380,6 +380,30 @@ struct ftrace_graph_ret {
> #ifdef CONFIG_FUNCTION_GRAPH_TRACER
>
> /*
> + * Stack of return addresses for functions
> + * of a thread.
> + * Used in struct thread_info
> + */
> +struct ftrace_ret_stack {
> + unsigned long ret;
> + unsigned long func;
> + unsigned long long calltime;
> +};
> +
> +/*
> + * Primary handler of a function return.
> + * It relays on ftrace_return_to_handler.
> + * Defined in entry_32/64.S
> + */
> +extern void return_to_handler(void);
> +
> +extern int
> +ftrace_push_return_trace(unsigned long ret, unsigned long long time,
> + unsigned long func, int *depth);
> +extern void
> +ftrace_pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret);
> +
> +/*
> * Sometimes we don't want to trace a function with the function
> * graph tracer but we want them to keep traced by the usual function
> * tracer if the function graph tracer is not configured.
> diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
> index 930c08e..dce71a5 100644
> --- a/kernel/trace/trace_functions_graph.c
> +++ b/kernel/trace/trace_functions_graph.c
> @@ -42,6 +42,81 @@ static struct tracer_flags tracer_flags = {
> /* pid on the last trace processed */
> static pid_t last_pid[NR_CPUS] = { [0 ... NR_CPUS-1] = -1 };
>
> +/* Add a function return address to the trace stack on thread info.*/
> +int
> +ftrace_push_return_trace(unsigned long ret, unsigned long long time,
> + unsigned long func, int *depth)
> +{
> + int index;
> +
> + if (!current->ret_stack)
> + return -EBUSY;
> +
> + /* The return trace stack is full */
> + if (current->curr_ret_stack == FTRACE_RETFUNC_DEPTH - 1) {
> + atomic_inc(¤t->trace_overrun);
> + return -EBUSY;
> + }
> +
> + index = ++current->curr_ret_stack;
> + barrier();
> + current->ret_stack[index].ret = ret;
> + current->ret_stack[index].func = func;
> + current->ret_stack[index].calltime = time;
> + *depth = index;
> +
> + return 0;
> +}
> +
> +/* Retrieve a function return address to the trace stack on thread info.*/
> +void
> +ftrace_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;
> + trace->overrun = atomic_read(¤t->trace_overrun);
> + trace->depth = index;
> + barrier();
> + current->curr_ret_stack--;
> +
> +}
> +
> +/*
> + * Send the trace to the ring-buffer.
> + * @return the original return address.
> + */
> +unsigned long ftrace_return_to_handler(void)
> +{
> + struct ftrace_graph_ret trace;
> + unsigned long ret;
> +
> + ftrace_pop_return_trace(&trace, &ret);
> + 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;
> +}
> +
> static int graph_trace_init(struct trace_array *tr)
> {
> int cpu, ret;
> --
> 1.5.6.5
>
> --
>
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/7] tracing/function-graph-tracer: make arch generic push pop functions
2009-02-17 4:49 ` Steven Rostedt
@ 2009-02-18 1:00 ` Ingo Molnar
2009-02-18 1:24 ` Steven Rostedt
2009-02-18 3:48 ` Steven Rostedt
0 siblings, 2 replies; 15+ messages in thread
From: Ingo Molnar @ 2009-02-18 1:00 UTC (permalink / raw)
To: Steven Rostedt
Cc: Benjamin Herrenschmidt, Paul Mackerras, Andrew Morton,
Frederic Weisbecker, Geoff Levand, LKML, Steven Rostedt
* Steven Rostedt <rostedt@goodmis.org> wrote:
> Ingo,
>
> This patch is to make function graph arch generic. But since
> the PowerPC changes depend on it, we want to push it through
> the PowerPC tree. But since it touches x86 code, can you give
> an Acked-by to it?
hm, but it's all ftrace bits. Could this go through the tracing
tree? That's how it's generally done for most cross-arch
subsystems. By having it in a separate tree we risk conflicts
and various logistics problems. It's not like the PPC tree is
modifying its ftrace.c file all that frequently, right?
Ingo
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/7] tracing/function-graph-tracer: make arch generic push pop functions
2009-02-18 1:00 ` Ingo Molnar
@ 2009-02-18 1:24 ` Steven Rostedt
2009-02-18 3:12 ` Benjamin Herrenschmidt
2009-02-18 3:48 ` Steven Rostedt
1 sibling, 1 reply; 15+ messages in thread
From: Steven Rostedt @ 2009-02-18 1:24 UTC (permalink / raw)
To: Ingo Molnar
Cc: Benjamin Herrenschmidt, Paul Mackerras, Andrew Morton,
Frederic Weisbecker, Geoff Levand, LKML, Steven Rostedt
On Wed, 18 Feb 2009, Ingo Molnar wrote:
>
> * Steven Rostedt <rostedt@goodmis.org> wrote:
>
> > Ingo,
> >
> > This patch is to make function graph arch generic. But since
> > the PowerPC changes depend on it, we want to push it through
> > the PowerPC tree. But since it touches x86 code, can you give
> > an Acked-by to it?
>
> hm, but it's all ftrace bits. Could this go through the tracing
> tree? That's how it's generally done for most cross-arch
> subsystems. By having it in a separate tree we risk conflicts
> and various logistics problems. It's not like the PPC tree is
> modifying its ftrace.c file all that frequently, right?
Really doesn't matter to me which tree it goes. I figure tip would be fine
in compile testing, but I doubt it would get much actual machine testing.
How fast do you get changes to next? Perhaps you could take it and push it
out to next, where Ben could quickly get it back in for testing? Or at
least do that with this patch, and then Ben could apply the others on top.
-- Steve
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/7] tracing/function-graph-tracer: make arch generic push pop functions
2009-02-18 1:24 ` Steven Rostedt
@ 2009-02-18 3:12 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2009-02-18 3:12 UTC (permalink / raw)
To: Steven Rostedt
Cc: Ingo Molnar, Paul Mackerras, Andrew Morton, Frederic Weisbecker,
Geoff Levand, LKML, Steven Rostedt
On Tue, 2009-02-17 at 20:24 -0500, Steven Rostedt wrote:
> > hm, but it's all ftrace bits. Could this go through the tracing
> > tree? That's how it's generally done for most cross-arch
> > subsystems. By having it in a separate tree we risk conflicts
> > and various logistics problems. It's not like the PPC tree is
> > modifying its ftrace.c file all that frequently, right?
>
> Really doesn't matter to me which tree it goes. I figure tip would be fine
> in compile testing, but I doubt it would get much actual machine testing.
>
> How fast do you get changes to next? Perhaps you could take it and push it
> out to next, where Ben could quickly get it back in for testing? Or at
> least do that with this patch, and then Ben could apply the others on top.
Well, it did already conflict with a patch from Kumar that change the
opcodes, which I could fix easily in my tree but would have been harder
to deal with in the tracing tree...
Also, my next tree will not pull somebody else next tree, as it's a
never-rebase-will-merge tree though I have a test branch i can play with
(in which your patches currently are).
In any case, I don't care -that- much who the patches go via, it's
easier for me to fix them up when conflicts occur in powerpc land and
they will probably get more testing via my tree but it's no big deal.
Cheers,
Ben.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/7] tracing/function-graph-tracer: make arch generic push pop functions
2009-02-18 1:00 ` Ingo Molnar
2009-02-18 1:24 ` Steven Rostedt
@ 2009-02-18 3:48 ` Steven Rostedt
2009-02-18 12:53 ` Ingo Molnar
1 sibling, 1 reply; 15+ messages in thread
From: Steven Rostedt @ 2009-02-18 3:48 UTC (permalink / raw)
To: Ingo Molnar
Cc: Benjamin Herrenschmidt, Paul Mackerras, Andrew Morton,
Frederic Weisbecker, Geoff Levand, LKML, Steven Rostedt
On Wed, 18 Feb 2009, Ingo Molnar wrote:
>
> * Steven Rostedt <rostedt@goodmis.org> wrote:
>
> > Ingo,
> >
> > This patch is to make function graph arch generic. But since
> > the PowerPC changes depend on it, we want to push it through
> > the PowerPC tree. But since it touches x86 code, can you give
> > an Acked-by to it?
>
> hm, but it's all ftrace bits. Could this go through the tracing
> tree? That's how it's generally done for most cross-arch
> subsystems. By having it in a separate tree we risk conflicts
> and various logistics problems. It's not like the PPC tree is
> modifying its ftrace.c file all that frequently, right?
Ingo,
How about this. We could incorporate some of the power of git. I could
make a separate branch based off of Linus's 2.6.29-rc5 announcement, and
apply just this patch (the ftrace generic and x86 change). If you give me
your Acked-by, I'll add that too.
This way, both you and Ben could pull from this branch to get the one
change. When it goes upstream, because it has the same SHA1, git could
easily resolve it.
-- Steve
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/7] tracing/function-graph-tracer: make arch generic push pop functions
2009-02-18 3:48 ` Steven Rostedt
@ 2009-02-18 12:53 ` Ingo Molnar
2009-02-18 17:29 ` Steven Rostedt
0 siblings, 1 reply; 15+ messages in thread
From: Ingo Molnar @ 2009-02-18 12:53 UTC (permalink / raw)
To: Steven Rostedt
Cc: Benjamin Herrenschmidt, Paul Mackerras, Andrew Morton,
Frederic Weisbecker, Geoff Levand, LKML, Steven Rostedt
* Steven Rostedt <rostedt@goodmis.org> wrote:
> On Wed, 18 Feb 2009, Ingo Molnar wrote:
>
> >
> > * Steven Rostedt <rostedt@goodmis.org> wrote:
> >
> > > Ingo,
> > >
> > > This patch is to make function graph arch generic. But since
> > > the PowerPC changes depend on it, we want to push it through
> > > the PowerPC tree. But since it touches x86 code, can you give
> > > an Acked-by to it?
> >
> > hm, but it's all ftrace bits. Could this go through the tracing
> > tree? That's how it's generally done for most cross-arch
> > subsystems. By having it in a separate tree we risk conflicts
> > and various logistics problems. It's not like the PPC tree is
> > modifying its ftrace.c file all that frequently, right?
>
> Ingo,
>
> How about this. We could incorporate some of the power of git.
> I could make a separate branch based off of Linus's 2.6.29-rc5
> announcement, and apply just this patch (the ftrace generic
> and x86 change). If you give me your Acked-by, I'll add that
> too.
>
> This way, both you and Ben could pull from this branch to get
> the one change. When it goes upstream, because it has the same
> SHA1, git could easily resolve it.
Sure, that's fine too - if the separate tree is semantically
meaningful. If it pulls in too many ftrace prerequisites i doubt
it's appropriate for the PPC tree.
Ingo
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/7] tracing/function-graph-tracer: make arch generic push pop functions
2009-02-18 12:53 ` Ingo Molnar
@ 2009-02-18 17:29 ` Steven Rostedt
0 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2009-02-18 17:29 UTC (permalink / raw)
To: Ingo Molnar
Cc: Benjamin Herrenschmidt, Paul Mackerras, Andrew Morton,
Frederic Weisbecker, Geoff Levand, LKML, Steven Rostedt
On Wed, 18 Feb 2009, Ingo Molnar wrote:
>
> * Steven Rostedt <rostedt@goodmis.org> wrote:
>
> > On Wed, 18 Feb 2009, Ingo Molnar wrote:
> >
> > >
> > > * Steven Rostedt <rostedt@goodmis.org> wrote:
> > >
> > > > Ingo,
> > > >
> > > > This patch is to make function graph arch generic. But since
> > > > the PowerPC changes depend on it, we want to push it through
> > > > the PowerPC tree. But since it touches x86 code, can you give
> > > > an Acked-by to it?
> > >
> > > hm, but it's all ftrace bits. Could this go through the tracing
> > > tree? That's how it's generally done for most cross-arch
> > > subsystems. By having it in a separate tree we risk conflicts
> > > and various logistics problems. It's not like the PPC tree is
> > > modifying its ftrace.c file all that frequently, right?
> >
> > Ingo,
> >
> > How about this. We could incorporate some of the power of git.
> > I could make a separate branch based off of Linus's 2.6.29-rc5
> > announcement, and apply just this patch (the ftrace generic
> > and x86 change). If you give me your Acked-by, I'll add that
> > too.
> >
> > This way, both you and Ben could pull from this branch to get
> > the one change. When it goes upstream, because it has the same
> > SHA1, git could easily resolve it.
>
> Sure, that's fine too - if the separate tree is semantically
> meaningful. If it pulls in too many ftrace prerequisites i doubt
> it's appropriate for the PPC tree.
Yeah, I'll just make a new branch based off of Linus's 2.6.29-rc5
announcement, and add the one patch, and not touch it again. This will be
a simple merge of one patch from a change set that is in both trees.
-- Steve
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2009-02-18 17:29 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-13 5:23 [PATCH 0/7] [git pull] powerpc function graph tracer Steven Rostedt
2009-02-13 5:23 ` [PATCH 1/7] tracing/function-graph-tracer: make arch generic push pop functions Steven Rostedt
2009-02-17 4:49 ` Steven Rostedt
2009-02-18 1:00 ` Ingo Molnar
2009-02-18 1:24 ` Steven Rostedt
2009-02-18 3:12 ` Benjamin Herrenschmidt
2009-02-18 3:48 ` Steven Rostedt
2009-02-18 12:53 ` Ingo Molnar
2009-02-18 17:29 ` Steven Rostedt
2009-02-13 5:24 ` [PATCH 2/7] powerpc64: port of the function graph tracer Steven Rostedt
2009-02-13 5:24 ` [PATCH 3/7] powerpc64, tracing: add function graph tracer with dynamic tracing Steven Rostedt
2009-02-13 5:24 ` [PATCH 4/7] powerpc64, ftrace: save toc only on modules for function graph Steven Rostedt
2009-02-13 5:24 ` [PATCH 5/7] powerpc32, ftrace: save and restore mcount regs with macro Steven Rostedt
2009-02-13 5:24 ` [PATCH 6/7] powerpc32, ftrace: port function graph tracer to ppc32, static only Steven Rostedt
2009-02-13 5:24 ` [PATCH 7/7] powerpc32, ftrace: dynamic function graph tracer Steven Rostedt
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.