Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tracing: Use tracer_tracing_disable() instead of "disabled" field for ftrace_dump_one()

The per CPU "disabled" value was the original way to disable tracing when
the tracing subsystem was first created. Today, the ring buffer
infrastructure has its own way to disable tracing. In fact, things have
changed so much since 2008 that many things ignore the disable flag.

The ftrace_dump_one() function iterates over all the current tracing CPUs and
increments the "disabled" counter before doing the dump, and decrements it
afterward.

As the disabled flag can be ignored, doing this today is not reliable.
Instead use the new tracer_tracing_disable() that calls into the ring
buffer code to do the disabling.

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: https://lore.kernel.org/20250505212235.381188238@goodmis.org
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+4 -7
+4 -7
kernel/trace/trace.c
··· 10484 10484 static struct trace_iterator iter; 10485 10485 unsigned int old_userobj; 10486 10486 unsigned long flags; 10487 - int cnt = 0, cpu; 10487 + int cnt = 0; 10488 10488 10489 10489 /* 10490 10490 * Always turn off tracing when we dump. ··· 10501 10501 /* Simulate the iterator */ 10502 10502 trace_init_iter(&iter, tr); 10503 10503 10504 - for_each_tracing_cpu(cpu) { 10505 - atomic_inc(&per_cpu_ptr(iter.array_buffer->data, cpu)->disabled); 10506 - } 10504 + /* While dumping, do not allow the buffer to be enable */ 10505 + tracer_tracing_disable(tr); 10507 10506 10508 10507 old_userobj = tr->trace_flags & TRACE_ITER_SYM_USEROBJ; 10509 10508 ··· 10561 10562 10562 10563 tr->trace_flags |= old_userobj; 10563 10564 10564 - for_each_tracing_cpu(cpu) { 10565 - atomic_dec(&per_cpu_ptr(iter.array_buffer->data, cpu)->disabled); 10566 - } 10565 + tracer_tracing_enable(tr); 10567 10566 local_irq_restore(flags); 10568 10567 } 10569 10568