tracing: Decrement the snapshot if the snapshot trigger fails to register
authorSteven Rostedt (Google) <rostedt@goodmis.org>
Fri, 23 Feb 2024 01:33:25 +0000 (20:33 -0500)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Mon, 18 Mar 2024 14:33:05 +0000 (10:33 -0400)
commit2048fdc27525c6b32c63f8429d9335b7fd2f90c2
treef8f98c86b73f831623c317cda2eb01f9ee08a975
parentcca990c7b565af0dc61a8f647c00833453cf5bff
tracing: Decrement the snapshot if the snapshot trigger fails to register

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 snapshot trigger was added, even if that snapshot trigger
failed.

 # cd /sys/kernel/tracing
 # echo "snapshot" > events/sched/sched_process_fork/trigger
 # echo "snapshot" > events/sched/sched_process_fork/trigger
 -bash: echo: write error: File exists

That second one that fails increments the snapshot counter but doesn't
decrement it. It needs to be decremented when the snapshot fails.

Link: https://lore.kernel.org/linux-trace-kernel/20240223013344.729055907@goodmis.org
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: Vincent Donnefort <vdonnefort@google.com>
Fixes: 16f7e48ffc53a ("tracing: Add snapshot refcount")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/trace_events_trigger.c