ftrace: trace single pid for function graph tracer
authorSteven Rostedt <srostedt@redhat.com>
Wed, 3 Dec 2008 20:36:59 +0000 (15:36 -0500)
committerIngo Molnar <mingo@elte.hu>
Thu, 4 Dec 2008 08:09:36 +0000 (09:09 +0100)
Impact: New feature

This patch makes the changes to set_ftrace_pid apply to the function
graph tracer.

  # echo $$ > /debugfs/tracing/set_ftrace_pid
  # echo function_graph > /debugfs/tracing/current_tracer

Will cause only the current task to be traced. Note, the trace flags are
also inherited by child processes, so the children of the shell
will also be traced.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/trace/ftrace.c
kernel/trace/trace.c
kernel/trace/trace.h

index c5049f54a275fa823e774b998ba365f61cd8e4ad..57592a9dd6302d8cf2ccc54cbeda068914eac9cd 100644 (file)
@@ -48,7 +48,7 @@ int ftrace_enabled __read_mostly;
 static int last_ftrace_enabled;
 
 /* set when tracing only a pid */
-static int ftrace_pid_trace = -1;
+int ftrace_pid_trace = -1;
 
 /* Quick disabling of function tracer. */
 int function_trace_stop;
index 710b39acd81b94d7040dbbfde75814510ac85f28..1bd9574404e5020b77b8432c1cff74130a190401 100644 (file)
@@ -1209,6 +1209,9 @@ int trace_graph_entry(struct ftrace_graph_ent *trace)
        int cpu;
        int pc;
 
+       if (!ftrace_trace_task(current))
+               return 0;
+
        if (!ftrace_graph_addr(trace->func))
                return 0;
 
index 41f026bfc9ed6e622a901fc2b794dd70efa6981f..95fff37ed9700f43d70694db85b493485733203d 100644 (file)
@@ -541,6 +541,16 @@ print_graph_function(struct trace_iterator *iter)
 }
 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
 
+extern int ftrace_pid_trace;
+
+static inline int ftrace_trace_task(struct task_struct *task)
+{
+       if (ftrace_pid_trace < 0)
+               return 1;
+
+       return test_tsk_trace_trace(task);
+}
+
 /*
  * trace_iterator_flags is an enumeration that defines bit
  * positions into trace_flags that controls the output.