Skip to content

Commit 54a3bfe

Browse files
committed
Merge: Updates for kernel tracing ring buffer
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4108 Description: Updates for kernel tracing ring buffer JIRA: https://issues.redhat.com/browse/RHEL-23763 Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=60719054 Tested: Verified Brew build test kernel RPMs and confirmed issue is resovled Signed-off-by: Mamatha Inamdar <minamdar@redhat.com> commit b71645d Author: Zheng Yejian <zhengyejian1@huawei.com> Date: Sat Aug 5 11:38:15 2023 +0800 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: fff -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/20230805033816.3284594-2-zhengyejian1@huawei.com Cc: <mhiramat@kernel.org> Cc: <vnagarnaik@google.com> Cc: <shuah@kernel.org> Fixes: 71babb2 ("tracing: change CPU ring buffer state from tracing_cpumask") Signed-off-by: Zheng Yejian <zhengyejian1@huawei.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Mamatha Inamdar <minamdar@redhat.com> Approved-by: Steve Best <sbest@redhat.com> Approved-by: Tony Camuso <tcamuso@redhat.com> Merged-by: Lucas Zampieri <lzampier@redhat.com>
2 parents ee43b6f + 2188b9e commit 54a3bfe

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
@@ -5173,11 +5173,17 @@ int tracing_set_cpumask(struct trace_array *tr,
51735173
!cpumask_test_cpu(cpu, tracing_cpumask_new)) {
51745174
atomic_inc(&per_cpu_ptr(tr->array_buffer.data, cpu)->disabled);
51755175
ring_buffer_record_disable_cpu(tr->array_buffer.buffer, cpu);
5176+
#ifdef CONFIG_TRACER_MAX_TRACE
5177+
ring_buffer_record_disable_cpu(tr->max_buffer.buffer, cpu);
5178+
#endif
51765179
}
51775180
if (!cpumask_test_cpu(cpu, tr->tracing_cpumask) &&
51785181
cpumask_test_cpu(cpu, tracing_cpumask_new)) {
51795182
atomic_dec(&per_cpu_ptr(tr->array_buffer.data, cpu)->disabled);
51805183
ring_buffer_record_enable_cpu(tr->array_buffer.buffer, cpu);
5184+
#ifdef CONFIG_TRACER_MAX_TRACE
5185+
ring_buffer_record_enable_cpu(tr->max_buffer.buffer, cpu);
5186+
#endif
51815187
}
51825188
}
51835189
arch_spin_unlock(&tr->max_lock);

0 commit comments

Comments
 (0)