Skip to content

Commit 1633634

Browse files
laoarrostedt
authored andcommitted
tracing: introduce TRACE_EVENT_NOP()
Sometimes we want to define a tracepoint as a do-nothing function. So I introduce TRACE_EVENT_NOP, DECLARE_EVENT_CLASS_NOP and DEFINE_EVENT_NOP for this kind of usage. Link: http://lkml.kernel.org/r/1553602391-11926-2-git-send-email-laoar.shao@gmail.com Signed-off-by: Yafang Shao <laoar.shao@gmail.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent a8d6557 commit 1633634

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

include/linux/tracepoint.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,4 +548,19 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
548548

549549
#define TRACE_EVENT_PERF_PERM(event, expr...)
550550

551+
#define DECLARE_EVENT_NOP(name, proto, args) \
552+
static inline void trace_##name(proto) \
553+
{ } \
554+
static inline bool trace_##name##_enabled(void) \
555+
{ \
556+
return false; \
557+
}
558+
559+
#define TRACE_EVENT_NOP(name, proto, args, struct, assign, print) \
560+
DECLARE_EVENT_NOP(name, PARAMS(proto), PARAMS(args))
561+
562+
#define DECLARE_EVENT_CLASS_NOP(name, proto, args, tstruct, assign, print)
563+
#define DEFINE_EVENT_NOP(template, name, proto, args) \
564+
DECLARE_EVENT_NOP(name, PARAMS(proto), PARAMS(args))
565+
551566
#endif /* ifdef TRACE_EVENT (see note above) */

include/trace/define_trace.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
assign, print, reg, unreg) \
4747
DEFINE_TRACE_FN(name, reg, unreg)
4848

49+
#undef TRACE_EVENT_NOP
50+
#define TRACE_EVENT_NOP(name, proto, args, struct, assign, print)
51+
52+
#undef DEFINE_EVENT_NOP
53+
#define DEFINE_EVENT_NOP(template, name, proto, args)
54+
4955
#undef DEFINE_EVENT
5056
#define DEFINE_EVENT(template, name, proto, args) \
5157
DEFINE_TRACE(name)
@@ -102,6 +108,8 @@
102108
#undef TRACE_EVENT_FN
103109
#undef TRACE_EVENT_FN_COND
104110
#undef TRACE_EVENT_CONDITION
111+
#undef TRACE_EVENT_NOP
112+
#undef DEFINE_EVENT_NOP
105113
#undef DECLARE_EVENT_CLASS
106114
#undef DEFINE_EVENT
107115
#undef DEFINE_EVENT_FN

0 commit comments

Comments
 (0)