Skip to content

Commit f5abaa1

Browse files
rostedtH. Peter Anvin
authored andcommitted
tracing: Add DEFINE_EVENT_FN() macro
Each TRACE_EVENT() adds several helper functions. If two or more trace events share the same structure and print format, they can also share most of these helper functions and save a lot of space from duplicate code. This is why the DECLARE_EVENT_CLASS() and DEFINE_EVENT() were created. Some events require a trigger to be called at registering and unregistering of the event and to do so they use TRACE_EVENT_FN(). If multiple events require a trigger, they currently have no choice but to use TRACE_EVENT_FN() as there's no DEFINE_EVENT_FN() available. This unfortunately causes a lot of wasted duplicate code created. By adding a DEFINE_EVENT_FN(), these events can still use a DECLARE_EVENT_CLASS() and then define their own triggers. Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Link: http://lkml.kernel.org/r/51C3236C.8030508@hds.com Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
1 parent 7d13205 commit f5abaa1

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎include/linux/tracepoint.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ static inline void tracepoint_synchronize_unregister(void)
378378
#define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print)
379379
#define DEFINE_EVENT(template, name, proto, args) \
380380
DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
381+
#define DEFINE_EVENT_FN(template, name, proto, args, reg, unreg)\
382+
DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
381383
#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
382384
DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
383385
#define DEFINE_EVENT_CONDITION(template, name, proto, \

‎include/trace/define_trace.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
#define DEFINE_EVENT(template, name, proto, args) \
4545
DEFINE_TRACE(name)
4646

47+
#undef DEFINE_EVENT_FN
48+
#define DEFINE_EVENT_FN(template, name, proto, args, reg, unreg) \
49+
DEFINE_TRACE_FN(name, reg, unreg)
50+
4751
#undef DEFINE_EVENT_PRINT
4852
#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
4953
DEFINE_TRACE(name)
@@ -91,6 +95,7 @@
9195
#undef TRACE_EVENT_CONDITION
9296
#undef DECLARE_EVENT_CLASS
9397
#undef DEFINE_EVENT
98+
#undef DEFINE_EVENT_FN
9499
#undef DEFINE_EVENT_PRINT
95100
#undef DEFINE_EVENT_CONDITION
96101
#undef TRACE_HEADER_MULTI_READ

‎include/trace/ftrace.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
static struct ftrace_event_call __used \
7272
__attribute__((__aligned__(4))) event_##name
7373

74+
#undef DEFINE_EVENT_FN
75+
#define DEFINE_EVENT_FN(template, name, proto, args, reg, unreg) \
76+
DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
77+
7478
#undef DEFINE_EVENT_PRINT
7579
#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
7680
DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))

0 commit comments

Comments
 (0)