]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
tracing: introduce TRACE_EVENT_NOP()
authorYafang Shao <laoar.shao@gmail.com>
Tue, 26 Mar 2019 12:13:09 +0000 (20:13 +0800)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Mon, 8 Apr 2019 13:22:51 +0000 (09:22 -0400)
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>
include/linux/tracepoint.h
include/trace/define_trace.h

index 9c3186578ce06d2b872e6e93ad1da0e27cf36152..86b019aa28398fdf40748b30aeedd4cc8c6faa21 100644 (file)
@@ -548,4 +548,19 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
 
 #define TRACE_EVENT_PERF_PERM(event, expr...)
 
+#define DECLARE_EVENT_NOP(name, proto, args)                           \
+       static inline void trace_##name(proto)                          \
+       { }                                                             \
+       static inline bool trace_##name##_enabled(void)                 \
+       {                                                               \
+               return false;                                           \
+       }
+
+#define TRACE_EVENT_NOP(name, proto, args, struct, assign, print)      \
+       DECLARE_EVENT_NOP(name, PARAMS(proto), PARAMS(args))
+
+#define DECLARE_EVENT_CLASS_NOP(name, proto, args, tstruct, assign, print)
+#define DEFINE_EVENT_NOP(template, name, proto, args)                  \
+       DECLARE_EVENT_NOP(name, PARAMS(proto), PARAMS(args))
+
 #endif /* ifdef TRACE_EVENT (see note above) */
index cb30c5532144883c7f534a5d7340bb294b49b998..bd75f97867b99a64ba0706a516cb06f0e4cc5a42 100644 (file)
                assign, print, reg, unreg)                      \
        DEFINE_TRACE_FN(name, reg, unreg)
 
+#undef TRACE_EVENT_NOP
+#define TRACE_EVENT_NOP(name, proto, args, struct, assign, print)
+
+#undef DEFINE_EVENT_NOP
+#define DEFINE_EVENT_NOP(template, name, proto, args)
+
 #undef DEFINE_EVENT
 #define DEFINE_EVENT(template, name, proto, args) \
        DEFINE_TRACE(name)
 #undef TRACE_EVENT_FN
 #undef TRACE_EVENT_FN_COND
 #undef TRACE_EVENT_CONDITION
+#undef TRACE_EVENT_NOP
+#undef DEFINE_EVENT_NOP
 #undef DECLARE_EVENT_CLASS
 #undef DEFINE_EVENT
 #undef DEFINE_EVENT_FN