Skip to content

Commit 486fbcb

Browse files
mhiramatrostedt
authored andcommitted
tracing: Skip update_last_data() if cleared and remove active check for save_mod()
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 <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Link: https://lore.kernel.org/174165660328.1173316.15529357882704817499.stgit@devnote2 Signed-off-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 5dbeb56 commit 486fbcb

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

kernel/trace/trace.c

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6040,6 +6040,12 @@ static void update_last_data(struct trace_array *tr)
60406040
if (!(tr->flags & TRACE_ARRAY_FL_BOOT))
60416041
return;
60426042

6043+
if (!(tr->flags & TRACE_ARRAY_FL_LAST_BOOT))
6044+
return;
6045+
6046+
/* Only if the buffer has previous boot data clear and update it. */
6047+
tr->flags &= ~TRACE_ARRAY_FL_LAST_BOOT;
6048+
60436049
/* Reset the module list and reload them */
60446050
if (tr->scratch) {
60456051
struct trace_scratch *tscratch = tr->scratch;
@@ -6052,9 +6058,6 @@ static void update_last_data(struct trace_array *tr)
60526058
module_for_each_mod(save_mod, tr);
60536059
}
60546060

6055-
if (!(tr->flags & TRACE_ARRAY_FL_LAST_BOOT))
6056-
return;
6057-
60586061
/*
60596062
* Need to clear all CPU buffers as there cannot be events
60606063
* from the previous boot mixed with events with this boot
@@ -6077,7 +6080,6 @@ static void update_last_data(struct trace_array *tr)
60776080
#else
60786081
tscratch->kaslr_addr = 0;
60796082
#endif
6080-
tr->flags &= ~TRACE_ARRAY_FL_LAST_BOOT;
60816083
}
60826084

60836085
/**
@@ -10103,15 +10105,6 @@ static void trace_module_remove_evals(struct module *mod)
1010310105
static inline void trace_module_remove_evals(struct module *mod) { }
1010410106
#endif /* CONFIG_TRACE_EVAL_MAP_FILE */
1010510107

10106-
static bool trace_array_active(struct trace_array *tr)
10107-
{
10108-
if (tr->current_trace != &nop_trace)
10109-
return true;
10110-
10111-
/* 0 is no events, 1 is all disabled */
10112-
return trace_events_enabled(tr, NULL) > 1;
10113-
}
10114-
1011510108
static void trace_module_record(struct module *mod)
1011610109
{
1011710110
struct trace_array *tr;
@@ -10120,11 +10113,8 @@ static void trace_module_record(struct module *mod)
1012010113
/* Update any persistent trace array that has already been started */
1012110114
if ((tr->flags & (TRACE_ARRAY_FL_BOOT | TRACE_ARRAY_FL_LAST_BOOT)) ==
1012210115
TRACE_ARRAY_FL_BOOT) {
10123-
/* Only update if the trace array is active */
10124-
if (trace_array_active(tr)) {
10125-
guard(mutex)(&scratch_mutex);
10126-
save_mod(mod, tr);
10127-
}
10116+
guard(mutex)(&scratch_mutex);
10117+
save_mod(mod, tr);
1012810118
}
1012910119
}
1013010120
}

0 commit comments

Comments
 (0)