All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 5.10 4/8] tracing: Skip selftests if tracing is disabled
Date: Sun,  7 Mar 2021 08:57:57 -0500	[thread overview]
Message-ID: <20210307135801.967583-4-sashal@kernel.org> (raw)
In-Reply-To: <20210307135801.967583-1-sashal@kernel.org>

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

[ Upstream commit ee666a185558ac9a929e53b902a568442ed62416 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/trace/trace.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index ee4be813ba85..54f74e2effb3 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1932,6 +1932,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
-- 
2.30.1


  parent reply	other threads:[~2021-03-07 13:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-07 13:57 [PATCH AUTOSEL 5.10 1/8] pstore: Fix warning in pstore_kill_sb() Sasha Levin
2021-03-07 13:57 ` [PATCH AUTOSEL 5.10 2/8] pstore/ram: Rate-limit "uncorrectable error in header" message Sasha Levin
2021-03-07 13:57 ` [PATCH AUTOSEL 5.10 3/8] drm/amdgpu: enable BACO runpm by default on sienna cichlid and navy flounder Sasha Levin
2021-03-07 13:57   ` Sasha Levin
2021-03-07 13:57   ` Sasha Levin
2021-03-07 13:57 ` Sasha Levin [this message]
2021-03-07 13:57 ` [PATCH AUTOSEL 5.10 5/8] nvme-pci: mark Seagate Nytro XM1440 as QUIRK_NO_NS_DESC_LIST Sasha Levin
2021-03-07 13:57   ` Sasha Levin
2021-03-07 13:57 ` [PATCH AUTOSEL 5.10 6/8] nvme-pci: add quirks for Lexar 256GB SSD Sasha Levin
2021-03-07 13:57   ` Sasha Levin
2021-03-07 13:58 ` [PATCH AUTOSEL 5.10 7/8] nvme-fabrics: fix kato initialization Sasha Levin
2021-03-07 13:58   ` Sasha Levin
2021-03-07 13:58 ` [PATCH AUTOSEL 5.10 8/8] nvmet: model_number must be immutable once set Sasha Levin
2021-03-07 13:58   ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210307135801.967583-4-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.