path: root/kernel/trace/trace.c
diff options
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2021-03-01 10:49:35 -0500
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2021-03-04 09:51:25 -0500
commitee666a185558ac9a929e53b902a568442ed62416 (patch)
tree9efeb847d912419a98b91fc382b8d2c6841598f6 /kernel/trace/trace.c
parentf40fc799afc598b3d130d5a0ada994c9d4fb6cf8 (diff)
tracing: Skip selftests if tracing is disabled
If tracing is disabled for some reason (traceoff_on_warning, command line, etc), the ftrace selftests are guaranteed to fail, as their results are defined by trace data in the ring buffers. If the ring buffers are turned off, the tests will fail, due to lack of data. Because tracing being disabled is for a specific reason (warning, user decided to, etc), it does not make sense to enable tracing to run the self tests, as the test output may corrupt the reason for the tracing to be disabled. Instead, simply skip the self tests and report that they are being skipped due to tracing being disabled. Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace.c')
1 files changed, 6 insertions, 0 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index e295c413580e..eccb4e1187cc 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1929,6 +1929,12 @@ static int run_tracer_selftest(struct tracer *type)
if (!selftests_can_run)
return save_selftest(type);
+ if (!tracing_is_on()) {
+ pr_warn("Selftest for tracer %s skipped due to tracing disabled\n",
+ type->name);
+ return 0;
+ }
* Run a selftest on this tracer.
* Here we reset the trace buffer, and set the current