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()

+13 -1
kernel/trace/ring_buffer.c
··· 536 536 unsigned flags; 537 537 int cpus; 538 538 atomic_t record_disabled; 539 + atomic_t resizing; 539 540 cpumask_var_t cpumask; 540 541 541 542 struct lock_class_key *reader_lock_key; ··· 2168 2167 2169 2168 /* prevent another thread from changing buffer sizes */ 2170 2169 mutex_lock(&buffer->mutex); 2171 - 2170 + atomic_inc(&buffer->resizing); 2172 2171 2173 2172 if (cpu_id == RING_BUFFER_ALL_CPUS) { 2174 2173 /* ··· 2323 2322 atomic_dec(&buffer->record_disabled); 2324 2323 } 2325 2324 2325 + atomic_dec(&buffer->resizing); 2326 2326 mutex_unlock(&buffer->mutex); 2327 2327 return 0; 2328 2328 ··· 2344 2342 } 2345 2343 } 2346 2344 out_err_unlock: 2345 + atomic_dec(&buffer->resizing); 2347 2346 mutex_unlock(&buffer->mutex); 2348 2347 return err; 2349 2348 } ··· 5542 5539 if (local_read(&cpu_buffer_a->committing)) 5543 5540 goto out_dec; 5544 5541 if (local_read(&cpu_buffer_b->committing)) 5542 + goto out_dec; 5543 + 5544 + /* 5545 + * When resize is in progress, we cannot swap it because 5546 + * it will mess the state of the cpu buffer. 5547 + */ 5548 + if (atomic_read(&buffer_a->resizing)) 5549 + goto out_dec; 5550 + if (atomic_read(&buffer_b->resizing)) 5545 5551 goto out_dec; 5546 5552 5547 5553 buffer_a->buffers[cpu] = cpu_buffer_b;
+2 -1
kernel/trace/trace.c
··· 1928 1928 * place on this CPU. We fail to record, but we reset 1929 1929 * the max trace buffer (no one writes directly to it) 1930 1930 * and flag that it failed. 1931 + * Another reason is resize is in progress. 1931 1932 */ 1932 1933 trace_array_printk_buf(tr->max_buffer.buffer, _THIS_IP_, 1933 - "Failed to swap buffers due to commit in progress\n"); 1934 + "Failed to swap buffers due to commit or resize in progress\n"); 1934 1935 } 1935 1936 1936 1937 WARN_ON_ONCE(ret && ret != -EAGAIN && ret != -EBUSY);
+2 -1
kernel/trace/trace_events_hist.c
··· 6668 6668 goto out_unreg; 6669 6669 6670 6670 if (has_hist_vars(hist_data) || hist_data->n_var_refs) { 6671 - if (save_hist_vars(hist_data)) 6671 + ret = save_hist_vars(hist_data); 6672 + if (ret) 6672 6673 goto out_unreg; 6673 6674 } 6674 6675
-4
kernel/trace/tracing_map.h
··· 272 272 extern u64 tracing_map_read_var(struct tracing_map_elt *elt, unsigned int i); 273 273 extern u64 tracing_map_read_var_once(struct tracing_map_elt *elt, unsigned int i); 274 274 275 - extern void tracing_map_set_field_descr(struct tracing_map *map, 276 - unsigned int i, 277 - unsigned int key_offset, 278 - tracing_map_cmp_fn_t cmp_fn); 279 275 extern int 280 276 tracing_map_sort_entries(struct tracing_map *map, 281 277 struct tracing_map_sort_key *sort_keys,