Commit cb525a65 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'trace-v6.1-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace

Pull tracing fixes from Steven Rostedt:

 - Fix osnoise duration type to 64bit not 32bit

 - Have histogram triggers be able to handle an unexpected NULL pointer
   for the record event, which 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()

* tag 'trace-v6.1-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  tracing: Free buffers when a used dynamic event is removed
  tracing: Add tracing_reset_all_online_cpus_unlocked() function
  tracing: Fix race where histograms can be called before the event
  tracing/osnoise: Fix duration type
  tracing/user_events: Fix memory leak in user_event_create()
  tracing/hist: add in missing * in comment blocks
parents f35badcc 4313e5a6
...@@ -2180,10 +2180,12 @@ void tracing_reset_online_cpus(struct array_buffer *buf) ...@@ -2180,10 +2180,12 @@ void tracing_reset_online_cpus(struct array_buffer *buf)
} }
/* Must have trace_types_lock held */ /* 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; struct trace_array *tr;
lockdep_assert_held(&trace_types_lock);
list_for_each_entry(tr, &ftrace_trace_arrays, list) { list_for_each_entry(tr, &ftrace_trace_arrays, list) {
if (!tr->clear_trace) if (!tr->clear_trace)
continue; continue;
...@@ -2195,6 +2197,13 @@ void tracing_reset_all_online_cpus(void) ...@@ -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 * 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. * is the tgid last observed corresponding to pid=i.
......
...@@ -580,6 +580,7 @@ int tracing_is_enabled(void); ...@@ -580,6 +580,7 @@ int tracing_is_enabled(void);
void tracing_reset_online_cpus(struct array_buffer *buf); void tracing_reset_online_cpus(struct array_buffer *buf);
void tracing_reset_current(int cpu); void tracing_reset_current(int cpu);
void tracing_reset_all_online_cpus(void); 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(struct inode *inode, struct file *filp);
int tracing_open_generic_tr(struct inode *inode, struct file *filp); int tracing_open_generic_tr(struct inode *inode, struct file *filp);
bool tracing_is_disabled(void); bool tracing_is_disabled(void);
......
...@@ -118,6 +118,7 @@ int dyn_event_release(const char *raw_command, struct dyn_event_operations *type ...@@ -118,6 +118,7 @@ int dyn_event_release(const char *raw_command, struct dyn_event_operations *type
if (ret) if (ret)
break; break;
} }
tracing_reset_all_online_cpus();
mutex_unlock(&event_mutex); mutex_unlock(&event_mutex);
out: out:
argv_free(argv); argv_free(argv);
...@@ -214,6 +215,7 @@ int dyn_events_release_all(struct dyn_event_operations *type) ...@@ -214,6 +215,7 @@ int dyn_events_release_all(struct dyn_event_operations *type)
break; break;
} }
out: out:
tracing_reset_all_online_cpus();
mutex_unlock(&event_mutex); mutex_unlock(&event_mutex);
return ret; return ret;
......
...@@ -2880,7 +2880,10 @@ static int probe_remove_event_call(struct trace_event_call *call) ...@@ -2880,7 +2880,10 @@ static int probe_remove_event_call(struct trace_event_call *call)
* TRACE_REG_UNREGISTER. * TRACE_REG_UNREGISTER.
*/ */
if (file->flags & EVENT_FILE_FL_ENABLED) 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 * The do_for_each_event_file_safe() is
* a double loop. After finding the call for this * a double loop. After finding the call for this
...@@ -2893,6 +2896,12 @@ static int probe_remove_event_call(struct trace_event_call *call) ...@@ -2893,6 +2896,12 @@ static int probe_remove_event_call(struct trace_event_call *call)
__trace_remove_event_call(call); __trace_remove_event_call(call);
return 0; 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 */ /* Remove an event_call */
...@@ -2972,7 +2981,7 @@ static void trace_module_remove_events(struct module *mod) ...@@ -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 * over from this module may be passed to the new module events and
* unexpected results may occur. * unexpected results may occur.
*/ */
tracing_reset_all_online_cpus(); tracing_reset_all_online_cpus_unlocked();
} }
static int trace_module_notify(struct notifier_block *self, static int trace_module_notify(struct notifier_block *self,
......
...@@ -983,7 +983,7 @@ static struct hist_field *find_any_var_ref(struct hist_trigger_data *hist_data, ...@@ -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 * A trigger can define one or more variables. If any one of them is
* currently referenced by any other trigger, this function will * currently referenced by any other trigger, this function will
* determine that. * determine that.
*
* Typically used to determine whether or not a trigger can be removed * Typically used to determine whether or not a trigger can be removed
* - if there are any references to a trigger's variables, it cannot. * - 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, ...@@ -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 * events. However, for convenience, users are allowed to directly
* specify an event field in an action, which will be automatically * specify an event field in an action, which will be automatically
* converted into a variable on their behalf. * converted into a variable on their behalf.
*
* This function creates a field variable with the name var_name on * This function creates a field variable with the name var_name on
* the hist trigger currently being defined on the target event. If * the hist trigger currently being defined on the target event. If
* subsys_name and event_name are specified, this function simply * subsys_name and event_name are specified, this function simply
...@@ -5143,6 +5143,9 @@ static void event_hist_trigger(struct event_trigger_data *data, ...@@ -5143,6 +5143,9 @@ static void event_hist_trigger(struct event_trigger_data *data,
void *key = NULL; void *key = NULL;
unsigned int i; unsigned int i;
if (unlikely(!rbe))
return;
memset(compound_key, 0, hist_data->key_size); memset(compound_key, 0, hist_data->key_size);
for_each_hist_key_field(i, hist_data) { for_each_hist_key_field(i, hist_data) {
......
...@@ -1425,7 +1425,6 @@ int synth_event_delete(const char *event_name) ...@@ -1425,7 +1425,6 @@ int synth_event_delete(const char *event_name)
mutex_unlock(&event_mutex); mutex_unlock(&event_mutex);
if (mod) { if (mod) {
mutex_lock(&trace_types_lock);
/* /*
* It is safest to reset the ring buffer if the module * It is safest to reset the ring buffer if the module
* being unloaded registered any events that were * being unloaded registered any events that were
...@@ -1437,7 +1436,6 @@ int synth_event_delete(const char *event_name) ...@@ -1437,7 +1436,6 @@ int synth_event_delete(const char *event_name)
* occur. * occur.
*/ */
tracing_reset_all_online_cpus(); tracing_reset_all_online_cpus();
mutex_unlock(&trace_types_lock);
} }
return ret; return ret;
......
...@@ -1100,8 +1100,10 @@ static int user_event_create(const char *raw_command) ...@@ -1100,8 +1100,10 @@ static int user_event_create(const char *raw_command)
group = current_user_event_group(); group = current_user_event_group();
if (!group) if (!group) {
kfree(name);
return -ENOENT; return -ENOENT;
}
mutex_lock(&group->reg_mutex); mutex_lock(&group->reg_mutex);
......
...@@ -917,7 +917,7 @@ void osnoise_trace_irq_entry(int id) ...@@ -917,7 +917,7 @@ void osnoise_trace_irq_entry(int id)
void osnoise_trace_irq_exit(int id, const char *desc) void osnoise_trace_irq_exit(int id, const char *desc)
{ {
struct osnoise_variables *osn_var = this_cpu_osn_var(); struct osnoise_variables *osn_var = this_cpu_osn_var();
int duration; s64 duration;
if (!osn_var->sampling) if (!osn_var->sampling)
return; return;
...@@ -1048,7 +1048,7 @@ static void trace_softirq_entry_callback(void *data, unsigned int vec_nr) ...@@ -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) static void trace_softirq_exit_callback(void *data, unsigned int vec_nr)
{ {
struct osnoise_variables *osn_var = this_cpu_osn_var(); struct osnoise_variables *osn_var = this_cpu_osn_var();
int duration; s64 duration;
if (!osn_var->sampling) if (!osn_var->sampling)
return; return;
...@@ -1144,7 +1144,7 @@ thread_entry(struct osnoise_variables *osn_var, struct task_struct *t) ...@@ -1144,7 +1144,7 @@ thread_entry(struct osnoise_variables *osn_var, struct task_struct *t)
static void static void
thread_exit(struct osnoise_variables *osn_var, struct task_struct *t) thread_exit(struct osnoise_variables *osn_var, struct task_struct *t)
{ {
int duration; s64 duration;
if (!osn_var->sampling) if (!osn_var->sampling)
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment