tracing: Fixes for 6.1
Subsystems (2)
Steven Rostedt
maintainerLinus,
tracing fixes for 6.1:
- Fix osnoise duration type to 64bit not 32bit.
- Have histogram triggers be able to handle an unexpected NULL pointer for the record event, that can happen when the histogram first starts up.
- Clear out ring buffers when dynamic events are removed, as the type that is saved in the ring buffer is used to read the event, and a stale type that is reused by another event could cause use after free issues.
- Trivial comment fix.
- Fix memory leak in user_event_create().
Please pull the latest trace-v6.1-rc6 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace-v6.1-rc6
Tag SHA1: ace7e8ba9a89438bc7438ef42453fa8abf6fdb94 Head SHA1: 4313e5a613049dfc1819a6dfb5f94cf2caff9452
Colin Ian King (1):
tracing/hist: add in missing * in comment blocks
Daniel Bristot de Oliveira (1):
tracing/osnoise: Fix duration type
Steven Rostedt (Google) (3):
tracing: Fix race where histograms can be called before the event
tracing: Add tracing_reset_all_online_cpus_unlocked() function
tracing: Free buffers when a used dynamic event is removed
Xiu Jianfeng (1):
tracing/user_events: Fix memory leak in user_event_create()
----
kernel/trace/trace.c | 11 ++++++++++- kernel/trace/trace.h | 1 + kernel/trace/trace_dynevent.c | 2 ++ kernel/trace/trace_events.c | 13 +++++++++++-- kernel/trace/trace_events_hist.c | 7 +++++-- kernel/trace/trace_events_synth.c | 2 -- kernel/trace/trace_events_user.c | 4 +++- kernel/trace/trace_osnoise.c | 6 +++--- 8 files changed, 35 insertions(+), 11 deletions(-)
---------------------------
kernel/trace/trace.c +10 -1
@@ -2180,10 +2180,12 @@ void tracing_reset_online_cpus(struct array_buffer *buf) }/* Must have trace_types_lock held */ -void tracing_reset_all_online_cpus (void ) +void tracing_reset_all_online_cpus_unlocked (void ) {struct trace_array *tr; +lockdep_assert_held (&trace_types_lock); +list_for_each_entry (tr, &ftrace_trace_arrays, list) {if (!tr->clear_trace)continue ;
@@ -2195,6 +2197,13 @@ void tracing_reset_all_online_cpus(void) } } +void tracing_reset_all_online_cpus (void ) +{ +mutex_lock (&trace_types_lock); +tracing_reset_all_online_cpus_unlocked (); +mutex_unlock (&trace_types_lock); +} +/* * The tgid_map array maps from pid to tgid; i.e. the value stored at index i * is the tgid last observed corresponding to pid=i.
kernel/trace/trace.h +1 -0
@@ -580,6 +580,7 @@ int tracing_is_enabled(void);void tracing_reset_online_cpus (struct array_buffer *buf);void tracing_reset_current (int cpu);void tracing_reset_all_online_cpus (void ); +void tracing_reset_all_online_cpus_unlocked (void );int tracing_open_generic (struct inode *inode,struct file *filp);int tracing_open_generic_tr (struct inode *inode,struct file *filp);bool tracing_is_disabled (void );
kernel/trace/trace_dynevent.c +2 -0
@@ -118,6 +118,7 @@ int dyn_event_release(const char *raw_command, struct dyn_event_operations *typeif (ret)break ; } +tracing_reset_all_online_cpus ();mutex_unlock (&event_mutex); out:argv_free (argv);
@@ -214,6 +215,7 @@ int dyn_events_release_all(struct dyn_event_operations *type)break ; } out: +tracing_reset_all_online_cpus ();mutex_unlock (&event_mutex);return ret;
kernel/trace/trace_events.c +11 -2
@@ -2880,7 +2880,10 @@ static int probe_remove_event_call(struct trace_event_call *call)* TRACE_REG_UNREGISTER. */ if (file->flags &EVENT_FILE_FL_ENABLED ) -return -EBUSY ; + goto busy; + +if (file->flags &EVENT_FILE_FL_WAS_ENABLED ) + tr->clear_trace = true;/* * The do_for_each_event_file_safe() is * a double loop. After finding the call for this
@@ -2893,6 +2896,12 @@ static int probe_remove_event_call(struct trace_event_call *call)__trace_remove_event_call (call);return 0 ; + busy: +/* No need to clear the trace now */ +list_for_each_entry (tr, &ftrace_trace_arrays, list) { + tr->clear_trace = false; + } +return -EBUSY ; }/* Remove an event_call */
@@ -2972,7 +2981,7 @@ static void trace_module_remove_events(struct module *mod)* over from this module may be passed to the new module events and * unexpected results may occur. */ -tracing_reset_all_online_cpus (); +tracing_reset_all_online_cpus_unlocked (); } static int trace_module_notify(struct notifier_block *self,
kernel/trace/trace_events_hist.c +5 -2
@@ -983,7 +983,7 @@ static struct hist_field *find_any_var_ref(struct hist_trigger_data *hist_data,* A trigger can define one or more variables. If any one of them is * currently referenced by any other trigger, this function will * determine that. - +* * Typically used to determine whether or not a trigger can be removed * - if there are any references to a trigger's variables, it cannot. *
@@ -3226,7 +3226,7 @@ static struct field_var *create_field_var(struct hist_trigger_data *hist_data,* events. However, for convenience, users are allowed to directly * specify an event field in an action, which will be automatically * converted into a variable on their behalf. - +* * This function creates a field variable with the name var_name on * the hist trigger currently being defined on the target event. If * subsys_name and event_name are specified, this function simply
@@ -5143,6 +5143,9 @@ static void event_hist_trigger(struct event_trigger_data *data,void *key =NULL ;unsigned int i; +if (unlikely (!rbe)) +return ; +memset (compound_key,0 , hist_data->key_size);for_each_hist_key_field (i, hist_data) {
kernel/trace/trace_events_synth.c +0 -2
@@ -1425,7 +1425,6 @@ int synth_event_delete(const char *event_name)mutex_unlock (&event_mutex);if (mod) { -mutex_lock (&trace_types_lock);/* * It is safest to reset the ring buffer if the module * being unloaded registered any events that were
@@ -1437,7 +1436,6 @@ int synth_event_delete(const char *event_name)* occur. */ tracing_reset_all_online_cpus (); -mutex_unlock (&trace_types_lock); }return ret;
kernel/trace/trace_events_user.c +3 -1
@@ -1100,8 +1100,10 @@ static int user_event_create(const char *raw_command) group =current_user_event_group (); -if (!group) +if (!group) { +kfree (name);return -ENOENT ; + }mutex_lock (&group->reg_mutex);
kernel/trace/trace_osnoise.c +3 -3
@@ -917,7 +917,7 @@ void osnoise_trace_irq_entry(int id)void osnoise_trace_irq_exit (int id,const char *desc) {struct osnoise_variables *osn_var =this_cpu_osn_var (); -int duration; +s64 duration;if (!osn_var->sampling)return ;
@@ -1048,7 +1048,7 @@ static void trace_softirq_entry_callback(void *data, unsigned int vec_nr)static void trace_softirq_exit_callback (void *data,unsigned int vec_nr) {struct osnoise_variables *osn_var =this_cpu_osn_var (); -int duration; +s64 duration;if (!osn_var->sampling)return ;
@@ -1144,7 +1144,7 @@ thread_entry(struct osnoise_variables *osn_var, struct task_struct *t)static void thread_exit (struct osnoise_variables *osn_var,struct task_struct *t) { -int duration; +s64 duration;if (!osn_var->sampling)return ;
The pull request you sent on Mon, 28 Nov 2022 14:51:50 -0500:
The pull request you sent on Mon, 28 Nov 2022 14:51:50 -0500:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.gittrace-v6.1-rc6
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/cb525a6513fad6e28f063f56db0a17e264bc8811
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html