[RFC PATCH 04/10] ftrace: Ensure buffers are visibles to tracing callbacks right away

From: Frederic Weisbecker
Date: Thu Jan 21 2010 - 20:17:15 EST


A tracer may need to allocate specific buffers before calling
function tracing callbacks. And these callbacks may use these
buffers. To avoid lazy memory ordering, the callbacks may need
to check the state of the buffers before doing anything. This
is wasteful on the tracing hot path.

Let's then put an appropriate barrier before registering tracing
callbacks.

Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Li Zefan <lizf@xxxxxxxxxxxxxx>
Cc: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
---
kernel/trace/ftrace.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index f258f67..3cdb35e 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3099,6 +3099,14 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
goto out;
}

+ /*
+ * The tracing callbacks might use buffers that the tracer could
+ * have allocated just before. Ensure this is all visible before
+ * starting the tracing, so that we avoid null pointer checks
+ * in the tracing hot paths.
+ */
+ smp_mb();
+
ftrace_graph_return = retfunc;
ftrace_graph_entry = entryfunc;

--
1.6.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/