aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/tracepoint.h
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-12-02 16:46:18 -0500
committerSteven Rostedt <rostedt@goodmis.org>2010-12-03 10:45:34 -0500
commit287050d390264402e11bea8b811859e42e8faa29 (patch)
treeb24814f1c985545f68ea9de87f7819b9230db0aa /include/linux/tracepoint.h
parent042957801626465492b9428860de39a3cb2a8219 (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/linux/tracepoint.h')
-rw-r--r--include/linux/tracepoint.h29
1 files changed, 23 insertions, 6 deletions
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 5a6074fcd81d..d3e4f87e95c0 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -106,6 +106,7 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
106 106
107#define TP_PROTO(args...) args 107#define TP_PROTO(args...) args
108#define TP_ARGS(args...) args 108#define TP_ARGS(args...) args
109#define TP_CONDITION(args...) args
109 110
110#ifdef CONFIG_TRACEPOINTS 111#ifdef CONFIG_TRACEPOINTS
111 112
@@ -119,12 +120,14 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
119 * as "(void *, void)". The DECLARE_TRACE_NOARGS() will pass in just 120 * as "(void *, void)". The DECLARE_TRACE_NOARGS() will pass in just
120 * "void *data", where as the DECLARE_TRACE() will pass in "void *data, proto". 121 * "void *data", where as the DECLARE_TRACE() will pass in "void *data, proto".
121 */ 122 */
122#define __DO_TRACE(tp, proto, args) \ 123#define __DO_TRACE(tp, proto, args, cond) \
123 do { \ 124 do { \
124 struct tracepoint_func *it_func_ptr; \ 125 struct tracepoint_func *it_func_ptr; \
125 void *it_func; \ 126 void *it_func; \
126 void *__data; \ 127 void *__data; \
127 \ 128 \
129 if (!(cond)) \
130 return; \
128 rcu_read_lock_sched_notrace(); \ 131 rcu_read_lock_sched_notrace(); \
129 it_func_ptr = rcu_dereference_sched((tp)->funcs); \ 132 it_func_ptr = rcu_dereference_sched((tp)->funcs); \
130 if (it_func_ptr) { \ 133 if (it_func_ptr) { \
@@ -142,7 +145,7 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
142 * not add unwanted padding between the beginning of the section and the 145 * not add unwanted padding between the beginning of the section and the
143 * structure. Force alignment to the same alignment as the section start. 146 * structure. Force alignment to the same alignment as the section start.
144 */ 147 */
145#define __DECLARE_TRACE(name, proto, args, data_proto, data_args) \ 148#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
146 extern struct tracepoint __tracepoint_##name; \ 149 extern struct tracepoint __tracepoint_##name; \
147 static inline void trace_##name(proto) \ 150 static inline void trace_##name(proto) \
148 { \ 151 { \
@@ -151,7 +154,8 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
151do_trace: \ 154do_trace: \
152 __DO_TRACE(&__tracepoint_##name, \ 155 __DO_TRACE(&__tracepoint_##name, \
153 TP_PROTO(data_proto), \ 156 TP_PROTO(data_proto), \
154 TP_ARGS(data_args)); \ 157 TP_ARGS(data_args), \
158 TP_CONDITION(cond)); \
155 } \ 159 } \
156 static inline int \ 160 static inline int \
157 register_trace_##name(void (*probe)(data_proto), void *data) \ 161 register_trace_##name(void (*probe)(data_proto), void *data) \
@@ -186,7 +190,7 @@ do_trace: \
186 EXPORT_SYMBOL(__tracepoint_##name) 190 EXPORT_SYMBOL(__tracepoint_##name)
187 191
188#else /* !CONFIG_TRACEPOINTS */ 192#else /* !CONFIG_TRACEPOINTS */
189#define __DECLARE_TRACE(name, proto, args, data_proto, data_args) \ 193#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
190 static inline void trace_##name(proto) \ 194 static inline void trace_##name(proto) \
191 { } \ 195 { } \
192 static inline int \ 196 static inline int \
@@ -227,13 +231,18 @@ do_trace: \
227 * "void *__data, proto" as the callback prototype. 231 * "void *__data, proto" as the callback prototype.
228 */ 232 */
229#define DECLARE_TRACE_NOARGS(name) \ 233#define DECLARE_TRACE_NOARGS(name) \
230 __DECLARE_TRACE(name, void, , void *__data, __data) 234 __DECLARE_TRACE(name, void, , 1, void *__data, __data)
231 235
232#define DECLARE_TRACE(name, proto, args) \ 236#define DECLARE_TRACE(name, proto, args) \
233 __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \ 237 __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), 1, \
234 PARAMS(void *__data, proto), \ 238 PARAMS(void *__data, proto), \
235 PARAMS(__data, args)) 239 PARAMS(__data, args))
236 240
241#define DECLARE_TRACE_CONDITION(name, proto, args, cond) \
242 __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), PARAMS(cond), \
243 PARAMS(void *__data, proto), \
244 PARAMS(__data, args))
245
237#define TRACE_EVENT_FLAGS(event, flag) 246#define TRACE_EVENT_FLAGS(event, flag)
238 247
239#endif /* DECLARE_TRACE */ 248#endif /* DECLARE_TRACE */
@@ -349,12 +358,20 @@ do_trace: \
349 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)) 358 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
350#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ 359#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
351 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)) 360 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
361#define DEFINE_EVENT_CONDITION(template, name, proto, \
362 args, cond) \
363 DECLARE_TRACE_CONDITION(name, PARAMS(proto), \
364 PARAMS(args), PARAMS(cond))
352 365
353#define TRACE_EVENT(name, proto, args, struct, assign, print) \ 366#define TRACE_EVENT(name, proto, args, struct, assign, print) \
354 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)) 367 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
355#define TRACE_EVENT_FN(name, proto, args, struct, \ 368#define TRACE_EVENT_FN(name, proto, args, struct, \
356 assign, print, reg, unreg) \ 369 assign, print, reg, unreg) \
357 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)) 370 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
371#define TRACE_EVENT_CONDITION(name, proto, args, cond, \
372 struct, assign, print) \
373 DECLARE_TRACE_CONDITION(name, PARAMS(proto), \
374 PARAMS(args), PARAMS(cond))
358 375
359#define TRACE_EVENT_FLAGS(event, flag) 376#define TRACE_EVENT_FLAGS(event, flag)
360 377