Skip to content

Commit

Permalink
tracing: Decrement the snapshot if the snapshot trigger fails to regi…
Browse files Browse the repository at this point in the history
…ster

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/[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: 16f7e48 ("tracing: Add snapshot refcount")
Signed-off-by: Steven Rostedt (Google) <[email protected]>
  • Loading branch information
rostedt committed Mar 18, 2024
1 parent cca990c commit 2048fdc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kernel/trace/trace_events_trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,10 @@ register_snapshot_trigger(char *glob,
if (ret < 0)
return ret;

return register_trigger(glob, data, file);
ret = register_trigger(glob, data, file);
if (ret < 0)
tracing_disarm_snapshot(file->tr);
return ret;
}

static void unregister_snapshot_trigger(char *glob,
Expand Down

0 comments on commit 2048fdc

Please sign in to comment.