linux-stable/Documentation/trace
Steven Rostedt (Red Hat) 7c65bbc7dc tracing: Add trace_<tracepoint>_enabled() function
There are some code paths in the kernel that need to do some preparations
before it calls a tracepoint. As that code is worthless overhead when
the tracepoint is not enabled, it would be prudent to have that code
only run when the tracepoint is active. To accomplish this, all tracepoints
now get a static inline function called "trace_<tracepoint-name>_enabled()"
which returns true when the tracepoint is enabled and false otherwise.

As an added bonus, that function uses the static_key of the tracepoint
such that no branch is needed.

  if (trace_mytracepoint_enabled()) {
	arg = process_tp_arg();
	trace_mytracepoint(arg);
  }

Will keep the "process_tp_arg()" (which may be expensive to run) from
being executed when the tracepoint isn't enabled.

It's best to encapsulate the tracepoint itself in the if statement
just to keep races. For example, if you had:

  if (trace_mytracepoint_enabled())
	arg = process_tp_arg();
  trace_mytracepoint(arg);

There's a chance that the tracepoint could be enabled just after the
if statement, and arg will be undefined when calling the tracepoint.

Link: http://lkml.kernel.org/r/20140506094407.507b6435@gandalf.local.home

Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2014-05-07 12:10:51 -04:00
..
postprocess Documentation/trace/postprocess/trace-vmscan-postprocess.pl: fix the traceevent regex 2014-01-23 16:36:52 -08:00
events-kmem.txt mm-tracepoint: rename page-free events 2012-01-10 16:30:41 -08:00
events-nmi.txt x86: Add NMI duration tracepoints 2013-06-23 11:52:58 +02:00
events-power.txt PM / QoS: Rename device resume latency QoS items 2014-02-11 00:35:23 +01:00
events.txt tracing: Add documentation for trace event triggers 2013-12-21 22:02:18 -05:00
ftrace-design.txt ftrace: Do not pass data to ftrace_dyn_arch_init 2014-03-07 10:06:14 -05:00
ftrace.txt ftrace, sched: Add TRACE_FLAG_PREEMPT_RESCHED 2013-11-11 12:43:39 +01:00
function-graph-fold.vim tracing: Add vim script to enable folding for function_graph traces 2009-08-26 00:32:04 -04:00
kprobetrace.txt doc: fix old config name of kprobetrace 2012-09-27 12:11:29 +02:00
mmiotrace.txt Documentation: Update mmiotrace.txt 2009-12-20 06:18:23 +01:00
ring-buffer-design.txt doc: fix double words 2014-03-21 13:16:58 +01:00
tracepoint-analysis.txt mm-tracepoint: fix documentation and examples 2012-01-10 16:30:41 -08:00
tracepoints.txt tracing: Add trace_<tracepoint>_enabled() function 2014-05-07 12:10:51 -04:00
uprobetracer.txt tracing/uprobes: Add @+file_offset fetch method 2014-01-02 20:57:05 -05:00