tracing: Drop the synthetic event ref when clearing hist triggers
Subsystems (2)
PATCH 1/1 tracing: Drop the synthetic event ref when clearing hist triggers
clear_event_triggers() frees a hist trigger on a synthetic event without dropping the se->ref taken by event_hist_trigger_parse(). Removing an instance with such a trigger leaves the synthetic event busy forever.
Fixes 4b147936fa50 ("tracing: Add support for 'synthetic' events")
Signed-off-by David Carlier <[email protected]>
---
Applies on trace/for-next, depends on 3403d9bb27eb ("tracing/histograms: Verify event_call identity when updating synth_event refcount").
kernel/trace/trace.h | 2 ++ kernel/trace/trace_events_hist.c | 20 +++++++++++++------- kernel/trace/trace_events_trigger.c | 2 ++ 3 files changed, 17 insertions(+), 7 deletions(-)
kernel/trace/trace.h +2 -0
@@ -1915,9 +1915,11 @@ extern const struct file_operations event_inject_fops;#ifdef CONFIG_HIST_TRIGGERS extern int register_trigger_hist_cmd (void );extern int register_trigger_hist_enable_disable_cmds (void ); +extern void hist_put_synth_event (struct trace_event_file *file);#else static inline int register_trigger_hist_cmd (void ) {return 0 ; }static inline int register_trigger_hist_enable_disable_cmds (void ) {return 0 ; } +static inline void hist_put_synth_event (struct trace_event_file *file) { }#endif extern int register_trigger_cmds (void );
kernel/trace/trace_events_hist.c +13 -7
@@ -6756,6 +6756,17 @@ static bool hist_trigger_check_refs(struct event_trigger_data *data,return false; } +void hist_put_synth_event (struct trace_event_file *file) +{ +struct synth_event *se; + +lockdep_assert_held (&event_mutex); + + se =find_synth_event_call (file->event_call); +if (se) + se->ref--; +} +static void hist_unregister_trigger (char *glob,struct event_trigger_data *data,struct trace_event_file *file)
@@ -6811,7 +6822,6 @@ static void hist_unreg_all(struct trace_event_file *file) {struct event_trigger_data *test, *n;struct hist_trigger_data *hist_data; -struct synth_event *se;lockdep_assert_held (&event_mutex);
@@ -6824,9 +6834,7 @@ static void hist_unreg_all(struct trace_event_file *file)list_del_rcu (&test->list);trace_event_trigger_enable_disable (file,0 ); - se =find_synth_event_call (file->event_call); -if (se) - se->ref--; +hist_put_synth_event (file);update_cond_flag (file);if (hist_data->enable_timestamps)
@@ -6941,9 +6949,7 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops, }event_trigger_unregister (cmd_ops, file, glob+1 , trigger_data); - se =find_synth_event_call (file->event_call); -if (se) - se->ref--; +hist_put_synth_event (file); ret =0 ; goto out_free; }
kernel/trace/trace_events_trigger.c +2 -0
@@ -643,6 +643,8 @@ clear_event_triggers(struct trace_array *tr)list_for_each_entry_safe (data, n, &file->triggers, list) {trace_event_trigger_enable_disable (file,0 );list_del_rcu (&data->list); +if (data->cmd_ops->trigger_type ==ETT_EVENT_HIST ) +hist_put_synth_event (file);if (data->cmd_ops->free) data->cmd_ops->free (data); }
Signature · 1 line
2.55.0