blob: 2dcc7a1431edecb36479063f22d2af555bcd654a [file] [log] [blame]
From 0c3bf440a6cc86006708a74afd7371aaef85947f Mon Sep 17 00:00:00 2001
From: "Steven Rostedt (VMware)" <>
Date: Thu, 20 Feb 2020 15:38:01 -0500
Subject: [PATCH] tracing: Disable trace_printk() on post poned tests
commit 78041c0c9e935d9ce4086feeff6c569ed88ddfd4 upstream.
The tracing seftests checks various aspects of the tracing infrastructure,
and one is filtering. If trace_printk() is active during a self test, it can
cause the filtering to fail, which will disable that part of the trace.
To keep the selftests from failing because of trace_printk() calls,
trace_printk() checks the variable tracing_selftest_running, and if set, it
does not write to the tracing buffer.
As some tracers were registered earlier in boot, the selftest they triggered
would fail because not all the infrastructure was set up for the full
selftest. Thus, some of the tests were post poned to when their
infrastructure was ready (namely file system code). The postpone code did
not set the tracing_seftest_running variable, and could fail if a
trace_printk() was added and executed during their run.
Fixes: 9afecfbb95198 ("tracing: Postpone tracer start-up tests till the system is more robust")
Signed-off-by: Steven Rostedt (VMware) <>
Signed-off-by: Paul Gortmaker <>
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 74fa91ab7608..1c7188e95541 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1726,6 +1726,7 @@ static __init int init_trace_selftests(void)
pr_info("Running postponed tracer tests:\n");
+ tracing_selftest_running = true;
list_for_each_entry_safe(p, n, &postponed_selftests, list) {
/* This loop can take minutes when sanitizers are enabled, so
* lets make sure we allow RCU processing.
@@ -1748,6 +1749,7 @@ static __init int init_trace_selftests(void)
+ tracing_selftest_running = false;