tracing: Various cleanups
Steven Rostedt
maintainercover tracing: Various cleanups
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next
Head SHA1: 904d1857ad09b43f514897dd42daffe200d1ca50
Steven Rostedt (Red Hat) (8):
tracing: Move event_trigger_unlock_commit{_regs}() to local header
tracing: Make filter_check_discard() local
tracing: Fold filter_check_discard() into its only user
tracing: Move trace_buffer_unlock_commit{_regs}() to local header
tracing: Remove unused function trace_current_buffer_discard_commit()
tracing: Have trace_buffer_unlock_commit() call the _regs version with NULL
tracing: Remove one use of trace_current_buffer_lock_reserve()
tracing: Remove unused function trace_current_buffer_lock_reserve()
----
include/linux/trace_events.h | 115 ------------------------------------------- kernel/trace/trace.c | 46 ----------------- kernel/trace/trace.h | 114 ++++++++++++++++++++++++++++++++++++++++++ kernel/trace/trace_events.c | 18 ++++--- 4 files changed, 124 insertions(+), 169 deletions(-)
Steven Rostedt
maintainerPATCH 1/8 tracing: Move event_trigger_unlock_commit{_regs}() to local header
From: "Steven Rostedt (Red Hat)" <[email protected]>
The functions event_trigger_unlock_commit() and event_trigger_unlock_commit_regs() are no longer used outside the tracing system. Move them out of the generic headers and into the local one.
Along with __event_trigger_test_discard() that is only used by them.
--- include/linux/trace_events.h | 94 -------------------------------------------- kernel/trace/trace.h | 94 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 94 deletions(-)
include/linux/trace_events.h +0 -94
@@ -452,100 +452,6 @@ trace_trigger_soft_disabled(struct trace_event_file *file)return false; } -/* -* Helper function for event_trigger_unlock_commit{_regs}(). -* If there are event triggers attached to this event that requires -* filtering against its fields, then they wil be called as the -* entry already holds the field information of the current event. -* -* It also checks if the event should be discarded or not. -* It is to be discarded if the event is soft disabled and the -* event was only recorded to process triggers, or if the event -* filter is active and this event did not match the filters. -* -* Returns true if the event is discarded, false otherwise. -*/ -static inline bool -__event_trigger_test_discard (struct trace_event_file *file, -struct ring_buffer *buffer, -struct ring_buffer_event *event, -void *entry, -enum event_trigger_type *tt) -{ -unsigned long eflags = file->flags; - -if (eflags &EVENT_FILE_FL_TRIGGER_COND ) - *tt =event_triggers_call (file, entry); - -if (test_bit (EVENT_FILE_FL_SOFT_DISABLED_BIT , &file->flags)) -ring_buffer_discard_commit (buffer, event); -else if (!filter_check_discard (file, entry, buffer, event)) -return false; - -return true; -} - -/** -* event_trigger_unlock_commit - handle triggers and finish event commit -* @file: The file pointer assoctiated to the event -* @buffer: The ring buffer that the event is being written to -* @event: The event meta data in the ring buffer -* @entry: The event itself -* @irq_flags: The state of the interrupts at the start of the event -* @pc: The state of the preempt count at the start of the event. -* -* This is a helper function to handle triggers that require data -* from the event itself. It also tests the event against filters and -* if the event is soft disabled and should be discarded. -*/ -static inline void -event_trigger_unlock_commit (struct trace_event_file *file, -struct ring_buffer *buffer, -struct ring_buffer_event *event, -void *entry,unsigned long irq_flags,int pc) -{ -enum event_trigger_type tt =ETT_NONE ; - -if (!__event_trigger_test_discard (file, buffer, event, entry, &tt)) -trace_buffer_unlock_commit (file->tr, buffer, event, irq_flags, pc); - -if (tt) -event_triggers_post_call (file, tt, entry); -} - -/** -* event_trigger_unlock_commit_regs - handle triggers and finish event commit -* @file: The file pointer assoctiated to the event -* @buffer: The ring buffer that the event is being written to -* @event: The event meta data in the ring buffer -* @entry: The event itself -* @irq_flags: The state of the interrupts at the start of the event -* @pc: The state of the preempt count at the start of the event. -* -* This is a helper function to handle triggers that require data -* from the event itself. It also tests the event against filters and -* if the event is soft disabled and should be discarded. -* -* Same as event_trigger_unlock_commit() but calls -* trace_buffer_unlock_commit_regs() instead of trace_buffer_unlock_commit(). -*/ -static inline void -event_trigger_unlock_commit_regs (struct trace_event_file *file, -struct ring_buffer *buffer, -struct ring_buffer_event *event, -void *entry,unsigned long irq_flags,int pc, -struct pt_regs *regs) -{ -enum event_trigger_type tt =ETT_NONE ; - -if (!__event_trigger_test_discard (file, buffer, event, entry, &tt)) -trace_buffer_unlock_commit_regs (file->tr, buffer, event, - irq_flags, pc, regs); - -if (tt) -event_triggers_post_call (file, tt, entry); -} -#ifdef CONFIG_BPF_EVENTS unsigned int trace_call_bpf (struct bpf_prog *prog,void *ctx);#else
kernel/trace/trace.h +94 -0
100 lines not on this page · raw message
Signature · 1 line
2.8.0.rc3
Steven Rostedt
maintainerPATCH 2/8 tracing: Make filter_check_discard() local
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
Nothing outside of the tracing directory calls filter_check_discard() or check_filter_check_discard(). They should not be called by modules. Move their prototypes into the local tracing header and remove their EXPORT_SYMBOL() macros.
--- include/linux/trace_events.h | 6 ------ kernel/trace/trace.c | 2 -- kernel/trace/trace.h | 6 ++++++ 3 files changed, 6 insertions(+), 8 deletions(-)
include/linux/trace_events.h +0 -6
@@ -413,12 +413,6 @@ enum event_trigger_type {extern int filter_match_preds (struct event_filter *filter,void *rec); -extern int filter_check_discard (struct trace_event_file *file,void *rec, -struct ring_buffer *buffer, -struct ring_buffer_event *event); -extern int call_filter_check_discard (struct trace_event_call *call,void *rec, -struct ring_buffer *buffer, -struct ring_buffer_event *event);extern enum event_trigger_type event_triggers_call (struct trace_event_file *file,void *rec); extern void event_triggers_post_call(struct trace_event_file *file,
kernel/trace/trace.c +0 -2
@@ -318,7 +318,6 @@ int filter_check_discard(struct trace_event_file *file, void *rec,return 0 ; } -EXPORT_SYMBOL_GPL (filter_check_discard); int call_filter_check_discard(struct trace_event_call *call, void *rec, struct ring_buffer *buffer,
@@ -332,7 +331,6 @@ int call_filter_check_discard(struct trace_event_call *call, void *rec,return 0 ; } -EXPORT_SYMBOL_GPL (call_filter_check_discard);static cycle_t buffer_ftrace_now (struct trace_buffer *buf,int cpu) {
kernel/trace/trace.h +6 -0
@@ -1065,6 +1065,12 @@ struct trace_subsystem_dir {int nr_events; }; +extern int filter_check_discard (struct trace_event_file *file,void *rec, +struct ring_buffer *buffer, +struct ring_buffer_event *event); +extern int call_filter_check_discard (struct trace_event_call *call,void *rec, +struct ring_buffer *buffer, +struct ring_buffer_event *event);/* * Helper function for event_trigger_unlock_commit{_regs}(). * If there are event triggers attached to this event that requires
Signature · 1 line
2.8.0.rc3
Steven Rostedt
maintainerPATCH 3/8 tracing: Fold filter_check_discard() into its only user
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
The function filter_check_discard() is small and only called by one user, its code can be folded into that one caller and make the code a bit less comlplex.
--- kernel/trace/trace.c | 13 ------------- kernel/trace/trace.h | 13 ++++++------- 2 files changed, 6 insertions(+), 20 deletions(-)
kernel/trace/trace.c +0 -13
@@ -306,19 +306,6 @@ void trace_array_put(struct trace_array *this_tr)mutex_unlock (&trace_types_lock); } -int filter_check_discard (struct trace_event_file *file,void *rec, -struct ring_buffer *buffer, -struct ring_buffer_event *event) -{ -if (unlikely (file->flags &EVENT_FILE_FL_FILTERED ) && - !filter_match_preds (file->filter, rec)) { -ring_buffer_discard_commit (buffer, event); -return 1 ; - } - -return 0 ; -} -int call_filter_check_discard (struct trace_event_call *call,void *rec,struct ring_buffer *buffer,struct ring_buffer_event *event)
kernel/trace/trace.h +6 -7
@@ -1065,9 +1065,6 @@ struct trace_subsystem_dir {int nr_events; }; -extern int filter_check_discard (struct trace_event_file *file,void *rec, -struct ring_buffer *buffer, -struct ring_buffer_event *event);extern int call_filter_check_discard (struct trace_event_call *call,void *rec,struct ring_buffer *buffer,struct ring_buffer_event *event);
@@ -1096,12 +1093,14 @@ __event_trigger_test_discard(struct trace_event_file *file,if (eflags &EVENT_FILE_FL_TRIGGER_COND ) *tt =event_triggers_call (file, entry); -if (test_bit (EVENT_FILE_FL_SOFT_DISABLED_BIT , &file->flags)) +if (test_bit (EVENT_FILE_FL_SOFT_DISABLED_BIT , &file->flags) || + (unlikely (file->flags &EVENT_FILE_FL_FILTERED ) && + !filter_match_preds (file->filter, entry))) {ring_buffer_discard_commit (buffer, event); -else if (!filter_check_discard (file, entry, buffer, event)) -return false; +return true; + } -return true; +return false; }/**
Signature · 1 line
2.8.0.rc3
Steven Rostedt
maintainerPATCH 4/8 tracing: Move trace_buffer_unlock_commit{_regs}() to local header
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
The functions trace_buffer_unlock_commit() and the _regs() version are only used within the kernel/trace directory. Move them to the local header and remove the export as well.
--- include/linux/trace_events.h | 9 --------- kernel/trace/trace.c | 2 -- kernel/trace/trace.h | 10 ++++++++++ 3 files changed, 10 insertions(+), 11 deletions(-)
include/linux/trace_events.h +0 -9
@@ -158,15 +158,6 @@ struct ring_buffer_event * trace_current_buffer_lock_reserve(struct ring_buffer **current_buffer, int type, unsigned long len, unsigned long flags, int pc); -void trace_buffer_unlock_commit (struct trace_array *tr, -struct ring_buffer *buffer, -struct ring_buffer_event *event, -unsigned long flags,int pc); -void trace_buffer_unlock_commit_regs (struct trace_array *tr, -struct ring_buffer *buffer, -struct ring_buffer_event *event, -unsigned long flags,int pc, -struct pt_regs *regs);void trace_current_buffer_discard_commit (struct ring_buffer *buffer,struct ring_buffer_event *event);
kernel/trace/trace.c +0 -2
@@ -1696,7 +1696,6 @@ void trace_buffer_unlock_commit(struct trace_array *tr,ftrace_trace_stack (tr, buffer, flags,6 , pc,NULL );ftrace_trace_userstack (buffer, flags, pc); } -EXPORT_SYMBOL_GPL (trace_buffer_unlock_commit);static struct ring_buffer *temp_buffer;
@@ -1748,7 +1747,6 @@ void trace_buffer_unlock_commit_regs(struct trace_array *tr,ftrace_trace_stack (tr, buffer, flags,0 , pc, regs);ftrace_trace_userstack (buffer, flags, pc); } -EXPORT_SYMBOL_GPL (trace_buffer_unlock_commit_regs);void trace_current_buffer_discard_commit (struct ring_buffer *buffer,struct ring_buffer_event *event)
kernel/trace/trace.h +10 -0
@@ -1068,6 +1068,16 @@ struct trace_subsystem_dir {extern int call_filter_check_discard (struct trace_event_call *call,void *rec,struct ring_buffer *buffer,struct ring_buffer_event *event); + +void trace_buffer_unlock_commit (struct trace_array *tr, +struct ring_buffer *buffer, +struct ring_buffer_event *event, +unsigned long flags,int pc); +void trace_buffer_unlock_commit_regs (struct trace_array *tr, +struct ring_buffer *buffer, +struct ring_buffer_event *event, +unsigned long flags,int pc, +struct pt_regs *regs);/* * Helper function for event_trigger_unlock_commit{_regs}(). * If there are event triggers attached to this event that requires
Signature · 1 line
2.8.0.rc3
Steven Rostedt
maintainerPATCH 5/8 tracing: Remove unused function trace_current_buffer_discard_commit()
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
The function trace_current_buffer_discard_commit() has no callers, remove it.
--- include/linux/trace_events.h | 2 -- kernel/trace/trace.c | 8 -------- 2 files changed, 10 deletions(-)
include/linux/trace_events.h +0 -2
@@ -158,8 +158,6 @@ struct ring_buffer_event * trace_current_buffer_lock_reserve(struct ring_buffer **current_buffer, int type, unsigned long len, unsigned long flags, int pc); -void trace_current_buffer_discard_commit (struct ring_buffer *buffer, -struct ring_buffer_event *event);void tracing_record_cmdline (struct task_struct *tsk);
kernel/trace/trace.c +0 -8
@@ -1734,7 +1734,6 @@ trace_current_buffer_lock_reserve(struct ring_buffer **current_rb,return trace_buffer_lock_reserve (*current_rb, type, len, flags, pc); } -EXPORT_SYMBOL_GPL (trace_current_buffer_lock_reserve); void trace_buffer_unlock_commit_regs(struct trace_array *tr, struct ring_buffer *buffer,
@@ -1748,13 +1747,6 @@ void trace_buffer_unlock_commit_regs(struct trace_array *tr,ftrace_trace_userstack (buffer, flags, pc); } -void trace_current_buffer_discard_commit (struct ring_buffer *buffer, -struct ring_buffer_event *event) -{ -ring_buffer_discard_commit (buffer, event); -} -EXPORT_SYMBOL_GPL (trace_current_buffer_discard_commit); - void trace_function(struct trace_array *tr, unsigned long ip, unsigned long parent_ip, unsigned long flags,
Signature · 1 line
2.8.0.rc3
Steven Rostedt
maintainerPATCH 6/8 tracing: Have trace_buffer_unlock_commit() call the _regs version with NULL
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
There's no real difference between trace_buffer_unlock_commit() and trace_buffer_unlock_commit_regs() except that the former passes NULL to ftrace_stack_trace() instead of regs. Have the former be a static inline of the latter which passes NULL for regs.
--- kernel/trace/trace.c | 11 ----------- kernel/trace/trace.h | 13 +++++++++---- 2 files changed, 9 insertions(+), 15 deletions(-)
kernel/trace/trace.c +0 -11
@@ -1686,17 +1686,6 @@ __buffer_unlock_commit(struct ring_buffer *buffer, struct ring_buffer_event *evering_buffer_unlock_commit (buffer, event); } -void trace_buffer_unlock_commit (struct trace_array *tr, -struct ring_buffer *buffer, -struct ring_buffer_event *event, -unsigned long flags,int pc) -{ -__buffer_unlock_commit (buffer, event); - -ftrace_trace_stack (tr, buffer, flags,6 , pc,NULL ); -ftrace_trace_userstack (buffer, flags, pc); -} -static struct ring_buffer *temp_buffer; struct ring_buffer_event *
kernel/trace/trace.h +9 -4
@@ -1069,15 +1069,20 @@ extern int call_filter_check_discard(struct trace_event_call *call, void *rec,struct ring_buffer *buffer, struct ring_buffer_event *event); -void trace_buffer_unlock_commit (struct trace_array *tr, -struct ring_buffer *buffer, -struct ring_buffer_event *event, -unsigned long flags,int pc);void trace_buffer_unlock_commit_regs (struct trace_array *tr,struct ring_buffer *buffer,struct ring_buffer_event *event,unsigned long flags,int pc,struct pt_regs *regs); + +static inline void trace_buffer_unlock_commit (struct trace_array *tr, +struct ring_buffer *buffer, +struct ring_buffer_event *event, +unsigned long flags,int pc) +{ +trace_buffer_unlock_commit_regs (tr, buffer, event, flags, pc,NULL ); +} +/* * Helper function for event_trigger_unlock_commit{_regs}(). * If there are event triggers attached to this event that requires
Signature · 1 line
2.8.0.rc3
Steven Rostedt
maintainerPATCH 7/8 tracing: Remove one use of trace_current_buffer_lock_reserve()
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
The only user of trace_current_buffer_lock_reserve() is in the boot up self tests. Restructure the code a little to have that code use what everything else uses: trace_event_buffer_lock_reserve().
--- kernel/trace/trace_events.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
kernel/trace/trace_events.c +10 -8
@@ -3392,7 +3392,7 @@ static __init void event_trace_self_tests(void) static DEFINE_PER_CPU(atomic_t, ftrace_test_event_disable); -static struct trace_array *event_tr; +static struct trace_event_file event_trace_file__initdata ; static void __init function_test_events_call(unsigned long ip, unsigned long parent_ip,
@@ -3416,17 +3416,17 @@ function_test_events_call(unsigned long ip, unsigned long parent_ip,local_save_flags (flags); - event =trace_current_buffer_lock_reserve (&buffer, -TRACE_FN ,sizeof (*entry), - flags, pc); + event =trace_event_buffer_lock_reserve (&buffer, &event_trace_file, +TRACE_FN ,sizeof (*entry), + flags, pc);if (!event) goto out; entry =ring_buffer_event_data (event); entry->ip = ip; entry->parent_ip = parent_ip; -trace_buffer_unlock_commit (event_tr, buffer, event, flags, pc); - +event_trigger_unlock_commit (&event_trace_file, buffer, event, + entry, flags, pc); out:atomic_dec (&per_cpu (ftrace_test_event_disable, cpu));preempt_enable_notrace ();
@@ -3441,9 +3441,11 @@ static struct ftrace_ops trace_ops __initdata =static __init void event_trace_self_test_with_function (void ) {int ret; - event_tr =top_trace_array (); -if (WARN_ON (!event_tr)) + + event_trace_file.tr =top_trace_array (); +if (WARN_ON (!event_trace_file.tr))return ; + ret =register_ftrace_function (&trace_ops);if (WARN_ON (ret <0 )) {pr_info ("Failed to enable function tracer for event tests\n" );
Signature · 1 line
2.8.0.rc3
Steven Rostedt
maintainerPATCH 8/8 tracing: Remove unused function trace_current_buffer_lock_reserve()
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
trace_current_buffer_lock_reserve() has no more users. Remove it.
--- include/linux/trace_events.h | 4 ---- kernel/trace/trace.c | 10 ---------- 2 files changed, 14 deletions(-)
include/linux/trace_events.h +0 -4
@@ -154,10 +154,6 @@ trace_event_buffer_lock_reserve(struct ring_buffer **current_buffer,struct trace_event_file *trace_file, int type, unsigned long len, unsigned long flags, int pc); -struct ring_buffer_event * -trace_current_buffer_lock_reserve (struct ring_buffer **current_buffer, -int type,unsigned long len, -unsigned long flags,int pc);void tracing_record_cmdline (struct task_struct *tsk);
kernel/trace/trace.c +0 -10
@@ -1714,16 +1714,6 @@ trace_event_buffer_lock_reserve(struct ring_buffer **current_rb, }EXPORT_SYMBOL_GPL (trace_event_buffer_lock_reserve); -struct ring_buffer_event * -trace_current_buffer_lock_reserve (struct ring_buffer **current_rb, -int type,unsigned long len, -unsigned long flags,int pc) -{ - *current_rb = global_trace.trace_buffer.buffer; -return trace_buffer_lock_reserve (*current_rb, - type, len, flags, pc); -} - void trace_buffer_unlock_commit_regs(struct trace_array *tr, struct ring_buffer *buffer, struct ring_buffer_event *event,
Signature · 1 line
2.8.0.rc3