public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFA][PATCH 0/2] ftrace: Fix arch issues with function graph trampoline
@ 2014-07-14 17:05 Steven Rostedt
  2014-07-14 17:05 ` [RFA][PATCH 1/2] ftrace: Allow archs to specify if they need a separate " Steven Rostedt
  2014-07-14 17:05 ` [RFA][PATCH 2/2] ftrace/x86: Have function graph tracer use its own trampoline Steven Rostedt
  0 siblings, 2 replies; 3+ messages in thread
From: Steven Rostedt @ 2014-07-14 17:05 UTC (permalink / raw)
  To: linux-kernel; +Cc: H. Peter Anvin, Ingo Molnar, Andrew Morton

H. Peter Anvin,

It was reported to me that my for-next branch broke other archs.
This patch series makes the ftrace graph trampoline an opt-in feature,
as it may require some arch changes to make it work. X86 did not
require changes, but now that it is an opt in, x86 needs to do so
to get this feature.

Can you give me your Acked-by on patch 2?

Thanks!

-- Steve



Steven Rostedt (Red Hat) (2):
      ftrace: Allow archs to specify if they need a separate function graph trampoline
      ftrace/x86: Have function graph tracer use its own trampoline

----
 arch/x86/include/asm/ftrace.h |  2 ++
 include/linux/ftrace.h        | 10 ++++++++++
 kernel/trace/ftrace.c         |  6 ++++--
 3 files changed, 16 insertions(+), 2 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [RFA][PATCH 1/2] ftrace: Allow archs to specify if they need a separate function graph trampoline
  2014-07-14 17:05 [RFA][PATCH 0/2] ftrace: Fix arch issues with function graph trampoline Steven Rostedt
@ 2014-07-14 17:05 ` Steven Rostedt
  2014-07-14 17:05 ` [RFA][PATCH 2/2] ftrace/x86: Have function graph tracer use its own trampoline Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2014-07-14 17:05 UTC (permalink / raw)
  To: linux-kernel; +Cc: H. Peter Anvin, Ingo Molnar, Andrew Morton, Tuomas Tynkkynen

[-- Attachment #1: 0001-ftrace-Allow-archs-to-specify-if-they-need-a-separat.patch --]
[-- Type: text/plain, Size: 2754 bytes --]

From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

Currently if an arch supports function graph tracing, the core code will
just assign the function graph trampoline to the function graph addr that
gets called.

But as the old method for function graph tracing always calls the function
trampoline first and that calls the function graph trampoline, some
archs may have the function graph trampoline dependent on operations that
were done in the function trampoline. This causes function graph tracer
to break on those archs.

Instead of having the default be to set the function graph ftrace_ops
to the function graph trampoline, have it instead just set it to zero
which will keep it from jumping to a trampoline that is not set up
to be jumped directly too.

Link: http://lkml.kernel.org/r/53BED155.9040607@nvidia.com

Reported-by: Tuomas Tynkkynen <ttynkkynen@nvidia.com>
Tested-by: Tuomas Tynkkynen <ttynkkynen@nvidia.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 include/linux/ftrace.h | 10 ++++++++++
 kernel/trace/ftrace.c  |  6 ++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 11e18fd58b1a..4807a39e7ae1 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -453,6 +453,16 @@ void ftrace_modify_all_code(int command);
 #endif
 #endif
 
+/*
+ * If an arch would like functions that are only traced
+ * by the function graph tracer to jump directly to its own
+ * trampoline, then they can define FTRACE_GRAPH_TRAMP_ADDR
+ * to be that address to jump to.
+ */
+#ifndef FTRACE_GRAPH_TRAMP_ADDR
+#define FTRACE_GRAPH_TRAMP_ADDR ((unsigned long) 0)
+#endif
+
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 extern void ftrace_graph_caller(void);
 extern int ftrace_enable_ftrace_graph_caller(void);
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 45aac1a742c5..c52d37d64c23 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -5366,7 +5366,8 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
 
 #ifdef CONFIG_DYNAMIC_FTRACE
 	/* Optimize function graph calling (if implemented by arch) */
-	global_ops.trampoline = FTRACE_GRAPH_ADDR;
+	if (FTRACE_GRAPH_TRAMP_ADDR)
+		global_ops.trampoline = FTRACE_GRAPH_TRAMP_ADDR;
 #endif
 
 	ret = ftrace_startup(&global_ops, FTRACE_START_FUNC_RET);
@@ -5390,7 +5391,8 @@ void unregister_ftrace_graph(void)
 	ftrace_shutdown(&global_ops, FTRACE_STOP_FUNC_RET);
 	global_ops.flags &= ~FTRACE_OPS_FL_STUB;
 #ifdef CONFIG_DYNAMIC_FTRACE
-	global_ops.trampoline = 0;
+	if (FTRACE_GRAPH_TRAMP_ADDR)
+		global_ops.trampoline = 0;
 #endif
 	unregister_pm_notifier(&ftrace_suspend_notifier);
 	unregister_trace_sched_switch(ftrace_graph_probe_sched_switch, NULL);
-- 
2.0.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [RFA][PATCH 2/2] ftrace/x86: Have function graph tracer use its own trampoline
  2014-07-14 17:05 [RFA][PATCH 0/2] ftrace: Fix arch issues with function graph trampoline Steven Rostedt
  2014-07-14 17:05 ` [RFA][PATCH 1/2] ftrace: Allow archs to specify if they need a separate " Steven Rostedt
@ 2014-07-14 17:05 ` Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2014-07-14 17:05 UTC (permalink / raw)
  To: linux-kernel; +Cc: H. Peter Anvin, Ingo Molnar, Andrew Morton

[-- Attachment #1: 0002-ftrace-x86-Have-function-graph-tracer-use-its-own-tr.patch --]
[-- Type: text/plain, Size: 1097 bytes --]

From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

The function graph trampoline is called from the function trampoline
and both do a save and restore of registers. The save of registers
done by the function trampoline when only the function graph tracer
is running is a waste of CPU cycles.

As the function graph tracer trampoline in x86 is dependent from
the function trampoline, we can call it directly when a function
is only being traced by the function graph trampoline.

Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 arch/x86/include/asm/ftrace.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
index 0525a8bdf65d..e1f7fecaa7d6 100644
--- a/arch/x86/include/asm/ftrace.h
+++ b/arch/x86/include/asm/ftrace.h
@@ -68,6 +68,8 @@ struct dyn_arch_ftrace {
 
 int ftrace_int3_handler(struct pt_regs *regs);
 
+#define FTRACE_GRAPH_TRAMP_ADDR FTRACE_GRAPH_ADDR
+
 #endif /*  CONFIG_DYNAMIC_FTRACE */
 #endif /* __ASSEMBLY__ */
 #endif /* CONFIG_FUNCTION_TRACER */
-- 
2.0.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-07-14 17:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-14 17:05 [RFA][PATCH 0/2] ftrace: Fix arch issues with function graph trampoline Steven Rostedt
2014-07-14 17:05 ` [RFA][PATCH 1/2] ftrace: Allow archs to specify if they need a separate " Steven Rostedt
2014-07-14 17:05 ` [RFA][PATCH 2/2] ftrace/x86: Have function graph tracer use its own trampoline Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox