]> Git Repo - linux.git/commitdiff
tracing: Fix snapshot counter going between two tracers that use it
authorSteven Rostedt (Google) <[email protected]>
Fri, 23 Feb 2024 01:33:24 +0000 (20:33 -0500)
committerSteven Rostedt (Google) <[email protected]>
Mon, 18 Mar 2024 14:33:05 +0000 (10:33 -0400)
Running the ftrace selftests caused the ring buffer mapping test to fail.
Investigating, I found that the snapshot counter would be incremented
every time a tracer that uses the snapshot is enabled even if the snapshot
was used by the previous tracer.

That is:

 # cd /sys/kernel/tracing
 # echo wakeup_rt > current_tracer
 # echo wakeup_dl > current_tracer
 # echo nop > current_tracer

would leave the snapshot counter at 1 and not zero. That's because the
enabling of wakeup_dl would increment the counter again but the setting
the tracer to nop would only decrement it once.

Do not arm the snapshot for a tracer if the previous tracer already had it
armed.

Link: https://lore.kernel.org/linux-trace-kernel/[email protected]
Cc: Masami Hiramatsu <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Mathieu Desnoyers <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Vincent Donnefort <[email protected]>
Fixes: 16f7e48ffc53a ("tracing: Add snapshot refcount")
Signed-off-by: Steven Rostedt (Google) <[email protected]>
kernel/trace/trace.c

index a7c0dc0aaf147e959e3557e21c1bd99cbaf39c5c..1e1fd377a1cfdd6e532c3155055c28f9aaf86fbd 100644 (file)
@@ -6162,7 +6162,7 @@ int tracing_set_tracer(struct trace_array *tr, const char *buf)
                tracing_disarm_snapshot(tr);
        }
 
-       if (t->use_max_tr) {
+       if (!had_max_tr && t->use_max_tr) {
                ret = tracing_arm_snapshot_locked(tr);
                if (ret)
                        goto out;
This page took 0.06509 seconds and 4 git commands to generate.