History

ftrace: disable tracing on resize

Impact: fix for bug on resize This patch addresses the bug found here: http://bugzilla.kernel.org/show_bug.cgi?id=11996 When ftrace converted to the new unified trace buffer, the resizing of the buffer was not protected as much as it was originally. If tracing is performed while the resize occurs, then the buffer can be corrupted. This patch disables all ftrace buffer modifications before a resize takes place.

Steven Rostedt committed 18 years ago

Commit bf5e6511 parent 3ad4f591 file · +16 −1Browse files

Unified · Split

kernel/trace/trace.c+16−1
@@ -2676,7 +2676,7 @@ tracing_entries_write(struct file *filp, const char __user *ubuf, · 2675 unmodified lines
26762676 {
26772677 unsigned long val;
26782678 char buf[64];
2679− int ret;
2679+ int ret, cpu;
26802680 struct trace_array *tr = filp->private_data;
26812681
26822682 if (cnt >= sizeof(buf))
@@ -2704,6 +2704,14 @@ tracing_entries_write(struct file *filp, const char __user *ubuf, · 21 unmodified lines
27042704 goto out;
27052705 }
27062706
2707+ /* disable all cpu buffers */
2708+ for_each_tracing_cpu(cpu) {
2709+ if (global_trace.data[cpu])
2710+ atomic_inc(&global_trace.data[cpu]->disabled);
2711+ if (max_tr.data[cpu])
2712+ atomic_inc(&max_tr.data[cpu]->disabled);
2713+ }
2714+
27072715 if (val != global_trace.entries) {
27082716 ret = ring_buffer_resize(global_trace.buffer, val);
27092717 if (ret < 0) {
@@ -2735,6 +2743,13 @@ tracing_entries_write(struct file *filp, const char __user *ubuf, · 25 unmodified lines
27352743 if (tracing_disabled)
27362744 cnt = -ENOMEM;
27372745 out:
2746+ for_each_tracing_cpu(cpu) {
2747+ if (global_trace.data[cpu])
2748+ atomic_dec(&global_trace.data[cpu]->disabled);
2749+ if (max_tr.data[cpu])
2750+ atomic_dec(&max_tr.data[cpu]->disabled);
2751+ }
2752+
27382753 max_tr.entries = global_trace.entries;
27392754 mutex_unlock(&trace_types_lock);
27402755