]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
tracing: Skip update_last_data() if cleared and remove active check for save_mod()
authorMasami Hiramatsu (Google) <mhiramat@kernel.org>
Tue, 11 Mar 2025 01:30:03 +0000 (10:30 +0900)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Fri, 28 Mar 2025 12:39:56 +0000 (08:39 -0400)
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.

Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://lore.kernel.org/174165660328.1173316.15529357882704817499.stgit@devnote2
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/trace.c

index 78ae76666695321a13bfeaaf71dc85490a427110..382c7a5623036eefcc8de4f16f8dff46ac9a0a67 100644 (file)
@@ -6040,6 +6040,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;
@@ -6052,9 +6058,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
@@ -6077,7 +6080,6 @@ static void update_last_data(struct trace_array *tr)
 #else
        tscratch->kaslr_addr = 0;
 #endif
-       tr->flags &= ~TRACE_ARRAY_FL_LAST_BOOT;
 }
 
 /**
@@ -10103,15 +10105,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;
@@ -10120,11 +10113,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);
                }
        }
 }