Commit 3b4e48b8 authored by Linus Torvalds's avatar Linus Torvalds

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

Pull tracing fixes from Steven Rostedt:

 - Swapping the ring buffer for snapshotting (for things like irqsoff)
   can crash if the ring buffer is being resized. Disable swapping when
   this happens. The missed swap will be reported to the tracer

 - Report error if the histogram fails to be created due to an error in
   adding a histogram variable, in event_hist_trigger_parse()

 - Remove unused declaration of tracing_map_set_field_descr()

* tag 'trace-v6.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  tracing/histograms: Return an error if we fail to add histogram to hist_vars list
  ring-buffer: Do not swap cpu_buffer during resize process
  tracing: Remove unused extern declaration tracing_map_set_field_descr()
parents 12a5336c 4b8b3905
...@@ -536,6 +536,7 @@ struct trace_buffer { ...@@ -536,6 +536,7 @@ struct trace_buffer {
unsigned flags; unsigned flags;
int cpus; int cpus;
atomic_t record_disabled; atomic_t record_disabled;
atomic_t resizing;
cpumask_var_t cpumask; cpumask_var_t cpumask;
struct lock_class_key *reader_lock_key; struct lock_class_key *reader_lock_key;
...@@ -2167,7 +2168,7 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size, ...@@ -2167,7 +2168,7 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
/* prevent another thread from changing buffer sizes */ /* prevent another thread from changing buffer sizes */
mutex_lock(&buffer->mutex); mutex_lock(&buffer->mutex);
atomic_inc(&buffer->resizing);
if (cpu_id == RING_BUFFER_ALL_CPUS) { if (cpu_id == RING_BUFFER_ALL_CPUS) {
/* /*
...@@ -2322,6 +2323,7 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size, ...@@ -2322,6 +2323,7 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
atomic_dec(&buffer->record_disabled); atomic_dec(&buffer->record_disabled);
} }
atomic_dec(&buffer->resizing);
mutex_unlock(&buffer->mutex); mutex_unlock(&buffer->mutex);
return 0; return 0;
...@@ -2342,6 +2344,7 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size, ...@@ -2342,6 +2344,7 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
} }
} }
out_err_unlock: out_err_unlock:
atomic_dec(&buffer->resizing);
mutex_unlock(&buffer->mutex); mutex_unlock(&buffer->mutex);
return err; return err;
} }
...@@ -5541,6 +5544,15 @@ int ring_buffer_swap_cpu(struct trace_buffer *buffer_a, ...@@ -5541,6 +5544,15 @@ int ring_buffer_swap_cpu(struct trace_buffer *buffer_a,
if (local_read(&cpu_buffer_b->committing)) if (local_read(&cpu_buffer_b->committing))
goto out_dec; goto out_dec;
/*
* When resize is in progress, we cannot swap it because
* it will mess the state of the cpu buffer.
*/
if (atomic_read(&buffer_a->resizing))
goto out_dec;
if (atomic_read(&buffer_b->resizing))
goto out_dec;
buffer_a->buffers[cpu] = cpu_buffer_b; buffer_a->buffers[cpu] = cpu_buffer_b;
buffer_b->buffers[cpu] = cpu_buffer_a; buffer_b->buffers[cpu] = cpu_buffer_a;
......
...@@ -1928,9 +1928,10 @@ update_max_tr_single(struct trace_array *tr, struct task_struct *tsk, int cpu) ...@@ -1928,9 +1928,10 @@ update_max_tr_single(struct trace_array *tr, struct task_struct *tsk, int cpu)
* place on this CPU. We fail to record, but we reset * place on this CPU. We fail to record, but we reset
* the max trace buffer (no one writes directly to it) * the max trace buffer (no one writes directly to it)
* and flag that it failed. * and flag that it failed.
* Another reason is resize is in progress.
*/ */
trace_array_printk_buf(tr->max_buffer.buffer, _THIS_IP_, trace_array_printk_buf(tr->max_buffer.buffer, _THIS_IP_,
"Failed to swap buffers due to commit in progress\n"); "Failed to swap buffers due to commit or resize in progress\n");
} }
WARN_ON_ONCE(ret && ret != -EAGAIN && ret != -EBUSY); WARN_ON_ONCE(ret && ret != -EAGAIN && ret != -EBUSY);
......
...@@ -6668,7 +6668,8 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops, ...@@ -6668,7 +6668,8 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops,
goto out_unreg; goto out_unreg;
if (has_hist_vars(hist_data) || hist_data->n_var_refs) { if (has_hist_vars(hist_data) || hist_data->n_var_refs) {
if (save_hist_vars(hist_data)) ret = save_hist_vars(hist_data);
if (ret)
goto out_unreg; goto out_unreg;
} }
......
...@@ -272,10 +272,6 @@ extern u64 tracing_map_read_sum(struct tracing_map_elt *elt, unsigned int i); ...@@ -272,10 +272,6 @@ extern u64 tracing_map_read_sum(struct tracing_map_elt *elt, unsigned int i);
extern u64 tracing_map_read_var(struct tracing_map_elt *elt, unsigned int i); extern u64 tracing_map_read_var(struct tracing_map_elt *elt, unsigned int i);
extern u64 tracing_map_read_var_once(struct tracing_map_elt *elt, unsigned int i); extern u64 tracing_map_read_var_once(struct tracing_map_elt *elt, unsigned int i);
extern void tracing_map_set_field_descr(struct tracing_map *map,
unsigned int i,
unsigned int key_offset,
tracing_map_cmp_fn_t cmp_fn);
extern int extern int
tracing_map_sort_entries(struct tracing_map *map, tracing_map_sort_entries(struct tracing_map *map,
struct tracing_map_sort_key *sort_keys, struct tracing_map_sort_key *sort_keys,
......
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