From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-doc@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Andrew Morton <akpm@linux-foundation.org>,
Vincent Donnefort <vdonnefort@google.com>,
Joel Fernandes <joel@joelfernandes.org>,
Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
suleiman@google.com, Thomas Gleixner <tglx@linutronix.de>,
Vineeth Pillai <vineeth@bitbyteword.org>,
Beau Belgrave <beaub@linux.microsoft.com>,
Alexander Graf <graf@amazon.com>, Baoquan He <bhe@redhat.com>,
Borislav Petkov <bp@alien8.de>,
"Paul E. McKenney" <paulmck@kernel.org>,
David Howells <dhowells@redhat.com>,
Mike Rapoport <rppt@kernel.org>,
Dave Hansen <dave.hansen@linux.intel.com>,
Tony Luck <tony.luck@intel.com>,
Guenter Roeck <linux@roeck-us.net>,
Ross Zwisler <zwisler@google.com>,
Kees Cook <keescook@chromium.org>,
Alexander Aring <aahringo@redhat.com>,
"Luis Claudio R. Goncalves" <lgoncalv@redhat.com>,
Tomas Glozar <tglozar@redhat.com>, John Kacur <jkacur@redhat.com>,
Clark Williams <williams@redhat.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
"Jonathan Corbet" <corbet@lwn.net>
Subject: [PATCH 1/5] tracing: Add "traceoff" flag to boot time tracing instances
Date: Thu, 22 Aug 2024 21:39:03 -0400 [thread overview]
Message-ID: <20240823014019.053229958@goodmis.org> (raw)
In-Reply-To: 20240823013902.135036960@goodmis.org
From: Steven Rostedt <rostedt@goodmis.org>
Add a "flags" delimiter (^) to the "trace_instance" kernel command line
parameter, and add the "traceoff" flag. The format is:
trace_instance=<name>[^<flag1>[^<flag2>]][@<memory>][,<events>]
The code allows for more than one flag to be added, but currently only
"traceoff" is done so.
The motivation for this change came from debugging with the persistent
ring buffer and having trace_printk() writing to it. The trace_printk
calls are always enabled, and the boot after the crash was having the
unwanted trace_printks from the current boot inject into the ring buffer
with the trace_printks of the crash kernel, making the output very
confusing.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
.../admin-guide/kernel-parameters.txt | 17 ++++++++++
kernel/trace/trace.c | 31 ++++++++++++++++++-
2 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 388653448e72..3803f2b7f065 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -6743,6 +6743,15 @@
the same thing would happen if it was left off). The irq_handler_entry
event, and all events under the "initcall" system.
+ Flags can be added to the instance to modify its behavior when it is
+ created. The flags are separated by '^'. Currently there's only one flag
+ defined, and that's "traceoff", to have the tracing instance tracing
+ disabled after it is created.
+
+ trace_instance=foo^traceoff,sched,irq
+
+ The flags must come before the defined events.
+
If memory has been reserved (see memmap for x86), the instance
can use that memory:
@@ -6765,6 +6774,14 @@
kernel versions where the validator will fail and reset the ring buffer
if the layout is not the same as the previous kernel.
+ If the ring buffer is used for persistent bootups and has events enabled,
+ it is recommend to disable tracing so that events from a previous boot do not
+ mix with events of the current boot (unless you are debugging a random crash
+ at boot up).
+
+ reserve_mem=12M:4096:trace trace_instance=boot_map^traceoff@trace,sched,irq
+
+
trace_options=[option-list]
[FTRACE] Enable or disable tracer options at boot.
The option-list is a comma delimited list of options
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 9bcef199ae90..a79eefe84d6b 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -10468,10 +10468,36 @@ __init static void enable_instances(void)
phys_addr_t start = 0;
phys_addr_t size = 0;
unsigned long addr = 0;
+ bool traceoff = false;
+ char *flag_delim;
+ char *addr_delim;
tok = strsep(&curr_str, ",");
- name = strsep(&tok, "@");
+ flag_delim = strchr(tok, '^');
+ addr_delim = strchr(tok, '@');
+
+ if (addr_delim)
+ *addr_delim++ = '\0';
+
+ if (flag_delim)
+ *flag_delim++ = '\0';
+
+ name = tok;
+
+ if (flag_delim) {
+ char *flag;
+
+ while ((flag = strsep(&flag_delim, "^"))) {
+ if (strcmp(flag, "traceoff") == 0)
+ traceoff = true;
+ else
+ pr_info("Tracing: Invalid instance flag '%s' for %s\n",
+ flag, name);
+ }
+ }
+
+ tok = addr_delim;
if (tok && isdigit(*tok)) {
start = memparse(tok, &tok);
if (!start) {
@@ -10519,6 +10545,9 @@ __init static void enable_instances(void)
continue;
}
+ if (traceoff)
+ tracer_tracing_off(tr);
+
/* Only allow non mapped buffers to be deleted */
if (!start)
trace_array_put(tr);
--
2.43.0
next prev parent reply other threads:[~2024-08-23 1:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-23 1:39 [PATCH 0/5] tracing: Allow trace_printk() to use the persistent ring buffer Steven Rostedt
2024-08-23 1:39 ` Steven Rostedt [this message]
2024-08-23 1:39 ` [PATCH 2/5] tracing: Allow trace_printk() to go to other instance buffers Steven Rostedt
2024-08-23 1:39 ` [PATCH 3/5] tracing: Have trace_printk not use binary prints if boot buffer Steven Rostedt
2024-08-23 1:39 ` [PATCH 4/5] tracing: Add option to set an instance to be the trace_printk destination Steven Rostedt
2024-08-23 1:39 ` [PATCH 5/5] tracing/Documentation: Start a document on how to debug with tracing Steven Rostedt
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=20240823014019.053229958@goodmis.org \
--to=rostedt@goodmis.org \
--cc=aahringo@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=beaub@linux.microsoft.com \
--cc=bhe@redhat.com \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=dhowells@redhat.com \
--cc=graf@amazon.com \
--cc=jkacur@redhat.com \
--cc=joel@joelfernandes.org \
--cc=keescook@chromium.org \
--cc=lgoncalv@redhat.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=rppt@kernel.org \
--cc=suleiman@google.com \
--cc=tglozar@redhat.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=torvalds@linux-foundation.org \
--cc=vdonnefort@google.com \
--cc=vineeth@bitbyteword.org \
--cc=williams@redhat.com \
--cc=zwisler@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).