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: kdb: Use tracer_tracing_on/off() instead of setting per CPU disabled

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 kdb_ftdump() 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, simply call tracer_tracing_off() and then tracer_tracing_on() to
disable and then enabled the entire ring buffer in one go!

Cc: Jason Wessel <jason.wessel@windriver.com>
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>
Cc: Daniel Thompson <danielt@kernel.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/20250505212235.549033722@goodmis.org
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+2 -7
+2 -7
kernel/trace/trace_kdb.c
··· 98 98 long cpu_file; 99 99 int err; 100 100 int cnt; 101 - int cpu; 102 101 103 102 if (argc > 2) 104 103 return KDB_ARGCOUNT; ··· 119 120 trace_init_global_iter(&iter); 120 121 iter.buffer_iter = buffer_iter; 121 122 122 - for_each_tracing_cpu(cpu) { 123 - atomic_inc(&per_cpu_ptr(iter.array_buffer->data, cpu)->disabled); 124 - } 123 + tracer_tracing_disable(iter.tr); 125 124 126 125 /* A negative skip_entries means skip all but the last entries */ 127 126 if (skip_entries < 0) { ··· 132 135 133 136 ftrace_dump_buf(skip_entries, cpu_file); 134 137 135 - for_each_tracing_cpu(cpu) { 136 - atomic_dec(&per_cpu_ptr(iter.array_buffer->data, cpu)->disabled); 137 - } 138 + tracer_tracing_enable(iter.tr); 138 139 139 140 kdb_trap_printk--; 140 141