Skip to content

Commit 3b4e48b

Browse files
committed
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()
2 parents 12a5336 + 4b8b390 commit 3b4e48b

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

kernel/trace/ring_buffer.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ struct trace_buffer {
536536
unsigned flags;
537537
int cpus;
538538
atomic_t record_disabled;
539+
atomic_t resizing;
539540
cpumask_var_t cpumask;
540541

541542
struct lock_class_key *reader_lock_key;
@@ -2167,7 +2168,7 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
21672168

21682169
/* prevent another thread from changing buffer sizes */
21692170
mutex_lock(&buffer->mutex);
2170-
2171+
atomic_inc(&buffer->resizing);
21712172

21722173
if (cpu_id == RING_BUFFER_ALL_CPUS) {
21732174
/*
@@ -2322,6 +2323,7 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
23222323
atomic_dec(&buffer->record_disabled);
23232324
}
23242325

2326+
atomic_dec(&buffer->resizing);
23252327
mutex_unlock(&buffer->mutex);
23262328
return 0;
23272329

@@ -2342,6 +2344,7 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
23422344
}
23432345
}
23442346
out_err_unlock:
2347+
atomic_dec(&buffer->resizing);
23452348
mutex_unlock(&buffer->mutex);
23462349
return err;
23472350
}
@@ -5541,6 +5544,15 @@ int ring_buffer_swap_cpu(struct trace_buffer *buffer_a,
55415544
if (local_read(&cpu_buffer_b->committing))
55425545
goto out_dec;
55435546

5547+
/*
5548+
* When resize is in progress, we cannot swap it because
5549+
* it will mess the state of the cpu buffer.
5550+
*/
5551+
if (atomic_read(&buffer_a->resizing))
5552+
goto out_dec;
5553+
if (atomic_read(&buffer_b->resizing))
5554+
goto out_dec;
5555+
55445556
buffer_a->buffers[cpu] = cpu_buffer_b;
55455557
buffer_b->buffers[cpu] = cpu_buffer_a;
55465558

kernel/trace/trace.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1928,9 +1928,10 @@ update_max_tr_single(struct trace_array *tr, struct task_struct *tsk, int cpu)
19281928
* place on this CPU. We fail to record, but we reset
19291929
* the max trace buffer (no one writes directly to it)
19301930
* and flag that it failed.
1931+
* Another reason is resize is in progress.
19311932
*/
19321933
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");
19341935
}
19351936

19361937
WARN_ON_ONCE(ret && ret != -EAGAIN && ret != -EBUSY);

kernel/trace/trace_events_hist.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6668,7 +6668,8 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops,
66686668
goto out_unreg;
66696669

66706670
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)
66726673
goto out_unreg;
66736674
}
66746675

kernel/trace/tracing_map.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,6 @@ extern u64 tracing_map_read_sum(struct tracing_map_elt *elt, unsigned int i);
272272
extern u64 tracing_map_read_var(struct tracing_map_elt *elt, unsigned int i);
273273
extern u64 tracing_map_read_var_once(struct tracing_map_elt *elt, unsigned int i);
274274

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);
279275
extern int
280276
tracing_map_sort_entries(struct tracing_map *map,
281277
struct tracing_map_sort_key *sort_keys,

0 commit comments

Comments
 (0)