tracing: Consolidate event trigger code
The event trigger code that checks for callback triggers before and
after recording of an event has lots of flags checks. This code is
duplicated throughout the ftrace events, kprobes and system calls.
They all do the exact same checks against the event flags.
Added helper functions ftrace_trigger_soft_disabled(),
event_trigger_unlock_commit() and event_trigger_unlock_commit_regs()
that consolidated the code and these are used instead.
Link: http://lkml.kernel.org/r/20140106222703.5e7dbba2@gandalf.local.home
Acked-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Tested-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 0962968..1a8b28d 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -546,8 +546,6 @@
struct ftrace_event_file *ftrace_file = __data; \
struct ftrace_event_call *event_call = ftrace_file->event_call; \
struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
- unsigned long eflags = ftrace_file->flags; \
- enum event_trigger_type __tt = ETT_NONE; \
struct ring_buffer_event *event; \
struct ftrace_raw_##call *entry; \
struct ring_buffer *buffer; \
@@ -555,12 +553,8 @@
int __data_size; \
int pc; \
\
- if (!(eflags & FTRACE_EVENT_FL_TRIGGER_COND)) { \
- if (eflags & FTRACE_EVENT_FL_TRIGGER_MODE) \
- event_triggers_call(ftrace_file, NULL); \
- if (eflags & FTRACE_EVENT_FL_SOFT_DISABLED) \
- return; \
- } \
+ if (ftrace_trigger_soft_disabled(ftrace_file)) \
+ return; \
\
local_save_flags(irq_flags); \
pc = preempt_count(); \
@@ -579,17 +573,8 @@
\
{ assign; } \
\
- if (eflags & FTRACE_EVENT_FL_TRIGGER_COND) \
- __tt = event_triggers_call(ftrace_file, entry); \
- \
- if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT, \
- &ftrace_file->flags)) \
- ring_buffer_discard_commit(buffer, event); \
- else if (!filter_check_discard(ftrace_file, entry, buffer, event)) \
- trace_buffer_unlock_commit(buffer, event, irq_flags, pc); \
- \
- if (__tt) \
- event_triggers_post_call(ftrace_file, __tt); \
+ event_trigger_unlock_commit(ftrace_file, buffer, event, entry, \
+ irq_flags, pc); \
}
/*
* The ftrace_test_probe is compiled out, it is only here as a build time check