Commit ea2c68a08fedb5053ba312d661e47df9f4d72411

Authored by Lai Jiangshan
Committed by Frederic Weisbecker
1 parent 24a53652e3

tracing: Simplify test for function_graph tracing start point

In the function graph tracer, a calling function is to be traced
only when it is enabled through the set_graph_function file,
or when it is nested in an enabled function.

Current code uses TSK_TRACE_FL_GRAPH to test whether it is nested
or not. Looking at the code, we can get this:
(trace->depth > 0) <==> (TSK_TRACE_FL_GRAPH is set)

trace->depth is more explicit to tell that it is nested.
So we use trace->depth directly and simplify the code.

No functionality is changed.
TSK_TRACE_FL_GRAPH is not removed yet, it is left for future usage.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <4B4DB0B6.7040607@cn.fujitsu.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>

Showing 2 changed files with 3 additions and 7 deletions Side-by-side Diff

kernel/trace/trace.h
... ... @@ -504,7 +504,7 @@
504 504 {
505 505 int i;
506 506  
507   - if (!ftrace_graph_count || test_tsk_trace_graph(current))
  507 + if (!ftrace_graph_count)
508 508 return 1;
509 509  
510 510 for (i = 0; i < ftrace_graph_count; i++) {
kernel/trace/trace_functions_graph.c
... ... @@ -215,7 +215,8 @@
215 215 if (!ftrace_trace_task(current))
216 216 return 0;
217 217  
218   - if (!ftrace_graph_addr(trace->func))
  218 + /* trace it when it is-nested-in or is a function enabled. */
  219 + if (!(trace->depth || ftrace_graph_addr(trace->func)))
219 220 return 0;
220 221  
221 222 local_irq_save(flags);
... ... @@ -228,9 +229,6 @@
228 229 } else {
229 230 ret = 0;
230 231 }
231   - /* Only do the atomic if it is not already set */
232   - if (!test_tsk_trace_graph(current))
233   - set_tsk_trace_graph(current);
234 232  
235 233 atomic_dec(&data->disabled);
236 234 local_irq_restore(flags);
... ... @@ -278,8 +276,6 @@
278 276 pc = preempt_count();
279 277 __trace_graph_return(tr, trace, flags, pc);
280 278 }
281   - if (!trace->depth)
282   - clear_tsk_trace_graph(current);
283 279 atomic_dec(&data->disabled);
284 280 local_irq_restore(flags);
285 281 }