Skip to contentSkip to conversation

tracing: Drop the tr check from the graph tracing path

PATCH In review Frederic Weisbecker 2 participants 3 messages Jan 14, 2010 – Jan 17, 2010 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing: Drop the tr check from the graph tracing path

Each time we save a function entry from the function graph tracer, we check if the trace array is set, which is wasteful because it is set anyway before we start the tracer. All we need is to ensure we have good read and write orderings. When we set the trace array, we just need to guarantee it to be visible before starting tracing.

Cc Steven Rostedt <[email protected]>
Cc Lai Jiangshan <[email protected]>
Cc Paul E. McKenney <[email protected]>
---
 kernel/trace/trace_functions_graph.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)
kernel/trace/trace_functions_graph.c +10 -9
index b1342c5..f225229 100644
@@ -212,9 +212,6 @@ int trace_graph_entry(struct ftrace_graph_ent *trace)
 	int cpu;
 	int pc;
 
-	if (unlikely(!tr))
-		return 0;
-
 	if (!ftrace_trace_task(current))
 		return 0;
 
@@ -287,11 +284,20 @@ void trace_graph_return(struct ftrace_graph_ret *trace)
 	local_irq_restore(flags);
 }
 
+void set_graph_array(struct trace_array *tr)
+{
+	graph_array = tr;
+
+	/* Make graph_array visible before we start tracing */
+
+	smp_mb();
+}
+
 static int graph_trace_init(struct trace_array *tr)
 {
 	int ret;
 
-	graph_array = tr;
+	set_graph_array(tr);
 	ret = register_ftrace_graph(&trace_graph_return,
 				    &trace_graph_entry);
 	if (ret)
@@ -301,11 +307,6 @@ static int graph_trace_init(struct trace_array *tr)
 	return 0;
 }
 
-void set_graph_array(struct trace_array *tr)
-{
-	graph_array = tr;
-}
-
 static void graph_trace_reset(struct trace_array *tr)
 {
 	tracing_stop_cmdline_record();
Signature · 1 line
1.6.2.3
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Frederic Weisbecker

Each time we save a function entry from the function graph tracer, we check if the trace array is set, which is wasteful because it is set anyway before we start the tracer. All we need is to ensure we have good read and write orderings. When we set the trace array, we just need to guarantee it to be visible before starting tracing.

-- Steve

Quoted 5 lines
Cc Lai Jiangshan <[email protected]>
Cc Paul E. McKenney <[email protected]>
---
 kernel/trace/trace_functions_graph.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)
#2 lore raw
In reply to Frederic Weisbecker
Commit-ID:  24a53652e361321b09df5040711e69387344ce09
Gitweb:     http://git.kernel.org/tip/24a53652e361321b09df5040711e69387344ce09
Author:     Frederic Weisbecker <[email protected]>
AuthorDate: Thu, 14 Jan 2010 08:23:15 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sun, 17 Jan 2010 08:06:25 +0100

tracing: Drop the tr check from the graph tracing path

Each time we save a function entry from the function graph tracer, we check if the trace array is set, which is wasteful because it is set anyway before we start the tracer. All we need is to ensure we have good read and write orderings. When we set the trace array, we just need to guarantee it to be visible before starting tracing.

LKML-Reference: <[email protected]>

---
 kernel/trace/trace_functions_graph.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)
kernel/trace/trace_functions_graph.c +10 -9
index b1342c5..f225229 100644
@@ -212,9 +212,6 @@ int trace_graph_entry(struct ftrace_graph_ent *trace)
 	int cpu;
 	int pc;
 
-	if (unlikely(!tr))
-		return 0;
-
 	if (!ftrace_trace_task(current))
 		return 0;
 
@@ -287,11 +284,20 @@ void trace_graph_return(struct ftrace_graph_ret *trace)
 	local_irq_restore(flags);
 }
 
+void set_graph_array(struct trace_array *tr)
+{
+	graph_array = tr;
+
+	/* Make graph_array visible before we start tracing */
+
+	smp_mb();
+}
+
 static int graph_trace_init(struct trace_array *tr)
 {
 	int ret;
 
-	graph_array = tr;
+	set_graph_array(tr);
 	ret = register_ftrace_graph(&trace_graph_return,
 				    &trace_graph_entry);
 	if (ret)
@@ -301,11 +307,6 @@ static int graph_trace_init(struct trace_array *tr)
 	return 0;
 }
 
-void set_graph_array(struct trace_array *tr)
-{
-	graph_array = tr;
-}
-
 static void graph_trace_reset(struct trace_array *tr)
 {
 	tracing_stop_cmdline_record();