diff mbox

[4/8] tracing/function: Introduce persistent trace option

Message ID 1341879046-5197-4-git-send-email-anton.vorontsov@linaro.org
State Accepted
Commit 21f679404a0c28bd5b1b3aff2a7218bbff4cb43d
Headers show

Commit Message

Anton Vorontsov July 10, 2012, 12:10 a.m. UTC
This patch introduces 'func_ptrace' option, now available in
/sys/kernel/debug/tracing/options when function tracer
is selected.

The patch also adds some tiny code that calls back to pstore
to record the trace. The callback is no-op when PSTORE=n.

Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
---
 kernel/trace/trace_functions.c |   25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

Comments

Steven Rostedt July 10, 2012, 12:58 p.m. UTC | #1
On Mon, 2012-07-09 at 17:10 -0700, Anton Vorontsov wrote:

> +static struct tracer_flags func_flags;
> +
>  static void
>  function_trace_call(unsigned long ip, unsigned long parent_ip)
>  {
> @@ -97,6 +106,12 @@ function_trace_call(unsigned long ip, unsigned long parent_ip)
>  	disabled = atomic_inc_return(&data->disabled);
>  
>  	if (likely(disabled == 1)) {
> +		/*
> +		 * So far tracing doesn't support multiple buffers, so
> +		 * we make an explicit call for now.

I'm working on it ;-)

-- Steve

> +		 */
> +		if (unlikely(func_flags.val & TRACE_FUNC_OPT_PSTORE))
> +			pstore_ftrace_call(ip, parent_ip);
>  		pc = preempt_count();
>  		trace_function(tr, ip, parent_ip, flags, pc);
>  	}
diff mbox

Patch

diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c
index c7b0c6a..13770ab 100644
--- a/kernel/trace/trace_functions.c
+++ b/kernel/trace/trace_functions.c
@@ -13,6 +13,7 @@ 
 #include <linux/debugfs.h>
 #include <linux/uaccess.h>
 #include <linux/ftrace.h>
+#include <linux/pstore.h>
 #include <linux/fs.h>
 
 #include "trace.h"
@@ -74,6 +75,14 @@  function_trace_call_preempt_only(unsigned long ip, unsigned long parent_ip)
 	preempt_enable_notrace();
 }
 
+/* Our two options */
+enum {
+	TRACE_FUNC_OPT_STACK	= 0x1,
+	TRACE_FUNC_OPT_PSTORE	= 0x2,
+};
+
+static struct tracer_flags func_flags;
+
 static void
 function_trace_call(unsigned long ip, unsigned long parent_ip)
 {
@@ -97,6 +106,12 @@  function_trace_call(unsigned long ip, unsigned long parent_ip)
 	disabled = atomic_inc_return(&data->disabled);
 
 	if (likely(disabled == 1)) {
+		/*
+		 * So far tracing doesn't support multiple buffers, so
+		 * we make an explicit call for now.
+		 */
+		if (unlikely(func_flags.val & TRACE_FUNC_OPT_PSTORE))
+			pstore_ftrace_call(ip, parent_ip);
 		pc = preempt_count();
 		trace_function(tr, ip, parent_ip, flags, pc);
 	}
@@ -158,15 +173,13 @@  static struct ftrace_ops trace_stack_ops __read_mostly =
 	.flags = FTRACE_OPS_FL_GLOBAL,
 };
 
-/* Our two options */
-enum {
-	TRACE_FUNC_OPT_STACK = 0x1,
-};
-
 static struct tracer_opt func_opts[] = {
 #ifdef CONFIG_STACKTRACE
 	{ TRACER_OPT(func_stack_trace, TRACE_FUNC_OPT_STACK) },
 #endif
+#ifdef CONFIG_PSTORE_FTRACE
+	{ TRACER_OPT(func_pstore, TRACE_FUNC_OPT_PSTORE) },
+#endif
 	{ } /* Always set a last empty entry */
 };
 
@@ -218,6 +231,8 @@  static int func_set_flag(u32 old_flags, u32 bit, int set)
 		}
 
 		return 0;
+	} else if (bit == TRACE_FUNC_OPT_PSTORE) {
+		return 0;
 	}
 
 	return -EINVAL;