Skip to content

Commit 6ba3e05

Browse files
committed
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 <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Andrew Morton <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent dbecef6 commit 6ba3e05

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

kernel/trace/trace.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10484,7 +10484,7 @@ static void ftrace_dump_one(struct trace_array *tr, enum ftrace_dump_mode dump_m
1048410484
static struct trace_iterator iter;
1048510485
unsigned int old_userobj;
1048610486
unsigned long flags;
10487-
int cnt = 0, cpu;
10487+
int cnt = 0;
1048810488

1048910489
/*
1049010490
* Always turn off tracing when we dump.
@@ -10501,9 +10501,8 @@ static void ftrace_dump_one(struct trace_array *tr, enum ftrace_dump_mode dump_m
1050110501
/* Simulate the iterator */
1050210502
trace_init_iter(&iter, tr);
1050310503

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);
1050710506

1050810507
old_userobj = tr->trace_flags & TRACE_ITER_SYM_USEROBJ;
1050910508

@@ -10562,9 +10561,7 @@ static void ftrace_dump_one(struct trace_array *tr, enum ftrace_dump_mode dump_m
1056210561

1056310562
tr->trace_flags |= old_userobj;
1056410563

10565-
for_each_tracing_cpu(cpu) {
10566-
atomic_dec(&per_cpu_ptr(iter.array_buffer->data, cpu)->disabled);
10567-
}
10564+
tracer_tracing_enable(tr);
1056810565
local_irq_restore(flags);
1056910566
}
1057010567

0 commit comments

Comments
 (0)