]> git.baikalelectronics.ru Git - kernel.git/commit
tracing: Add tracing_check_open_get_tr()
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Fri, 11 Oct 2019 21:39:57 +0000 (17:39 -0400)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Sun, 13 Oct 2019 00:44:07 +0000 (20:44 -0400)
commitd308265b9fd3af2356bb9384d6366fb5387b7475
treebea5a6cbbfacf3b79428040486d3eb016d419289
parent3eacfd77c91fa72aa09368fa4e001072bf8c218c
tracing: Add tracing_check_open_get_tr()

Currently, most files in the tracefs directory test if tracing_disabled is
set. If so, it should return -ENODEV. The tracing_disabled is called when
tracing is found to be broken. Originally it was done in case the ring
buffer was found to be corrupted, and we wanted to prevent reading it from
crashing the kernel. But it's also called if a tracing selftest fails on
boot. It's a one way switch. That is, once it is triggered, tracing is
disabled until reboot.

As most tracefs files can also be used by instances in the tracefs
directory, they need to be carefully done. Each instance has a trace_array
associated to it, and when the instance is removed, the trace_array is
freed. But if an instance is opened with a reference to the trace_array,
then it requires looking up the trace_array to get its ref counter (as there
could be a race with it being deleted and the open itself). Once it is
found, a reference is added to prevent the instance from being removed (and
the trace_array associated with it freed).

Combine the two checks (tracing_disabled and trace_array_get()) into a
single helper function. This will also make it easier to add lockdown to
tracefs later.

Link: http://lkml.kernel.org/r/20191011135458.7399da44@gandalf.local.home
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/ftrace.c
kernel/trace/trace.c
kernel/trace/trace.h
kernel/trace/trace_dynevent.c
kernel/trace/trace_events.c
kernel/trace/trace_events_hist.c