diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-12-02 16:46:18 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-12-03 10:45:34 -0500 |
commit | 287050d390264402e11bea8b811859e42e8faa29 (patch) | |
tree | b24814f1c985545f68ea9de87f7819b9230db0aa /include/trace/define_trace.h | |
parent | 042957801626465492b9428860de39a3cb2a8219 (diff) |
tracing: Add TRACE_EVENT_CONDITIONAL()
There are instances in the kernel that we only want to trace
a tracepoint when a certain condition is set. But we do not
want to test for that condition in the core kernel.
If we test for that condition before calling the tracepoin, then
we will be performing that test even when tracing is not enabled.
This is 99.99% of the time.
We currently can just filter out on that condition, but that happens
after we write to the trace buffer. We just wasted time writing to
the ring buffer for an event we never cared about.
This patch adds:
TRACE_EVENT_CONDITION() and DEFINE_EVENT_CONDITION()
These have a new TP_CONDITION() argument that comes right after
the TP_ARGS(). This condition can use the parameters of TP_ARGS()
in the TRACE_EVENT() to determine if the tracepoint should be traced
or not. The TP_CONDITION() will be placed in a if (cond) trace;
For example, for the tracepoint sched_wakeup, it is useless to
trace a wakeup event where the caller never actually wakes
anything up (where success == 0). So adding:
TP_CONDITION(success),
which uses the "success" parameter of the wakeup tracepoint
will have it only trace when we have successfully woken up a
task.
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arjan van de Ven <arjan@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'include/trace/define_trace.h')
-rw-r--r-- | include/trace/define_trace.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/trace/define_trace.h b/include/trace/define_trace.h index 1dfab5401511..b0b4eb24d592 100644 --- a/include/trace/define_trace.h +++ b/include/trace/define_trace.h | |||
@@ -26,6 +26,15 @@ | |||
26 | #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \ | 26 | #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \ |
27 | DEFINE_TRACE(name) | 27 | DEFINE_TRACE(name) |
28 | 28 | ||
29 | #undef TRACE_EVENT_CONDITION | ||
30 | #define TRACE_EVENT_CONDITION(name, proto, args, cond, tstruct, assign, print) \ | ||
31 | TRACE_EVENT(name, \ | ||
32 | PARAMS(proto), \ | ||
33 | PARAMS(args), \ | ||
34 | PARAMS(tstruct), \ | ||
35 | PARAMS(assign), \ | ||
36 | PARAMS(print)) | ||
37 | |||
29 | #undef TRACE_EVENT_FN | 38 | #undef TRACE_EVENT_FN |
30 | #define TRACE_EVENT_FN(name, proto, args, tstruct, \ | 39 | #define TRACE_EVENT_FN(name, proto, args, tstruct, \ |
31 | assign, print, reg, unreg) \ | 40 | assign, print, reg, unreg) \ |
@@ -39,6 +48,10 @@ | |||
39 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ | 48 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ |
40 | DEFINE_TRACE(name) | 49 | DEFINE_TRACE(name) |
41 | 50 | ||
51 | #undef DEFINE_EVENT_CONDITION | ||
52 | #define DEFINE_EVENT_CONDITION(template, name, proto, args, cond) \ | ||
53 | DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) | ||
54 | |||
42 | #undef DECLARE_TRACE | 55 | #undef DECLARE_TRACE |
43 | #define DECLARE_TRACE(name, proto, args) \ | 56 | #define DECLARE_TRACE(name, proto, args) \ |
44 | DEFINE_TRACE(name) | 57 | DEFINE_TRACE(name) |
@@ -75,9 +88,11 @@ | |||
75 | 88 | ||
76 | #undef TRACE_EVENT | 89 | #undef TRACE_EVENT |
77 | #undef TRACE_EVENT_FN | 90 | #undef TRACE_EVENT_FN |
91 | #undef TRACE_EVENT_CONDITION | ||
78 | #undef DECLARE_EVENT_CLASS | 92 | #undef DECLARE_EVENT_CLASS |
79 | #undef DEFINE_EVENT | 93 | #undef DEFINE_EVENT |
80 | #undef DEFINE_EVENT_PRINT | 94 | #undef DEFINE_EVENT_PRINT |
95 | #undef DEFINE_EVENT_CONDITION | ||
81 | #undef TRACE_HEADER_MULTI_READ | 96 | #undef TRACE_HEADER_MULTI_READ |
82 | #undef DECLARE_TRACE | 97 | #undef DECLARE_TRACE |
83 | 98 | ||