aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2008-12-03 15:36:57 -0500
committerIngo Molnar <mingo@elte.hu>2008-12-04 03:09:34 -0500
commitea4e2bc4d9f7370e57a343ccb5e7c0ad3222ec3c (patch)
tree64a4a1d9d7d3de0695cb2e8c7161886ab660e311 /kernel/trace/trace.c
parentb29144c317fb748dae6d72c0f88eda9d43165b8d (diff)
ftrace: graph of a single function
This patch adds the file: /debugfs/tracing/set_graph_function which can be used along with the function graph tracer. When this file is empty, the function graph tracer will act as usual. When the file has a function in it, the function graph tracer will only trace that function. For example: # echo blk_unplug > /debugfs/tracing/set_graph_function # cat /debugfs/tracing/trace [...] ------------------------------------------ | 2) make-19003 => kjournald-2219 ------------------------------------------ 2) | blk_unplug() { 2) | dm_unplug_all() { 2) | dm_get_table() { 2) 1.381 us | _read_lock(); 2) 0.911 us | dm_table_get(); 2) 1. 76 us | _read_unlock(); 2) + 12.912 us | } 2) | dm_table_unplug_all() { 2) | blk_unplug() { 2) 0.778 us | generic_unplug_device(); 2) 2.409 us | } 2) 5.992 us | } 2) 0.813 us | dm_table_put(); 2) + 29. 90 us | } 2) + 34.532 us | } You can add up to 32 functions into this file. Currently we limit it to 32, but this may change with later improvements. To add another function, use the append '>>': # echo sys_read >> /debugfs/tracing/set_graph_function # cat /debugfs/tracing/set_graph_function blk_unplug sys_read Using the '>' will clear out the function and write anew: # echo sys_write > /debug/tracing/set_graph_function # cat /debug/tracing/set_graph_function sys_write Note, if you have function graph running while doing this, the small time between clearing it and updating it will cause the graph to record all functions. This should not be an issue because after it sets the filter, only those functions will be recorded from then on. If you need to only record a particular function then set this file first before starting the function graph tracer. In the future this side effect may be corrected. The set_graph_function file is similar to the set_ftrace_filter but it does not take wild cards nor does it allow for more than one function to be set with a single write. There is no technical reason why this is the case, I just do not have the time yet to implement that. Note, dynamic ftrace must be enabled for this to appear because it uses the dynamic ftrace records to match the name to the mcount call sites. Signed-off-by: Steven Rostedt <srostedt@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 8b6409a62b54..710b39acd81b 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1209,6 +1209,9 @@ int trace_graph_entry(struct ftrace_graph_ent *trace)
1209 int cpu; 1209 int cpu;
1210 int pc; 1210 int pc;
1211 1211
1212 if (!ftrace_graph_addr(trace->func))
1213 return 0;
1214
1212 local_irq_save(flags); 1215 local_irq_save(flags);
1213 cpu = raw_smp_processor_id(); 1216 cpu = raw_smp_processor_id();
1214 data = tr->data[cpu]; 1217 data = tr->data[cpu];
@@ -1217,6 +1220,9 @@ int trace_graph_entry(struct ftrace_graph_ent *trace)
1217 pc = preempt_count(); 1220 pc = preempt_count();
1218 __trace_graph_entry(tr, data, trace, flags, pc); 1221 __trace_graph_entry(tr, data, trace, flags, pc);
1219 } 1222 }
1223 /* Only do the atomic if it is not already set */
1224 if (!test_tsk_trace_graph(current))
1225 set_tsk_trace_graph(current);
1220 atomic_dec(&data->disabled); 1226 atomic_dec(&data->disabled);
1221 local_irq_restore(flags); 1227 local_irq_restore(flags);
1222 1228
@@ -1240,6 +1246,8 @@ void trace_graph_return(struct ftrace_graph_ret *trace)
1240 pc = preempt_count(); 1246 pc = preempt_count();
1241 __trace_graph_return(tr, data, trace, flags, pc); 1247 __trace_graph_return(tr, data, trace, flags, pc);
1242 } 1248 }
1249 if (!trace->depth)
1250 clear_tsk_trace_graph(current);
1243 atomic_dec(&data->disabled); 1251 atomic_dec(&data->disabled);
1244 local_irq_restore(flags); 1252 local_irq_restore(flags);
1245} 1253}