@@ -106,6 +106,7 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
106106
107107#define TP_PROTO (args ...) args
108108#define TP_ARGS (args ...) args
109+ #define TP_CONDITION (args ...) args
109110
110111#ifdef CONFIG_TRACEPOINTS
111112
@@ -119,12 +120,14 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
119120 * as "(void *, void)". The DECLARE_TRACE_NOARGS() will pass in just
120121 * "void *data", where as the DECLARE_TRACE() will pass in "void *data, proto".
121122 */
122- #define __DO_TRACE (tp , proto , args ) \
123+ #define __DO_TRACE (tp , proto , args , cond ) \
123124 do { \
124125 struct tracepoint_func *it_func_ptr; \
125126 void *it_func; \
126127 void *__data; \
127128 \
129+ if (!(cond)) \
130+ return; \
128131 rcu_read_lock_sched_notrace(); \
129132 it_func_ptr = rcu_dereference_sched((tp)->funcs); \
130133 if (it_func_ptr) { \
@@ -142,7 +145,7 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
142145 * not add unwanted padding between the beginning of the section and the
143146 * structure. Force alignment to the same alignment as the section start.
144147 */
145- #define __DECLARE_TRACE (name , proto , args , data_proto , data_args ) \
148+ #define __DECLARE_TRACE (name , proto , args , cond , data_proto , data_args ) \
146149 extern struct tracepoint __tracepoint_##name; \
147150 static inline void trace_##name(proto) \
148151 { \
@@ -151,7 +154,8 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
151154do_trace: \
152155 __DO_TRACE(&__tracepoint_##name, \
153156 TP_PROTO(data_proto), \
154- TP_ARGS(data_args)); \
157+ TP_ARGS(data_args), \
158+ TP_CONDITION(cond)); \
155159 } \
156160 static inline int \
157161 register_trace_##name(void (*probe)(data_proto), void *data) \
@@ -186,7 +190,7 @@ do_trace: \
186190 EXPORT_SYMBOL(__tracepoint_##name)
187191
188192#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 ) \
190194 static inline void trace_##name(proto) \
191195 { } \
192196 static inline int \
@@ -227,13 +231,18 @@ do_trace: \
227231 * "void *__data, proto" as the callback prototype.
228232 */
229233#define DECLARE_TRACE_NOARGS (name ) \
230- __DECLARE_TRACE(name, void, , void *__data, __data)
234+ __DECLARE_TRACE(name, void, , 1, void *__data, __data)
231235
232236#define DECLARE_TRACE (name , proto , args ) \
233- __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \
237+ __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), 1, \
234238 PARAMS(void *__data, proto), \
235239 PARAMS(__data, args))
236240
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+
237246#define TRACE_EVENT_FLAGS (event , flag )
238247
239248#endif /* DECLARE_TRACE */
@@ -349,12 +358,20 @@ do_trace: \
349358 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
350359#define DEFINE_EVENT_PRINT (template , name , proto , args , print ) \
351360 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))
352365
353366#define TRACE_EVENT (name , proto , args , struct , assign , print ) \
354367 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
355368#define TRACE_EVENT_FN (name , proto , args , struct , \
356369 assign , print , reg , unreg ) \
357370 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))
358375
359376#define TRACE_EVENT_FLAGS (event , flag )
360377
0 commit comments