From: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
Mark Rutland <mark.rutland@arm.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Subject: [PATCH v2] tracing: Skip update_last_data() if cleared and remove active check for save_mod()
Date: Tue, 11 Mar 2025 10:30:03 +0900 [thread overview]
Message-ID: <174165660328.1173316.15529357882704817499.stgit@devnote2> (raw)
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
If the last boot data is already cleared, there is no reason to update it
again. Skip if the TRACE_ARRAY_FL_LAST_BOOT is cleared.
Also, for calling save_mod() when module loading, we don't need to check
the trace is active or not because any module address can be on the
stacktrace.
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
Changes in v2:
- merge [1/3] and [2/3] in the previous series.
---
kernel/trace/trace.c | 26 ++++++++------------------
1 file changed, 8 insertions(+), 18 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index c3c79908766e..d17278a72e72 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -6033,6 +6033,12 @@ static void update_last_data(struct trace_array *tr)
if (!(tr->flags & TRACE_ARRAY_FL_BOOT))
return;
+ if (!(tr->flags & TRACE_ARRAY_FL_LAST_BOOT))
+ return;
+
+ /* Only if the buffer has previous boot data clear and update it. */
+ tr->flags &= ~TRACE_ARRAY_FL_LAST_BOOT;
+
/* Reset the module list and reload them */
if (tr->scratch) {
struct trace_scratch *tscratch = tr->scratch;
@@ -6045,9 +6051,6 @@ static void update_last_data(struct trace_array *tr)
module_for_each_mod(save_mod, tr);
}
- if (!(tr->flags & TRACE_ARRAY_FL_LAST_BOOT))
- return;
-
/*
* Need to clear all CPU buffers as there cannot be events
* from the previous boot mixed with events with this boot
@@ -6070,7 +6073,6 @@ static void update_last_data(struct trace_array *tr)
#else
tscratch->kaslr_addr = 0;
#endif
- tr->flags &= ~TRACE_ARRAY_FL_LAST_BOOT;
}
/**
@@ -10092,15 +10094,6 @@ static void trace_module_remove_evals(struct module *mod)
static inline void trace_module_remove_evals(struct module *mod) { }
#endif /* CONFIG_TRACE_EVAL_MAP_FILE */
-static bool trace_array_active(struct trace_array *tr)
-{
- if (tr->current_trace != &nop_trace)
- return true;
-
- /* 0 is no events, 1 is all disabled */
- return trace_events_enabled(tr, NULL) > 1;
-}
-
static void trace_module_record(struct module *mod)
{
struct trace_array *tr;
@@ -10109,11 +10102,8 @@ static void trace_module_record(struct module *mod)
/* Update any persistent trace array that has already been started */
if ((tr->flags & (TRACE_ARRAY_FL_BOOT | TRACE_ARRAY_FL_LAST_BOOT)) ==
TRACE_ARRAY_FL_BOOT) {
- /* Only update if the trace array is active */
- if (trace_array_active(tr)) {
- guard(mutex)(&scratch_mutex);
- save_mod(mod, tr);
- }
+ guard(mutex)(&scratch_mutex);
+ save_mod(mod, tr);
}
}
}
reply other threads:[~2025-03-11 1:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=174165660328.1173316.15529357882704817499.stgit@devnote2 \
--to=mhiramat@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=rostedt@goodmis.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox