Skip to content

Commit b71645d

Browse files
Zheng Yejianrostedt
authored andcommitted
tracing: Fix cpu buffers unavailable due to 'record_disabled' missed
Trace ring buffer can no longer record anything after executing following commands at the shell prompt: # cd /sys/kernel/tracing # cat tracing_cpumask fff # echo 0 > tracing_cpumask # echo 1 > snapshot # echo fff > tracing_cpumask # echo 1 > tracing_on # echo "hello world" > trace_marker -bash: echo: write error: Bad file descriptor The root cause is that: 1. After `echo 0 > tracing_cpumask`, 'record_disabled' of cpu buffers in 'tr->array_buffer.buffer' became 1 (see tracing_set_cpumask()); 2. After `echo 1 > snapshot`, 'tr->array_buffer.buffer' is swapped with 'tr->max_buffer.buffer', then the 'record_disabled' became 0 (see update_max_tr()); 3. After `echo fff > tracing_cpumask`, the 'record_disabled' become -1; Then array_buffer and max_buffer are both unavailable due to value of 'record_disabled' is not 0. To fix it, enable or disable both array_buffer and max_buffer at the same time in tracing_set_cpumask(). Link: https://lkml.kernel.org/r/[email protected] Cc: <[email protected]> Cc: <[email protected]> Cc: <[email protected]> Fixes: 71babb2 ("tracing: change CPU ring buffer state from tracing_cpumask") Signed-off-by: Zheng Yejian <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 2ccdd1b commit b71645d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

kernel/trace/trace.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5277,11 +5277,17 @@ int tracing_set_cpumask(struct trace_array *tr,
52775277
!cpumask_test_cpu(cpu, tracing_cpumask_new)) {
52785278
atomic_inc(&per_cpu_ptr(tr->array_buffer.data, cpu)->disabled);
52795279
ring_buffer_record_disable_cpu(tr->array_buffer.buffer, cpu);
5280+
#ifdef CONFIG_TRACER_MAX_TRACE
5281+
ring_buffer_record_disable_cpu(tr->max_buffer.buffer, cpu);
5282+
#endif
52805283
}
52815284
if (!cpumask_test_cpu(cpu, tr->tracing_cpumask) &&
52825285
cpumask_test_cpu(cpu, tracing_cpumask_new)) {
52835286
atomic_dec(&per_cpu_ptr(tr->array_buffer.data, cpu)->disabled);
52845287
ring_buffer_record_enable_cpu(tr->array_buffer.buffer, cpu);
5288+
#ifdef CONFIG_TRACER_MAX_TRACE
5289+
ring_buffer_record_enable_cpu(tr->max_buffer.buffer, cpu);
5290+
#endif
52855291
}
52865292
}
52875293
arch_spin_unlock(&tr->max_lock);

0 commit comments

Comments
 (0)