Skip to contentSkip to conversation

ftrace/tracing: Fixes and final removal of ftrace_start/stop()

PATCH In review Steven Rostedt 2 participants 35 messages Jul 19, 2014 – Jul 21, 2014

Subsystems (15)
Documentation x86 PowerPC MIPS +11 more subsystems
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover ftrace/tracing: Fixes and final removal of ftrace_start/stop()

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next

Head SHA1: ba1afef6a47c4133831fefcad4e0d7bf1d0ee99e

Corey Minyard (1):
ring-buffer: Always run per-cpu ring buffer resize with schedule_work_on()

Heiko Carstens (1):
s390/ftrace: remove check of obsolete variable function_trace_stop

Stanislav Fomichev (1):
tracing: let user specify tracing_thresh after selecting function_graph

Steven Rostedt (Red Hat) (28):
ftrace: Allow archs to specify if they need a separate function graph trampoline ftrace/x86: Have function graph tracer use its own trampoline
x86, power, suspend: Annotate restore_processor_state() with notrace PM / Sleep: Remove ftrace_stop/start() from suspend and hibernate
ftrace-graph: Remove dependency of ftrace_stop() from ftrace_graph_stop() ftrace/x86: Add call to ftrace_graph_is_dead() in function graph code
microblaze: ftrace: Add call to ftrace_graph_is_dead() in function graph code
MIPS: ftrace: Add call to ftrace_graph_is_dead() in function graph code
parisc: ftrace: Add call to ftrace_graph_is_dead() in function graph code powerpc/ftrace: Add call to ftrace_graph_is_dead() in function graph code
sh: ftrace: Add call to ftrace_graph_is_dead() in function graph code
ftrace-graph: Remove usage of ftrace_stop() in ftrace_graph_stop()
ftrace: Remove ftrace_start/stop()
ftrace: Do no disable function tracing on enabling function tracing
ftrace: Remove function_trace_stop check from list func
ftrace: Remove check for HAVE_FUNCTION_TRACE_MCOUNT_TEST
ftrace: x86: Remove check of obsolete variable function_trace_stop
tile: ftrace: Remove check of obsolete variable function_trace_stop sparc64,ftrace: Remove check of obsolete variable function_trace_stop
sh: ftrace: Remove check of obsolete variable function_trace_stop
parisc: ftrace: Remove check of obsolete variable function_trace_stop
MIPS: ftrace: Remove check of obsolete variable function_trace_stop
microblaze: ftrace: Remove check of obsolete variable function_trace_stop
metag: ftrace: Remove check of obsolete variable function_trace_stop
Blackfin: ftrace: Remove check of obsolete variable function_trace_stop arm64, ftrace: Remove check of obsolete variable function_trace_stop
tracing: Remove function_trace_stop and HAVE_FUNCTION_TRACE_MCOUNT_TEST
tracing: Convert local function_graph functions to static

Wang Nan (1):
ftrace: Do not copy old hash when resetting

----

 Documentation/trace/ftrace-design.txt | 26 --------------
 arch/arm64/kernel/entry-ftrace.S      |  5 ---
 arch/blackfin/Kconfig                 |  1 -
 arch/blackfin/kernel/ftrace-entry.S   | 18 ----------
 arch/metag/Kconfig                    |  1 -
 arch/metag/kernel/ftrace_stub.S       | 14 --------
 arch/microblaze/Kconfig               |  1 -
 arch/microblaze/kernel/ftrace.c       |  3 ++
 arch/microblaze/kernel/mcount.S       |  5 ---
 arch/mips/Kconfig                     |  1 -
 arch/mips/kernel/ftrace.c             |  3 ++
 arch/mips/kernel/mcount.S             |  7 ----
 arch/parisc/Kconfig                   |  1 -
 arch/parisc/kernel/ftrace.c           |  6 ++--
 arch/powerpc/kernel/ftrace.c          |  3 ++
 arch/s390/Kconfig                     |  1 -
 arch/s390/kernel/mcount.S             | 10 ++----
 arch/s390/kernel/mcount64.S           |  3 --
 arch/sh/Kconfig                       |  1 -
 arch/sh/kernel/ftrace.c               |  3 ++
 arch/sh/lib/mcount.S                  | 24 ++-----------
 arch/sparc/Kconfig                    |  1 -
 arch/sparc/lib/mcount.S               | 10 ++----
 arch/tile/Kconfig                     |  1 -
 arch/tile/kernel/mcount_64.S          | 18 ----------
 arch/x86/Kconfig                      |  1 -
 arch/x86/include/asm/ftrace.h         |  2 ++
 arch/x86/kernel/entry_32.S            |  9 -----
 arch/x86/kernel/ftrace.c              |  3 ++
 arch/x86/kernel/mcount_64.S           | 18 +---------
 arch/x86/power/cpu.c                  |  4 +--
 include/linux/ftrace.h                | 44 +++++++-----------------
 kernel/power/hibernate.c              |  6 ----
 kernel/power/suspend.c                |  2 --
 kernel/trace/Kconfig                  |  5 ---
 kernel/trace/ftrace.c                 | 44 ++++++------------------
 kernel/trace/ring_buffer.c            | 24 +++----------
 kernel/trace/trace.c                  | 65 +++++++++++++++++++++++++++++++----
 kernel/trace/trace.h                  |  2 ++
 kernel/trace/trace_functions_graph.c  | 43 +++++++++++++++++++++--
 40 files changed, 157 insertions(+), 282 deletions(-)
author maintainer
#1 lore raw

PATCH 1/32 ftrace: Allow archs to specify if they need a separate function graph trampoline

From: "Steven Rostedt (Red Hat)" <[email protected]>

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.

---
 include/linux/ftrace.h | 10 ++++++++++
 kernel/trace/ftrace.c  |  6 ++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
include/linux/ftrace.h +10 -0
index 11e18fd58b1a..4807a39e7ae1 100644
@@ -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);
kernel/trace/ftrace.c +4 -2
index 45aac1a742c5..1776153ea6e0 100644
@@ -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 != 0)
+		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 != 0)
+		global_ops.trampoline = 0;
 #endif
 	unregister_pm_notifier(&ftrace_suspend_notifier);
 	unregister_trace_sched_switch(ftrace_graph_probe_sched_switch, NULL);
Signature · 1 line
2.0.1
author maintainer
#2 lore raw

PATCH 2/32 ftrace/x86: Have function graph tracer use its own trampoline

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

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.

---
 arch/x86/include/asm/ftrace.h | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/include/asm/ftrace.h +2 -0
index 0525a8bdf65d..e1f7fecaa7d6 100644
@@ -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 */
Signature · 1 line
2.0.1
author maintainer
#3 lore raw

PATCH 3/32 x86, power, suspend: Annotate restore_processor_state() with notrace

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

ftrace_stop() is used to stop function tracing during suspend and resume which removes a lot of possible debugging opportunities with tracing. The reason was that some function in the resume path was causing a triple fault if it were to be traced. The issue I found was that doing something as simple as calling smp_processor_id() would reboot the box!

When function tracing was first created I didn't have a good way to figure out what function was having issues, or it looked to be multiple ones. To fix it, we just created a big hammer approach to the problem which was to add a flag in the mcount trampoline that could be checked and not call the traced functions.

Lately I developed better ways to find problem functions and I can bisect down to see what function is causing the issue. I removed the flag that stopped tracing and proceeded to find the problem function and it ended up being restore_processor_state(). This function makes sense as when the CPU comes back online from a suspend it calls this function to set up registers, amongst them the GS register, which stores things such as what CPU the processor is (if you call smp_processor_id() without this set up properly, it would fault).

By making restore_processor_state() notrace, the system can suspend and resume without the need of the big hammer tracing to stop.

---
 arch/x86/power/cpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/power/cpu.c +2 -2
index 424f4c97a44d..6ec7910f59bf 100644
@@ -165,7 +165,7 @@ static void fix_processor_context(void)
  *		by __save_processor_state()
  *	@ctxt - structure to load the registers contents from
  */
-static void __restore_processor_state(struct saved_context *ctxt)
+static void notrace __restore_processor_state(struct saved_context *ctxt)
 {
 	if (ctxt->misc_enable_saved)
 		wrmsrl(MSR_IA32_MISC_ENABLE, ctxt->misc_enable);
@@ -239,7 +239,7 @@ static void __restore_processor_state(struct saved_context *ctxt)
 }
 
 /* Needed by apm.c */
-void restore_processor_state(void)
+void notrace restore_processor_state(void)
 {
 	__restore_processor_state(&saved_context);
 }
Signature · 1 line
2.0.1
author maintainer
#4 lore raw

PATCH 4/32 PM / Sleep: Remove ftrace_stop/start() from suspend and hibernate

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

ftrace_stop() and ftrace_start() were added to the suspend and hibernate process because there was some function within the work flow that caused the system to reboot if it was traced. This function has recently been found (restore_processor_state()). Now there's no reason to disable function tracing while we are going into suspend or hibernate, which means that being able to trace this will help tremendously in debugging any issues with suspend or hibernate.

This also means that the ftrace_stop/start() functions can be removed and simplify the function tracing code a bit.

---
 kernel/power/hibernate.c | 6 ------
 kernel/power/suspend.c   | 2 --
 2 files changed, 8 deletions(-)
kernel/power/hibernate.c +0 -6
index fcc2611d3f14..a9dfa79b6bab 100644
@@ -371,7 +371,6 @@ int hibernation_snapshot(int platform_mode)
 	}
 
 	suspend_console();
-	ftrace_stop();
 	pm_restrict_gfp_mask();
 
 	error = dpm_suspend(PMSG_FREEZE);
@@ -397,7 +396,6 @@ int hibernation_snapshot(int platform_mode)
 	if (error || !in_suspend)
 		pm_restore_gfp_mask();
 
-	ftrace_start();
 	resume_console();
 	dpm_complete(msg);
 
@@ -500,7 +498,6 @@ int hibernation_restore(int platform_mode)
 
 	pm_prepare_console();
 	suspend_console();
-	ftrace_stop();
 	pm_restrict_gfp_mask();
 	error = dpm_suspend_start(PMSG_QUIESCE);
 	if (!error) {
@@ -508,7 +505,6 @@ int hibernation_restore(int platform_mode)
 		dpm_resume_end(PMSG_RECOVER);
 	}
 	pm_restore_gfp_mask();
-	ftrace_start();
 	resume_console();
 	pm_restore_console();
 	return error;
@@ -535,7 +531,6 @@ int hibernation_platform_enter(void)
 
 	entering_platform_hibernation = true;
 	suspend_console();
-	ftrace_stop();
 	error = dpm_suspend_start(PMSG_HIBERNATE);
 	if (error) {
 		if (hibernation_ops->recover)
@@ -579,7 +574,6 @@ int hibernation_platform_enter(void)
  Resume_devices:
 	entering_platform_hibernation = false;
 	dpm_resume_end(PMSG_RESTORE);
-	ftrace_start();
 	resume_console();
 
  Close:
kernel/power/suspend.c +0 -2
index 4dd8822f732a..f6623da034d8 100644
@@ -248,7 +248,6 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
 		goto Platform_wake;
 	}
 
-	ftrace_stop();
 	error = disable_nonboot_cpus();
 	if (error || suspend_test(TEST_CPUS))
 		goto Enable_cpus;
@@ -275,7 +274,6 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
 
  Enable_cpus:
 	enable_nonboot_cpus();
-	ftrace_start();
 
  Platform_wake:
 	if (need_suspend_ops(state) && suspend_ops->wake)
Signature · 1 line
2.0.1
author maintainer
#5 lore raw

PATCH 5/32 ftrace-graph: Remove dependency of ftrace_stop() from ftrace_graph_stop()

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

ftrace_stop() is going away as it disables parts of function tracing that affects users that should not be affected. But ftrace_graph_stop() is built on ftrace_stop(). Here's another example of killing all of function tracing because something went wrong with function graph tracing.

Instead of disabling all users of function tracing on function graph error, disable only function graph tracing.

A new function is created called ftrace_graph_is_dead(). This is called in strategic paths to prevent function graph from doing more harm and allowing at least a warning to be printed before the system crashes.

NOTE: ftrace_stop() is still used until all the archs are converted over to use ftrace_graph_is_dead(). After that, ftrace_stop() will be removed.

---
 include/linux/ftrace.h               |  1 +
 kernel/trace/ftrace.c                |  5 -----
 kernel/trace/trace_functions_graph.c | 35 +++++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 5 deletions(-)
include/linux/ftrace.h +1 -0
index 4807a39e7ae1..18fb2c4a3f7f 100644
@@ -760,6 +760,7 @@ extern char __irqentry_text_end[];
 extern int register_ftrace_graph(trace_func_graph_ret_t retfunc,
 				trace_func_graph_ent_t entryfunc);
 
+extern bool ftrace_graph_is_dead(void);
 extern void ftrace_graph_stop(void);
 
 /* The current handlers in use */
kernel/trace/ftrace.c +0 -5
index 1776153ea6e0..8063280fd53d 100644
@@ -5473,9 +5473,4 @@ void ftrace_graph_exit_task(struct task_struct *t)
 
 	kfree(ret_stack);
 }
-
-void ftrace_graph_stop(void)
-{
-	ftrace_stop();
-}
 #endif
kernel/trace/trace_functions_graph.c +35 -0
index 4de3e57f723c..3604690be70b 100644
@@ -15,6 +15,38 @@
 #include "trace.h"
 #include "trace_output.h"
 
+static bool kill_ftrace_graph;
+
+/**
+ * ftrace_graph_is_dead - returns true if ftrace_graph_stop() was called
+ *
+ * ftrace_graph_stop() is called when a severe error is detected in
+ * the function graph tracing. This function is called by the critical
+ * paths of function graph to keep those paths from doing any more harm.
+ */
+bool ftrace_graph_is_dead(void)
+{
+	return kill_ftrace_graph;
+}
+
+/**
+ * ftrace_graph_stop - set to permanently disable function graph tracincg
+ *
+ * In case of an error int function graph tracing, this is called
+ * to try to keep function graph tracing from causing any more harm.
+ * Usually this is pretty severe and this is called to try to at least
+ * get a warning out to the user.
+ */
+void ftrace_graph_stop(void)
+{
+	kill_ftrace_graph = true;
+	/*
+	 * ftrace_stop() will be removed when all archs are updated to
+	 * use ftrace_graph_is_dead()
+	 */
+	ftrace_stop();
+}
+
 /* When set, irq functions will be ignored */
 static int ftrace_graph_skip_irqs;
 
@@ -92,6 +124,9 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
 	unsigned long long calltime;
 	int index;
 
+	if (unlikely(ftrace_graph_is_dead()))
+		return -EBUSY;
+
 	if (!current->ret_stack)
 		return -EBUSY;
 
Signature · 1 line
2.0.1
author maintainer
#6 lore raw

PATCH 6/32 ftrace/x86: Add call to ftrace_graph_is_dead() in function graph code

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

ftrace_stop() is going away as it disables parts of function tracing that affects users that should not be affected. But ftrace_graph_stop() is built on ftrace_stop(). Here's another example of killing all of function tracing because something went wrong with function graph tracing.

Instead of disabling all users of function tracing on function graph error, disable only function graph tracing. To do this, the arch code must call ftrace_graph_is_dead() before it implements function graph.

---
 arch/x86/kernel/ftrace.c | 3 +++
 1 file changed, 3 insertions(+)
arch/x86/kernel/ftrace.c +3 -0
index cbc4a91b131e..3386dc9aa333 100644
@@ -703,6 +703,9 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
 	unsigned long return_hooker = (unsigned long)
 				&return_to_handler;
 
+	if (unlikely(ftrace_graph_is_dead()))
+		return;
+
 	if (unlikely(atomic_read(&current->tracing_graph_pause)))
 		return;
 
Signature · 1 line
2.0.1
author maintainer
#7 lore raw

PATCH 7/32 microblaze: ftrace: Add call to ftrace_graph_is_dead() in function graph code

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

ftrace_stop() is going away as it disables parts of function tracing that affects users that should not be affected. But ftrace_graph_stop() is built on ftrace_stop(). Here's another example of killing all of function tracing because something went wrong with function graph tracing.

Instead of disabling all users of function tracing on function graph error, disable only function graph tracing. To do this, the arch code must call ftrace_graph_is_dead() before it implements function graph.

---
 arch/microblaze/kernel/ftrace.c | 3 +++
 1 file changed, 3 insertions(+)
arch/microblaze/kernel/ftrace.c +3 -0
index bbcd2533766c..fc7b48a52cd5 100644
@@ -27,6 +27,9 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
 	unsigned long return_hooker = (unsigned long)
 				&return_to_handler;
 
+	if (unlikely(ftrace_graph_is_dead()))
+		return;
+
 	if (unlikely(atomic_read(&current->tracing_graph_pause)))
 		return;
 
Signature · 1 line
2.0.1
author maintainer
#8 lore raw

PATCH 8/32 MIPS: ftrace: Add call to ftrace_graph_is_dead() in function graph code

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

ftrace_stop() is going away as it disables parts of function tracing that affects users that should not be affected. But ftrace_graph_stop() is built on ftrace_stop(). Here's another example of killing all of function tracing because something went wrong with function graph tracing.

Instead of disabling all users of function tracing on function graph error, disable only function graph tracing. To do this, the arch code must call ftrace_graph_is_dead() before it implements function graph.

---
 arch/mips/kernel/ftrace.c | 3 +++
 1 file changed, 3 insertions(+)
arch/mips/kernel/ftrace.c +3 -0
index 60e7e5e45af1..8b6538750fe1 100644
@@ -302,6 +302,9 @@ void prepare_ftrace_return(unsigned long *parent_ra_addr, unsigned long self_ra,
 	    &return_to_handler;
 	int faulted, insns;
 
+	if (unlikely(ftrace_graph_is_dead()))
+		return;
+
 	if (unlikely(atomic_read(&current->tracing_graph_pause)))
 		return;
 
Signature · 1 line
2.0.1
author maintainer
#9 lore raw

PATCH 9/32 parisc: ftrace: Add call to ftrace_graph_is_dead() in function graph code

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

ftrace_stop() is going away as it disables parts of function tracing that affects users that should not be affected. But ftrace_graph_stop() is built on ftrace_stop(). Here's another example of killing all of function tracing because something went wrong with function graph tracing.

Instead of disabling all users of function tracing on function graph error, disable only function graph tracing. To do this, the arch code must call ftrace_graph_is_dead() before it implements function graph.

---
 arch/parisc/kernel/ftrace.c | 3 +++
 1 file changed, 3 insertions(+)
arch/parisc/kernel/ftrace.c +3 -0
index 5beb97bafbb1..5512ab32c5e0 100644
@@ -112,6 +112,9 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
 	unsigned long long calltime;
 	struct ftrace_graph_ent trace;
 
+	if (unlikely(ftrace_graph_is_dead()))
+		return;
+
 	if (unlikely(atomic_read(&current->tracing_graph_pause)))
 		return;
 
Signature · 1 line
2.0.1
author maintainer
#10 lore raw

PATCH 10/32 powerpc/ftrace: Add call to ftrace_graph_is_dead() in function graph code

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

ftrace_stop() is going away as it disables parts of function tracing that affects users that should not be affected. But ftrace_graph_stop() is built on ftrace_stop(). Here's another example of killing all of function tracing because something went wrong with function graph tracing.

Instead of disabling all users of function tracing on function graph error, disable only function graph tracing. To do this, the arch code must call ftrace_graph_is_dead() before it implements function graph.

---
 arch/powerpc/kernel/ftrace.c | 3 +++
 1 file changed, 3 insertions(+)
arch/powerpc/kernel/ftrace.c +3 -0
index d178834fe508..390311c0f03d 100644
@@ -525,6 +525,9 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
 	struct ftrace_graph_ent trace;
 	unsigned long return_hooker = (unsigned long)&return_to_handler;
 
+	if (unlikely(ftrace_graph_is_dead()))
+		return;
+
 	if (unlikely(atomic_read(&current->tracing_graph_pause)))
 		return;
 
Signature · 1 line
2.0.1
author maintainer
#11 lore raw

PATCH 11/32 sh: ftrace: Add call to ftrace_graph_is_dead() in function graph code

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

ftrace_stop() is going away as it disables parts of function tracing that affects users that should not be affected. But ftrace_graph_stop() is built on ftrace_stop(). Here's another example of killing all of function tracing because something went wrong with function graph tracing.

Instead of disabling all users of function tracing on function graph error, disable only function graph tracing. To do this, the arch code must call ftrace_graph_is_dead() before it implements function graph.

---
 arch/sh/kernel/ftrace.c | 3 +++
 1 file changed, 3 insertions(+)
arch/sh/kernel/ftrace.c +3 -0
index 3c74f53db6db..079d70e6d74b 100644
@@ -344,6 +344,9 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
 	struct ftrace_graph_ent trace;
 	unsigned long return_hooker = (unsigned long)&return_to_handler;
 
+	if (unlikely(ftrace_graph_is_dead()))
+		return;
+
 	if (unlikely(atomic_read(&current->tracing_graph_pause)))
 		return;
 
Signature · 1 line
2.0.1
author maintainer
#12 lore raw

PATCH 12/32 ftrace-graph: Remove usage of ftrace_stop() in ftrace_graph_stop()

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

All archs now use ftrace_graph_is_dead() to stop function graph tracing. Remove the usage of ftrace_stop() as that is no longer needed.

---
 kernel/trace/trace_functions_graph.c | 5 -----
 1 file changed, 5 deletions(-)
kernel/trace/trace_functions_graph.c +0 -5
index 3604690be70b..2c944e6c4a9d 100644
@@ -40,11 +40,6 @@ bool ftrace_graph_is_dead(void)
 void ftrace_graph_stop(void)
 {
 	kill_ftrace_graph = true;
-	/*
-	 * ftrace_stop() will be removed when all archs are updated to
-	 * use ftrace_graph_is_dead()
-	 */
-	ftrace_stop();
 }
 
 /* When set, irq functions will be ignored */
Signature · 1 line
2.0.1
author maintainer
#13 lore raw

PATCH 13/32 ftrace: Remove ftrace_start/stop()

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

There are no more kernel users of ftrace_stop() and ftrace_start(). Remove them.

---
 include/linux/ftrace.h | 28 ----------------------------
 1 file changed, 28 deletions(-)
include/linux/ftrace.h +0 -28
index 18fb2c4a3f7f..b7333794554f 100644
@@ -143,32 +143,6 @@ enum ftrace_tracing_type_t {
 /* Current tracing type, default is FTRACE_TYPE_ENTER */
 extern enum ftrace_tracing_type_t ftrace_tracing_type;
 
-/**
- * ftrace_stop - stop function tracer.
- *
- * A quick way to stop the function tracer. Note this an on off switch,
- * it is not something that is recursive like preempt_disable.
- * This does not disable the calling of mcount, it only stops the
- * calling of functions from mcount.
- */
-static inline void ftrace_stop(void)
-{
-	function_trace_stop = 1;
-}
-
-/**
- * ftrace_start - start the function tracer.
- *
- * This function is the inverse of ftrace_stop. This does not enable
- * the function tracing if the function tracer is disabled. This only
- * sets the function tracer flag to continue calling the functions
- * from mcount.
- */
-static inline void ftrace_start(void)
-{
-	function_trace_stop = 0;
-}
-
 /*
  * The ftrace_ops must be a static and should also
  * be read_mostly.  These functions do modify read_mostly variables
@@ -245,8 +219,6 @@ static inline int ftrace_nr_registered_ops(void)
 }
 static inline void clear_ftrace_function(void) { }
 static inline void ftrace_kill(void) { }
-static inline void ftrace_stop(void) { }
-static inline void ftrace_start(void) { }
 #endif /* CONFIG_FUNCTION_TRACER */
 
 #ifdef CONFIG_STACK_TRACER
Signature · 1 line
2.0.1
author maintainer
#14 lore raw

PATCH 14/32 ftrace: Do no disable function tracing on enabling function tracing

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

When function tracing is being updated function_trace_stop is set to keep from tracing the updates. This was fine when function tracing was done from stop machine. But it is no longer done that way and this can cause real tracing to be missed.

Remove it.

---
 kernel/trace/ftrace.c | 7 -------
 1 file changed, 7 deletions(-)
kernel/trace/ftrace.c +0 -7
index 8063280fd53d..0fa1b87db95c 100644
@@ -2261,11 +2261,6 @@ static void ftrace_run_update_code(int command)
 	FTRACE_WARN_ON(ret);
 	if (ret)
 		return;
-	/*
-	 * Do not call function tracer while we update the code.
-	 * We are in stop machine.
-	 */
-	function_trace_stop++;
 
 	/*
 	 * By default we use stop_machine() to modify the code.
@@ -2275,8 +2270,6 @@ static void ftrace_run_update_code(int command)
 	 */
 	arch_ftrace_update_code(command);
 
-	function_trace_stop--;
-
 	ret = ftrace_arch_code_modify_post_process();
 	FTRACE_WARN_ON(ret);
 
Signature · 1 line
2.0.1
author maintainer
#15 lore raw

PATCH 15/32 ftrace: Remove function_trace_stop check from list func

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

function_trace_stop is no longer used to stop function tracing. Remove the check from __ftrace_ops_list_func().

Also, call FTRACE_WARN_ON() instead of setting function_trace_stop if a ops has no func to call.

---
 kernel/trace/ftrace.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
kernel/trace/ftrace.c +2 -6
index 0fa1b87db95c..70abf97d6e84 100644
@@ -4720,9 +4720,6 @@ __ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
 	struct ftrace_ops *op;
 	int bit;
 
-	if (function_trace_stop)
-		return;
-
 	bit = trace_test_and_set_recursion(TRACE_LIST_START, TRACE_LIST_MAX);
 	if (bit < 0)
 		return;
@@ -4734,9 +4731,8 @@ __ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
 	preempt_disable_notrace();
 	do_for_each_ftrace_op(op, ftrace_ops_list) {
 		if (ftrace_ops_test(op, ip, regs)) {
-			if (WARN_ON(!op->func)) {
-				function_trace_stop = 1;
-				printk("op=%p %pS\n", op, op);
+			if (FTRACE_WARN_ON(!op->func)) {
+				pr_warn("op=%p %pS\n", op, op);
 				goto out;
 			}
 			op->func(ip, parent_ip, op, regs);
Signature · 1 line
2.0.1
author maintainer
#16 lore raw

PATCH 16/32 ftrace: Remove check for HAVE_FUNCTION_TRACE_MCOUNT_TEST

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

function_trace_stop is no longer used to disable function tracing. This means that archs are no longer limited if it does not support checking this variable in the mcount trampoline.

No need to use the list_func for archs that do not support this obsolete method.

---
 Documentation/trace/ftrace-design.txt | 26 --------------------------
 include/linux/ftrace.h                |  3 +--
 2 files changed, 1 insertion(+), 28 deletions(-)
Documentation/trace/ftrace-design.txt +0 -26
index 3f669b9e8852..dd5f916b351d 100644
@@ -102,30 +102,6 @@ extern void mcount(void);
 EXPORT_SYMBOL(mcount);
 
 
-HAVE_FUNCTION_TRACE_MCOUNT_TEST
--------------------------------
-
-This is an optional optimization for the normal case when tracing is turned off
-in the system.  If you do not enable this Kconfig option, the common ftrace
-code will take care of doing the checking for you.
-
-To support this feature, you only need to check the function_trace_stop
-variable in the mcount function.  If it is non-zero, there is no tracing to be
-done at all, so you can return.
-
-This additional pseudo code would simply be:
-void mcount(void)
-{
-	/* save any bare state needed in order to do initial checking */
-
-+	if (function_trace_stop)
-+		return;
-
-	extern void (*ftrace_trace_function)(unsigned long, unsigned long);
-	if (ftrace_trace_function != ftrace_stub)
-...
-
-
 HAVE_FUNCTION_GRAPH_TRACER
 --------------------------
 
@@ -328,8 +304,6 @@ void mcount(void)
 
 void ftrace_caller(void)
 {
-	/* implement HAVE_FUNCTION_TRACE_MCOUNT_TEST if you desire */
-
 	/* save all state needed by the ABI (see paragraph above) */
 
 	unsigned long frompc = ...;
include/linux/ftrace.h +1 -2
index b7333794554f..c800906235e1 100644
@@ -33,8 +33,7 @@
  * features, then it must call an indirect function that
  * does. Or at least does enough to prevent any unwelcomed side effects.
  */
-#if !defined(CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST) || \
-	!ARCH_SUPPORTS_FTRACE_OPS
+#if !ARCH_SUPPORTS_FTRACE_OPS
 # define FTRACE_FORCE_LIST_FUNC 1
 #else
 # define FTRACE_FORCE_LIST_FUNC 0
Signature · 1 line
2.0.1
author maintainer
#17 lore raw

PATCH 17/32 ftrace: x86: Remove check of obsolete variable function_trace_stop

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

Nothing sets function_trace_stop to disable function tracing anymore. Remove the check for it in the arch code.

---
 arch/x86/Kconfig            |  1 -
 arch/x86/kernel/entry_32.S  |  9 ---------
 arch/x86/kernel/mcount_64.S | 18 +-----------------
 3 files changed, 1 insertion(+), 27 deletions(-)
arch/x86/Kconfig +0 -1
index a8f749ef0fdc..5b45e8fccaca 100644
@@ -54,7 +54,6 @@ config X86
 	select HAVE_FUNCTION_TRACER
 	select HAVE_FUNCTION_GRAPH_TRACER
 	select HAVE_FUNCTION_GRAPH_FP_TEST
-	select HAVE_FUNCTION_TRACE_MCOUNT_TEST
 	select HAVE_SYSCALL_TRACEPOINTS
 	select SYSCTL_EXCEPTION_TRACE
 	select HAVE_KVM
arch/x86/kernel/entry_32.S +0 -9
index dbaa23e78b36..64762c62e8a7 100644
@@ -1058,9 +1058,6 @@ ENTRY(mcount)
 END(mcount)
 
 ENTRY(ftrace_caller)
-	cmpl $0, function_trace_stop
-	jne  ftrace_stub
-
 	pushl %eax
 	pushl %ecx
 	pushl %edx
@@ -1092,8 +1089,6 @@ END(ftrace_caller)
 
 ENTRY(ftrace_regs_caller)
 	pushf	/* push flags before compare (in cs location) */
-	cmpl $0, function_trace_stop
-	jne ftrace_restore_flags
 
 	/*
 	 * i386 does not save SS and ESP when coming from kernel.
@@ -1152,7 +1147,6 @@ GLOBAL(ftrace_regs_call)
 	popf			/* Pop flags at end (no addl to corrupt flags) */
 	jmp ftrace_ret
 
-ftrace_restore_flags:
 	popf
 	jmp  ftrace_stub
 #else /* ! CONFIG_DYNAMIC_FTRACE */
@@ -1161,9 +1155,6 @@ ENTRY(mcount)
 	cmpl $__PAGE_OFFSET, %esp
 	jb ftrace_stub		/* Paging not enabled yet? */
 
-	cmpl $0, function_trace_stop
-	jne  ftrace_stub
-
 	cmpl $ftrace_stub, ftrace_trace_function
 	jnz trace
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
arch/x86/kernel/mcount_64.S +1 -17
index 6b4e3c3b3d74..c73aecf10d34 100644
@@ -46,10 +46,6 @@ END(function_hook)
 .endm
 
 ENTRY(ftrace_caller)
-	/* Check if tracing was disabled (quick check) */
-	cmpl $0, function_trace_stop
-	jne  ftrace_stub
-
 	ftrace_caller_setup
 	/* regs go into 4th parameter (but make it NULL) */
 	movq $0, %rcx
@@ -73,10 +69,6 @@ ENTRY(ftrace_regs_caller)
 	/* Save the current flags before compare (in SS location)*/
 	pushfq
 
-	/* Check if tracing was disabled (quick check) */
-	cmpl $0, function_trace_stop
-	jne  ftrace_restore_flags
-
 	/* skip=8 to skip flags saved in SS */
 	ftrace_caller_setup 8
 
@@ -131,7 +123,7 @@ GLOBAL(ftrace_regs_call)
 	popfq
 
 	jmp ftrace_return
-ftrace_restore_flags:
+
 	popfq
 	jmp  ftrace_stub
 
@@ -141,9 +133,6 @@ END(ftrace_regs_caller)
 #else /* ! CONFIG_DYNAMIC_FTRACE */
 
 ENTRY(function_hook)
-	cmpl $0, function_trace_stop
-	jne  ftrace_stub
-
 	cmpq $ftrace_stub, ftrace_trace_function
 	jnz trace
 
@@ -182,10 +171,6 @@ END(function_hook)
 ENTRY(ftrace_graph_caller)
 	MCOUNT_SAVE_FRAME
 
-	/* Check if tracing was disabled (quick check) */
-	cmpl $0, function_trace_stop
-	jne  fgraph_skip
-
 #ifdef CC_USING_FENTRY
 	leaq SS+16(%rsp), %rdi
 	movq $0, %rdx	/* No framepointers needed */
@@ -198,7 +183,6 @@ ENTRY(ftrace_graph_caller)
 
 	call	prepare_ftrace_return
 
-fgraph_skip:
 	MCOUNT_RESTORE_FRAME
 
 	retq
Signature · 1 line
2.0.1
author maintainer
#18 lore raw

PATCH 18/32 tile: ftrace: Remove check of obsolete variable function_trace_stop

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

Nothing sets function_trace_stop to disable function tracing anymore. Remove the check for it in the arch code.

---
 arch/tile/Kconfig            |  1 -
 arch/tile/kernel/mcount_64.S | 18 ------------------
 2 files changed, 19 deletions(-)
arch/tile/Kconfig +0 -1
index 4f3006b600e3..7fcd492adbfc 100644
@@ -128,7 +128,6 @@ config TILEGX
 	select SPARSE_IRQ
 	select GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
 	select HAVE_FUNCTION_TRACER
-	select HAVE_FUNCTION_TRACE_MCOUNT_TEST
 	select HAVE_FUNCTION_GRAPH_TRACER
 	select HAVE_DYNAMIC_FTRACE
 	select HAVE_FTRACE_MCOUNT_RECORD
arch/tile/kernel/mcount_64.S +0 -18
index 70d7bb0c4d8f..3c2b8d5e1d1a 100644
@@ -77,15 +77,6 @@ STD_ENDPROC(__mcount)
 
 	.align	64
 STD_ENTRY(ftrace_caller)
-	moveli	r11, hw2_last(function_trace_stop)
-	{ shl16insli	r11, r11, hw1(function_trace_stop); move r12, lr }
-	{ shl16insli	r11, r11, hw0(function_trace_stop); move lr, r10 }
-	ld	r11, r11
-	beqz	r11, 1f
-	jrp	r12
-
-1:
-	{ move	r10, lr; move	lr, r12 }
 	MCOUNT_SAVE_REGS
 
 	/* arg1: self return address */
@@ -119,15 +110,6 @@ STD_ENDPROC(ftrace_caller)
 
 	.align	64
 STD_ENTRY(__mcount)
-	moveli	r11, hw2_last(function_trace_stop)
-	{ shl16insli	r11, r11, hw1(function_trace_stop); move r12, lr }
-	{ shl16insli	r11, r11, hw0(function_trace_stop); move lr, r10 }
-	ld	r11, r11
-	beqz	r11, 1f
-	jrp	r12
-
-1:
-	{ move	r10, lr; move	lr, r12 }
 	{
 	 moveli	r11, hw2_last(ftrace_trace_function)
 	 moveli	r13, hw2_last(ftrace_stub)
Signature · 1 line
2.0.1
author maintainer
#19 lore raw

PATCH 19/32 sparc64,ftrace: Remove check of obsolete variable function_trace_stop

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

Nothing sets function_trace_stop to disable function tracing anymore. Remove the check for it in the arch code.

Cc David S. Miller <[email protected]>
OKed-to-go-through-tracing-tree-by David S. Miller <[email protected]>
---
 arch/sparc/Kconfig      |  1 -
 arch/sparc/lib/mcount.S | 10 ++--------
 2 files changed, 2 insertions(+), 9 deletions(-)
arch/sparc/Kconfig +0 -1
index 29f2e988c56a..abd7d5575a7d 100644
@@ -55,7 +55,6 @@ config SPARC64
 	select HAVE_FUNCTION_TRACER
 	select HAVE_FUNCTION_GRAPH_TRACER
 	select HAVE_FUNCTION_GRAPH_FP_TEST
-	select HAVE_FUNCTION_TRACE_MCOUNT_TEST
 	select HAVE_KRETPROBES
 	select HAVE_KPROBES
 	select HAVE_RCU_TABLE_FREE if SMP
arch/sparc/lib/mcount.S +2 -8
index 3ad6cbdc2163..0b0ed4d34219 100644
@@ -24,10 +24,7 @@ mcount:
 #ifdef CONFIG_DYNAMIC_FTRACE
 	/* Do nothing, the retl/nop below is all we need.  */
 #else
-	sethi		%hi(function_trace_stop), %g1
-	lduw		[%g1 + %lo(function_trace_stop)], %g2
-	brnz,pn		%g2, 2f
-	 sethi		%hi(ftrace_trace_function), %g1
+	sethi		%hi(ftrace_trace_function), %g1
 	sethi		%hi(ftrace_stub), %g2
 	ldx		[%g1 + %lo(ftrace_trace_function)], %g1
 	or		%g2, %lo(ftrace_stub), %g2
@@ -80,11 +77,8 @@ ftrace_stub:
 	.globl		ftrace_caller
 	.type		ftrace_caller,#function
 ftrace_caller:
-	sethi		%hi(function_trace_stop), %g1
 	mov		%i7, %g2
-	lduw		[%g1 + %lo(function_trace_stop)], %g1
-	brnz,pn		%g1, ftrace_stub
-	 mov		%fp, %g3
+	mov		%fp, %g3
 	save		%sp, -176, %sp
 	mov		%g2, %o1
 	mov		%g2, %l0
Signature · 1 line
2.0.1
author maintainer
#20 lore raw

PATCH 20/32 sh: ftrace: Remove check of obsolete variable function_trace_stop

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

Nothing sets function_trace_stop to disable function tracing anymore. Remove the check for it in the arch code.

[ Please test this on your arch ]

Cc Matt Fleming <[email protected]>
Cc Paul Mundt <[email protected]>
---
 arch/sh/Kconfig      |  1 -
 arch/sh/lib/mcount.S | 24 ++----------------------
 2 files changed, 2 insertions(+), 23 deletions(-)
arch/sh/Kconfig +0 -1
index 834b67c4db5a..aa2df3eaeb29 100644
@@ -57,7 +57,6 @@ config SUPERH32
 	select HAVE_FUNCTION_TRACER
 	select HAVE_FTRACE_MCOUNT_RECORD
 	select HAVE_DYNAMIC_FTRACE
-	select HAVE_FUNCTION_TRACE_MCOUNT_TEST
 	select HAVE_FTRACE_NMI_ENTER if DYNAMIC_FTRACE
 	select ARCH_WANT_IPC_PARSE_VERSION
 	select HAVE_FUNCTION_GRAPH_TRACER
arch/sh/lib/mcount.S +2 -22
index 52aa2011d753..7a8572f9d58b 100644
@@ -92,13 +92,6 @@ mcount:
 	rts
 	 nop
 #else
-#ifndef CONFIG_DYNAMIC_FTRACE
-	mov.l	.Lfunction_trace_stop, r0
-	mov.l	@r0, r0
-	tst	r0, r0
-	bf	ftrace_stub
-#endif
-
 	MCOUNT_ENTER()
 
 #ifdef CONFIG_DYNAMIC_FTRACE
@@ -174,11 +167,6 @@ ftrace_graph_call:
 
 	.globl ftrace_caller
 ftrace_caller:
-	mov.l	.Lfunction_trace_stop, r0
-	mov.l	@r0, r0
-	tst	r0, r0
-	bf	ftrace_stub
-
 	MCOUNT_ENTER()
 
 	.globl ftrace_call
@@ -196,8 +184,6 @@ ftrace_call:
 #endif /* CONFIG_DYNAMIC_FTRACE */
 
 	.align 2
-.Lfunction_trace_stop:
-	.long	function_trace_stop
 
 /*
  * NOTE: From here on the locations of the .Lftrace_stub label and
@@ -217,12 +203,7 @@ ftrace_stub:
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 	.globl	ftrace_graph_caller
 ftrace_graph_caller:
-	mov.l	2f, r0
-	mov.l	@r0, r0
-	tst	r0, r0
-	bt	1f
-
-	mov.l	3f, r1
+	mov.l	2f, r1
 	jmp	@r1
 	 nop
 1:
@@ -242,8 +223,7 @@ ftrace_graph_caller:
 	MCOUNT_LEAVE()
 
 	.align 2
-2:	.long	function_trace_stop
-3:	.long	skip_trace
+2:	.long	skip_trace
 .Lprepare_ftrace_return:
 	.long	prepare_ftrace_return
 
Signature · 1 line
2.0.1
#21 lore raw

Re: [for-next][PATCH 20/32] sh: ftrace: Remove check of obsolete variable function_trace_stop

Quoted 7 lines · Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

Nothing sets function_trace_stop to disable function tracing anymore. Remove the check for it in the arch code.

[ Please test this on your arch ]

Quoted 7 lines
Cc Matt Fleming <[email protected]>
Cc Paul Mundt <[email protected]>
---
 arch/sh/Kconfig      |  1 -
 arch/sh/lib/mcount.S | 24 ++----------------------
 2 files changed, 2 insertions(+), 23 deletions(-)

I no longer have hardware to test this on, but it looks pretty straight forward.

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
author maintainer
#22 lore raw

Re: [for-next][PATCH 20/32] sh: ftrace: Remove check of obsolete variable function_trace_stop

Quoted 16 lines · On Mon, 21 Jul 2014 12:05:29 +0100 Matt Fleming <[email protected]> wrote:
Quoted 7 lines · Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

Nothing sets function_trace_stop to disable function tracing anymore. Remove the check for it in the arch code.

[ Please test this on your arch ]

Quoted 7 lines
Cc Matt Fleming <[email protected]>
Cc Paul Mundt <[email protected]>
---
 arch/sh/Kconfig      |  1 -
 arch/sh/lib/mcount.S | 24 ++----------------------
 2 files changed, 2 insertions(+), 23 deletions(-)
Quoted 3 lines

I no longer have hardware to test this on, but it looks pretty straight forward.

Thanks.

I've already pushed this to my next repo, so it's going to keep the "Please test this on your arch" ;-)

Anyway, the arch has been orphaned, thus it's not really that important.

-- Steve

author maintainer
#23 lore raw

PATCH 21/32 parisc: ftrace: Remove check of obsolete variable function_trace_stop

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

Nothing sets function_trace_stop to disable function tracing anymore. Remove the check for it in the arch code.

---
 arch/parisc/Kconfig         | 1 -
 arch/parisc/kernel/ftrace.c | 3 ---
 2 files changed, 4 deletions(-)
arch/parisc/Kconfig +0 -1
index 108d48e652af..6e75e2030927 100644
@@ -6,7 +6,6 @@ config PARISC
 	select HAVE_OPROFILE
 	select HAVE_FUNCTION_TRACER if 64BIT
 	select HAVE_FUNCTION_GRAPH_TRACER if 64BIT
-	select HAVE_FUNCTION_TRACE_MCOUNT_TEST if 64BIT
 	select ARCH_WANT_FRAME_POINTERS
 	select RTC_CLASS
 	select RTC_DRV_GENERIC
arch/parisc/kernel/ftrace.c +0 -3
index 5512ab32c5e0..559d400f9385 100644
@@ -155,9 +155,6 @@ void ftrace_function_trampoline(unsigned long parent,
 {
 	extern ftrace_func_t ftrace_trace_function;
 
-	if (function_trace_stop)
-		return;
-
 	if (ftrace_trace_function != ftrace_stub) {
 		ftrace_trace_function(parent, self_addr);
 		return;
Signature · 1 line
2.0.1
author maintainer
#24 lore raw

PATCH 22/32 MIPS: ftrace: Remove check of obsolete variable function_trace_stop

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

Nothing sets function_trace_stop to disable function tracing anymore. Remove the check for it in the arch code.

---
 arch/mips/Kconfig         | 1 -
 arch/mips/kernel/mcount.S | 7 -------
 2 files changed, 8 deletions(-)
arch/mips/Kconfig +0 -1
index 4e238e6e661c..10f270bd3e25 100644
@@ -15,7 +15,6 @@ config MIPS
 	select HAVE_BPF_JIT if !CPU_MICROMIPS
 	select ARCH_HAVE_CUSTOM_GPIO_H
 	select HAVE_FUNCTION_TRACER
-	select HAVE_FUNCTION_TRACE_MCOUNT_TEST
 	select HAVE_DYNAMIC_FTRACE
 	select HAVE_FTRACE_MCOUNT_RECORD
 	select HAVE_C_RECORDMCOUNT
arch/mips/kernel/mcount.S +0 -7
index 539b6294b613..00940d1d5c4f 100644
@@ -74,10 +74,6 @@ _mcount:
 #endif
 
 	/* When tracing is activated, it calls ftrace_caller+8 (aka here) */
-	lw	t1, function_trace_stop
-	bnez	t1, ftrace_stub
-	 nop
-
 	MCOUNT_SAVE_REGS
 #ifdef KBUILD_MCOUNT_RA_ADDRESS
 	PTR_S	MCOUNT_RA_ADDRESS_REG, PT_R12(sp)
@@ -105,9 +101,6 @@ ftrace_stub:
 #else	/* ! CONFIG_DYNAMIC_FTRACE */
 
 NESTED(_mcount, PT_SIZE, ra)
-	lw	t1, function_trace_stop
-	bnez	t1, ftrace_stub
-	 nop
 	PTR_LA	t1, ftrace_stub
 	PTR_L	t2, ftrace_trace_function /* Prepare t2 for (1) */
 	bne	t1, t2, static_trace
Signature · 1 line
2.0.1
author maintainer
#25 lore raw

PATCH 23/32 microblaze: ftrace: Remove check of obsolete variable function_trace_stop

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

Nothing sets function_trace_stop to disable function tracing anymore. Remove the check for it in the arch code.

---
 arch/microblaze/Kconfig         | 1 -
 arch/microblaze/kernel/mcount.S | 5 -----
 2 files changed, 6 deletions(-)
arch/microblaze/Kconfig +0 -1
index 9ae08541e30d..40e1c1dd0e24 100644
@@ -22,7 +22,6 @@ config MICROBLAZE
 	select HAVE_DYNAMIC_FTRACE
 	select HAVE_FTRACE_MCOUNT_RECORD
 	select HAVE_FUNCTION_GRAPH_TRACER
-	select HAVE_FUNCTION_TRACE_MCOUNT_TEST
 	select HAVE_FUNCTION_TRACER
 	select HAVE_MEMBLOCK
 	select HAVE_MEMBLOCK_NODE_MAP
arch/microblaze/kernel/mcount.S +0 -5
index fc1e1322ce4c..fed9da5de8c4 100644
@@ -91,11 +91,6 @@ ENTRY(ftrace_caller)
 #endif /* CONFIG_DYNAMIC_FTRACE */
 	SAVE_REGS
 	swi	r15, r1, 0;
-	/* MS: HAVE_FUNCTION_TRACE_MCOUNT_TEST begin of checking */
-	lwi	r5, r0, function_trace_stop;
-	bneid	r5, end;
-	nop;
-	/* MS: HAVE_FUNCTION_TRACE_MCOUNT_TEST end of checking */
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 #ifndef CONFIG_DYNAMIC_FTRACE
 	lwi	r5, r0, ftrace_graph_return;
Signature · 1 line
2.0.1
author maintainer
#26 lore raw

PATCH 24/32 metag: ftrace: Remove check of obsolete variable function_trace_stop

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

Nothing sets function_trace_stop to disable function tracing anymore. Remove the check for it in the arch code.

---
 arch/metag/Kconfig              |  1 -
 arch/metag/kernel/ftrace_stub.S | 14 --------------
 2 files changed, 15 deletions(-)
arch/metag/Kconfig +0 -1
index 499b7610eaaf..0b389a81c43a 100644
@@ -13,7 +13,6 @@ config METAG
 	select HAVE_DYNAMIC_FTRACE
 	select HAVE_FTRACE_MCOUNT_RECORD
 	select HAVE_FUNCTION_TRACER
-	select HAVE_FUNCTION_TRACE_MCOUNT_TEST
 	select HAVE_KERNEL_BZIP2
 	select HAVE_KERNEL_GZIP
 	select HAVE_KERNEL_LZO
arch/metag/kernel/ftrace_stub.S +0 -14
index e70bff745bdd..3acc288217c0 100644
@@ -16,13 +16,6 @@ _mcount_wrapper:
 	.global _ftrace_caller
 	.type	_ftrace_caller,function
 _ftrace_caller:
-	MOVT    D0Re0,#HI(_function_trace_stop)
-	ADD	D0Re0,D0Re0,#LO(_function_trace_stop)
-	GETD	D0Re0,[D0Re0]
-	CMP	D0Re0,#0
-	BEQ	$Lcall_stub
-	MOV	PC,D0.4
-$Lcall_stub:
 	MSETL   [A0StP], D0Ar6, D0Ar4, D0Ar2, D0.4
 	MOV     D1Ar1, D0.4
 	MOV     D0Ar2, D1RtP
@@ -42,13 +35,6 @@ _ftrace_call:
 	.global	_mcount_wrapper
 	.type	_mcount_wrapper,function
 _mcount_wrapper:
-	MOVT    D0Re0,#HI(_function_trace_stop)
-	ADD	D0Re0,D0Re0,#LO(_function_trace_stop)
-	GETD	D0Re0,[D0Re0]
-	CMP	D0Re0,#0
-	BEQ	$Lcall_mcount
-	MOV	PC,D0.4
-$Lcall_mcount:
 	MSETL   [A0StP], D0Ar6, D0Ar4, D0Ar2, D0.4
 	MOV     D1Ar1, D0.4
 	MOV     D0Ar2, D1RtP
Signature · 1 line
2.0.1
author maintainer
#27 lore raw

PATCH 25/32 Blackfin: ftrace: Remove check of obsolete variable function_trace_stop

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

Nothing sets function_trace_stop to disable function tracing anymore. Remove the check for it in the arch code.

---
 arch/blackfin/Kconfig               |  1 -
 arch/blackfin/kernel/ftrace-entry.S | 18 ------------------
 2 files changed, 19 deletions(-)
arch/blackfin/Kconfig +0 -1
index f81e7b989fff..ed30699cc635 100644
@@ -18,7 +18,6 @@ config BLACKFIN
 	select HAVE_FTRACE_MCOUNT_RECORD
 	select HAVE_FUNCTION_GRAPH_TRACER
 	select HAVE_FUNCTION_TRACER
-	select HAVE_FUNCTION_TRACE_MCOUNT_TEST
 	select HAVE_IDE
 	select HAVE_KERNEL_GZIP if RAMKERNEL
 	select HAVE_KERNEL_BZIP2 if RAMKERNEL
arch/blackfin/kernel/ftrace-entry.S +0 -18
index 7eed00bbd26d..28d059540424 100644
@@ -33,15 +33,6 @@ ENDPROC(__mcount)
  * function will be waiting there.  mmmm pie.
  */
 ENTRY(_ftrace_caller)
-# ifdef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST
-	/* optional micro optimization: return if stopped */
-	p1.l = _function_trace_stop;
-	p1.h = _function_trace_stop;
-	r3 = [p1];
-	cc = r3 == 0;
-	if ! cc jump _ftrace_stub (bp);
-# endif
-
 	/* save first/second/third function arg and the return register */
 	[--sp] = r2;
 	[--sp] = r0;
@@ -83,15 +74,6 @@ ENDPROC(_ftrace_caller)
 
 /* See documentation for _ftrace_caller */
 ENTRY(__mcount)
-# ifdef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST
-	/* optional micro optimization: return if stopped */
-	p1.l = _function_trace_stop;
-	p1.h = _function_trace_stop;
-	r3 = [p1];
-	cc = r3 == 0;
-	if ! cc jump _ftrace_stub (bp);
-# endif
-
 	/* save third function arg early so we can do testing below */
 	[--sp] = r2;
 
Signature · 1 line
2.0.1
author maintainer
#28 lore raw

PATCH 26/32 arm64, ftrace: Remove check of obsolete variable function_trace_stop

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

Nothing sets function_trace_stop to disable function tracing anymore. Remove the check for it in the arch code.

arm64 was broken anyway, as it had an ifdef testing
CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST which is only set if
the arch supports the code (which it obviously did not), and it was testing a non existent ftrace_trace_stop instead of function_trace_stop.

---
 arch/arm64/kernel/entry-ftrace.S | 5 -----
 1 file changed, 5 deletions(-)
arch/arm64/kernel/entry-ftrace.S +0 -5
index aa5f9fcbf9ee..38e704e597f7 100644
@@ -96,11 +96,6 @@
  *     - ftrace_graph_caller to set up an exit hook
  */
 ENTRY(_mcount)
-#ifdef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST
-	ldr	x0, =ftrace_trace_stop
-	ldr	x0, [x0]		// if ftrace_trace_stop
-	ret				//   return;
-#endif
 	mcount_enter
 
 	ldr	x0, =ftrace_trace_function
Signature · 1 line
2.0.1
author maintainer
#29 lore raw

PATCH 27/32 s390/ftrace: remove check of obsolete variable function_trace_stop

In reply to Steven Rostedt

From: Heiko Carstens <[email protected]>

Remove check of obsolete variable function_trace_stop as requested by Steven Rostedt.

---
 arch/s390/Kconfig           |  1 -
 arch/s390/kernel/mcount.S   | 10 +++-------
 arch/s390/kernel/mcount64.S |  3 ---
 3 files changed, 3 insertions(+), 11 deletions(-)
arch/s390/Kconfig +0 -1
index bb63499fc5d3..f5af5f6ef0f4 100644
@@ -116,7 +116,6 @@ config S390
 	select HAVE_FTRACE_MCOUNT_RECORD
 	select HAVE_FUNCTION_GRAPH_TRACER
 	select HAVE_FUNCTION_TRACER
-	select HAVE_FUNCTION_TRACE_MCOUNT_TEST
 	select HAVE_FUTEX_CMPXCHG if FUTEX
 	select HAVE_KERNEL_BZIP2
 	select HAVE_KERNEL_GZIP
arch/s390/kernel/mcount.S +3 -7
index 08dcf21cb8df..433c6dbfa442 100644
@@ -21,13 +21,9 @@ ENTRY(_mcount)
 ENTRY(ftrace_caller)
 #endif
 	stm	%r2,%r5,16(%r15)
-	bras	%r1,2f
+	bras	%r1,1f
 0:	.long	ftrace_trace_function
-1:	.long	function_trace_stop
-2:	l	%r2,1b-0b(%r1)
-	icm	%r2,0xf,0(%r2)
-	jnz	3f
-	st	%r14,56(%r15)
+1:	st	%r14,56(%r15)
 	lr	%r0,%r15
 	ahi	%r15,-96
 	l	%r3,100(%r15)
@@ -50,7 +46,7 @@ ENTRY(ftrace_graph_caller)
 #endif
 	ahi	%r15,96
 	l	%r14,56(%r15)
-3:	lm	%r2,%r5,16(%r15)
+	lm	%r2,%r5,16(%r15)
 	br	%r14
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
arch/s390/kernel/mcount64.S +0 -3
index 1c52eae3396a..c67a8bf0fd9a 100644
@@ -20,9 +20,6 @@ ENTRY(_mcount)
 
 ENTRY(ftrace_caller)
 #endif
-	larl	%r1,function_trace_stop
-	icm	%r1,0xf,0(%r1)
-	bnzr	%r14
 	stmg	%r2,%r5,32(%r15)
 	stg	%r14,112(%r15)
 	lgr	%r1,%r15
Signature · 1 line
2.0.1
author maintainer
#30 lore raw

PATCH 28/32 tracing: Remove function_trace_stop and HAVE_FUNCTION_TRACE_MCOUNT_TEST

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

All users of function_trace_stop and HAVE_FUNCTION_TRACE_MCOUNT_TEST have been removed. We can safely remove them from the kernel.

---
 include/linux/ftrace.h | 2 --
 kernel/trace/Kconfig   | 5 -----
 kernel/trace/ftrace.c  | 3 ---
 3 files changed, 10 deletions(-)
include/linux/ftrace.h +0 -2
index c800906235e1..7a5b7b97e539 100644
@@ -129,8 +129,6 @@ struct ftrace_ops {
 #endif
 };
 
-extern int function_trace_stop;
-
 /*
  * Type of the current tracing.
  */
kernel/trace/Kconfig +0 -5
index d4409356f40d..a5da09c899dd 100644
@@ -29,11 +29,6 @@ config HAVE_FUNCTION_GRAPH_FP_TEST
 	help
 	  See Documentation/trace/ftrace-design.txt
 
-config HAVE_FUNCTION_TRACE_MCOUNT_TEST
-	bool
-	help
-	  See Documentation/trace/ftrace-design.txt
-
 config HAVE_DYNAMIC_FTRACE
 	bool
 	help
kernel/trace/ftrace.c +0 -3
index 70abf97d6e84..4c61f28a08e0 100644
@@ -80,9 +80,6 @@ static struct ftrace_ops ftrace_list_end __read_mostly = {
 int ftrace_enabled __read_mostly;
 static int last_ftrace_enabled;
 
-/* Quick disabling of function tracer. */
-int function_trace_stop __read_mostly;
-
 /* Current function tracing op */
 struct ftrace_ops *function_trace_op __read_mostly = &ftrace_list_end;
 /* What to set function_trace_op to */
Signature · 1 line
2.0.1
author maintainer
#31 lore raw

PATCH 29/32 ring-buffer: Always run per-cpu ring buffer resize with schedule_work_on()

In reply to Steven Rostedt

From: Corey Minyard <[email protected]>

The code for resizing the trace ring buffers has to run the per-cpu resize on the CPU itself. The code was using preempt_off() and running the code for the current CPU directly, otherwise calling schedule_work_on().

At least on RT this could result in the following:

|BUG: sleeping function called from invalid context at kernel/rtmutex.c:673
|in_atomic(): 1, irqs_disabled(): 0, pid: 607, name: bash
|3 locks held by bash/607:
|CPU: 0 PID: 607 Comm: bash Not tainted 3.12.15-rt25+ #124
|(rt_spin_lock+0x28/0x68)
|(free_hot_cold_page+0x84/0x3b8)
|(free_buffer_page+0x14/0x20)
|(rb_update_pages+0x280/0x338)
|(ring_buffer_resize+0x32c/0x3dc)
|(free_snapshot+0x18/0x38)
|(tracing_set_tracer+0x27c/0x2ac)

probably via

|cd /sys/kernel/debug/tracing/
|echo 1 > events/enable ; sleep 2
|echo 1024 > buffer_size_kb

If we just always use schedule_work_on(), there's no need for the preempt_off(). So do that.

---
 kernel/trace/ring_buffer.c | 24 ++++--------------------
 1 file changed, 4 insertions(+), 20 deletions(-)
kernel/trace/ring_buffer.c +4 -20
index 7c56c3d06943..35825a87d6a3 100644
@@ -1693,22 +1693,14 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size,
 			if (!cpu_buffer->nr_pages_to_update)
 				continue;
 
-			/* The update must run on the CPU that is being updated. */
-			preempt_disable();
-			if (cpu == smp_processor_id() || !cpu_online(cpu)) {
+			/* Can't run something on an offline CPU. */
+			if (!cpu_online(cpu)) {
 				rb_update_pages(cpu_buffer);
 				cpu_buffer->nr_pages_to_update = 0;
 			} else {
-				/*
-				 * Can not disable preemption for schedule_work_on()
-				 * on PREEMPT_RT.
-				 */
-				preempt_enable();
 				schedule_work_on(cpu,
 						&cpu_buffer->update_pages_work);
-				preempt_disable();
 			}
-			preempt_enable();
 		}
 
 		/* wait for all the updates to complete */
@@ -1746,22 +1738,14 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size,
 
 		get_online_cpus();
 
-		preempt_disable();
-		/* The update must run on the CPU that is being updated. */
-		if (cpu_id == smp_processor_id() || !cpu_online(cpu_id))
+		/* Can't run something on an offline CPU. */
+		if (!cpu_online(cpu_id))
 			rb_update_pages(cpu_buffer);
 		else {
-			/*
-			 * Can not disable preemption for schedule_work_on()
-			 * on PREEMPT_RT.
-			 */
-			preempt_enable();
 			schedule_work_on(cpu_id,
 					 &cpu_buffer->update_pages_work);
 			wait_for_completion(&cpu_buffer->update_done);
-			preempt_disable();
 		}
-		preempt_enable();
 
 		cpu_buffer->nr_pages_to_update = 0;
 		put_online_cpus();
Signature · 1 line
2.0.1
author maintainer
#32 lore raw

PATCH 30/32 tracing: let user specify tracing_thresh after selecting function_graph

In reply to Steven Rostedt

From: Stanislav Fomichev <[email protected]>

Currently, tracing_thresh works only if we specify it before selecting function_graph tracer. If we do the opposite, tracing_thresh will change it's value, but it will not be applied.
To fix it, we add update_thresh callback which is called whenever tracing_thresh is updated and for function_graph tracer we register handler which reinitializes tracer depending on tracing_thresh.

---
 kernel/trace/trace.c                 | 65 ++++++++++++++++++++++++++++++++----
 kernel/trace/trace.h                 |  2 ++
 kernel/trace/trace_functions_graph.c |  7 ++++
 3 files changed, 67 insertions(+), 7 deletions(-)
kernel/trace/trace.c +58 -7
index 4a343db45d4e..2752147ed317 100644
@@ -4201,10 +4201,9 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf,
 }
 
 static ssize_t
-tracing_max_lat_read(struct file *filp, char __user *ubuf,
-		     size_t cnt, loff_t *ppos)
+tracing_nsecs_read(unsigned long *ptr, char __user *ubuf,
+		   size_t cnt, loff_t *ppos)
 {
-	unsigned long *ptr = filp->private_data;
 	char buf[64];
 	int r;
 
@@ -4216,10 +4215,9 @@ tracing_max_lat_read(struct file *filp, char __user *ubuf,
 }
 
 static ssize_t
-tracing_max_lat_write(struct file *filp, const char __user *ubuf,
-		      size_t cnt, loff_t *ppos)
+tracing_nsecs_write(unsigned long *ptr, const char __user *ubuf,
+		    size_t cnt, loff_t *ppos)
 {
-	unsigned long *ptr = filp->private_data;
 	unsigned long val;
 	int ret;
 
@@ -4232,6 +4230,52 @@ tracing_max_lat_write(struct file *filp, const char __user *ubuf,
 	return cnt;
 }
 
+static ssize_t
+tracing_thresh_read(struct file *filp, char __user *ubuf,
+		    size_t cnt, loff_t *ppos)
+{
+	return tracing_nsecs_read(&tracing_thresh, ubuf, cnt, ppos);
+}
+
+static ssize_t
+tracing_thresh_write(struct file *filp, const char __user *ubuf,
+		     size_t cnt, loff_t *ppos)
+{
+	struct trace_array *tr = filp->private_data;
+	int ret;
+
+	mutex_lock(&trace_types_lock);
+	ret = tracing_nsecs_write(&tracing_thresh, ubuf, cnt, ppos);
+	if (ret < 0)
+		goto out;
+
+	if (tr->current_trace->update_thresh) {
+		ret = tr->current_trace->update_thresh(tr);
+		if (ret < 0)
+			goto out;
+	}
+
+	ret = cnt;
+out:
+	mutex_unlock(&trace_types_lock);
+
+	return ret;
+}
+
+static ssize_t
+tracing_max_lat_read(struct file *filp, char __user *ubuf,
+		     size_t cnt, loff_t *ppos)
+{
+	return tracing_nsecs_read(filp->private_data, ubuf, cnt, ppos);
+}
+
+static ssize_t
+tracing_max_lat_write(struct file *filp, const char __user *ubuf,
+		      size_t cnt, loff_t *ppos)
+{
+	return tracing_nsecs_write(filp->private_data, ubuf, cnt, ppos);
+}
+
 static int tracing_open_pipe(struct inode *inode, struct file *filp)
 {
 	struct trace_array *tr = inode->i_private;
@@ -5133,6 +5177,13 @@ static int snapshot_raw_open(struct inode *inode, struct file *filp)
 #endif /* CONFIG_TRACER_SNAPSHOT */
 
 
+static const struct file_operations tracing_thresh_fops = {
+	.open		= tracing_open_generic,
+	.read		= tracing_thresh_read,
+	.write		= tracing_thresh_write,
+	.llseek		= generic_file_llseek,
+};
+
 static const struct file_operations tracing_max_lat_fops = {
 	.open		= tracing_open_generic,
 	.read		= tracing_max_lat_read,
@@ -6494,7 +6545,7 @@ static __init int tracer_init_debugfs(void)
 	init_tracer_debugfs(&global_trace, d_tracer);
 
 	trace_create_file("tracing_thresh", 0644, d_tracer,
-			&tracing_thresh, &tracing_max_lat_fops);
+			&global_trace, &tracing_thresh_fops);
 
 	trace_create_file("README", 0444, d_tracer,
 			NULL, &tracing_readme_fops);
kernel/trace/trace.h +2 -0
index 9258f5a815db..385391fb1d3b 100644
@@ -339,6 +339,7 @@ struct tracer_flags {
  * @reset: called when one switches to another tracer
  * @start: called when tracing is unpaused (echo 1 > tracing_enabled)
  * @stop: called when tracing is paused (echo 0 > tracing_enabled)
+ * @update_thresh: called when tracing_thresh is updated
  * @open: called when the trace file is opened
  * @pipe_open: called when the trace_pipe file is opened
  * @close: called when the trace file is released
@@ -357,6 +358,7 @@ struct tracer {
 	void			(*reset)(struct trace_array *tr);
 	void			(*start)(struct trace_array *tr);
 	void			(*stop)(struct trace_array *tr);
+	int			(*update_thresh)(struct trace_array *tr);
 	void			(*open)(struct trace_iterator *iter);
 	void			(*pipe_open)(struct trace_iterator *iter);
 	void			(*close)(struct trace_iterator *iter);
kernel/trace/trace_functions_graph.c +7 -0
index 2c944e6c4a9d..74d98820497c 100644
@@ -475,6 +475,12 @@ static void graph_trace_reset(struct trace_array *tr)
 	unregister_ftrace_graph();
 }
 
+int graph_trace_update_thresh(struct trace_array *tr)
+{
+	graph_trace_reset(tr);
+	return graph_trace_init(tr);
+}
+
 static int max_bytes_for_cpu;
 
 static enum print_line_t
@@ -1525,6 +1531,7 @@ static struct trace_event graph_trace_ret_event = {
 
 static struct tracer graph_trace __tracer_data = {
 	.name		= "function_graph",
+	.update_thresh	= graph_trace_update_thresh,
 	.open		= graph_trace_open,
 	.pipe_open	= graph_trace_open,
 	.close		= graph_trace_close,
Signature · 1 line
2.0.1
author maintainer
#33 lore raw

PATCH 31/32 ftrace: Do not copy old hash when resetting

In reply to Steven Rostedt

From: Wang Nan <[email protected]>

Do not waste time copying the old hash if the hash is going to be reset. Just allocate a new hash and free the old one, as that is the same result as copying te old one and then resetting it.

[ SDR: Removed unused ftrace_filter_reset() function ]
---
 kernel/trace/ftrace.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
kernel/trace/ftrace.c +5 -10
index 4c61f28a08e0..762806026561 100644
@@ -2949,13 +2949,6 @@ ftrace_enabled_open(struct inode *inode, struct file *file)
 	return iter ? 0 : -ENOMEM;
 }
 
-static void ftrace_filter_reset(struct ftrace_hash *hash)
-{
-	mutex_lock(&ftrace_lock);
-	ftrace_hash_clear(hash);
-	mutex_unlock(&ftrace_lock);
-}
-
 /**
  * ftrace_regex_open - initialize function tracer filter files
  * @ops: The ftrace_ops that hold the hash filters
@@ -3720,14 +3713,16 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
 	else
 		orig_hash = &ops->notrace_hash;
 
-	hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash);
+	if (reset)
+		hash = alloc_ftrace_hash(FTRACE_HASH_DEFAULT_BITS);
+	else
+		hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash);
+
 	if (!hash) {
 		ret = -ENOMEM;
 		goto out_regex_unlock;
 	}
 
-	if (reset)
-		ftrace_filter_reset(hash);
 	if (buf && !ftrace_match_records(hash, buf, len)) {
 		ret = -EINVAL;
 		goto out_regex_unlock;
Signature · 1 line
2.0.1
author maintainer
#34 lore raw

PATCH 32/32 tracing: Convert local function_graph functions to static

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

Local functions should be static.

---
 kernel/trace/trace_functions_graph.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/trace/trace_functions_graph.c +4 -4
index 74d98820497c..f0a0c982cde3 100644
@@ -353,7 +353,7 @@ int trace_graph_entry(struct ftrace_graph_ent *trace)
 	return ret;
 }
 
-int trace_graph_thresh_entry(struct ftrace_graph_ent *trace)
+static int trace_graph_thresh_entry(struct ftrace_graph_ent *trace)
 {
 	if (tracing_thresh)
 		return 1;
@@ -442,7 +442,7 @@ void set_graph_array(struct trace_array *tr)
 	smp_mb();
 }
 
-void trace_graph_thresh_return(struct ftrace_graph_ret *trace)
+static void trace_graph_thresh_return(struct ftrace_graph_ret *trace)
 {
 	if (tracing_thresh &&
 	    (trace->rettime - trace->calltime < tracing_thresh))
@@ -475,7 +475,7 @@ static void graph_trace_reset(struct trace_array *tr)
 	unregister_ftrace_graph();
 }
 
-int graph_trace_update_thresh(struct trace_array *tr)
+static int graph_trace_update_thresh(struct trace_array *tr)
 {
 	graph_trace_reset(tr);
 	return graph_trace_init(tr);
@@ -1435,7 +1435,7 @@ static void __print_graph_headers_flags(struct seq_file *s, u32 flags)
 	seq_printf(s, "               |   |   |   |\n");
 }
 
-void print_graph_headers(struct seq_file *s)
+static void print_graph_headers(struct seq_file *s)
 {
 	print_graph_headers_flags(s, tracer_flags.val);
 }
Signature · 1 line
2.0.1