diff options
author | Masami Hiramatsu (Google) <mhiramat@kernel.org> | 2025-05-14 16:04:18 +0900 |
---|---|---|
committer | Steven Rostedt (Google) <rostedt@goodmis.org> | 2025-05-14 11:23:28 -0400 |
commit | 2632a2013f58f0aab4b9fd042e67d78740ba0996 (patch) | |
tree | 669d3bc36697de85eb185b0cdfc826082dd0596f | |
parent | 155fd6c3e2f02efdc71a9b62888942efc217aff0 (diff) | |
download | linux-trace-for-next.tar.gz |
tracing: Record trace_clock and recover when reboottrace/for-nextfor-next
Record trace_clock information in the trace_scratch area and recover
the trace_clock when boot, so that reader can docode the timestamp
correctly.
Note that since most trace_clocks records the timestamp in nano-
seconds, this is not a bug. But some trace_clock, like counter and
tsc will record the counter value. Only for those trace_clock user
needs this information.
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://lore.kernel.org/174720625803.1925039.1815089037443798944.stgit@mhiramat.tok.corp.google.com
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-rw-r--r-- | kernel/trace/trace.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index cf51c30b137fba..2c1764ed87b059 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -6066,6 +6066,7 @@ struct trace_mod_entry { }; struct trace_scratch { + unsigned int clock_id; unsigned long text_addr; unsigned long nr_entries; struct trace_mod_entry entries[]; @@ -6181,6 +6182,7 @@ static void update_last_data(struct trace_array *tr) if (tr->scratch) { struct trace_scratch *tscratch = tr->scratch; + tscratch->clock_id = tr->clock_id; memset(tscratch->entries, 0, flex_array_size(tscratch, entries, tscratch->nr_entries)); tscratch->nr_entries = 0; @@ -7403,6 +7405,12 @@ int tracing_set_clock(struct trace_array *tr, const char *clockstr) tracing_reset_online_cpus(&tr->max_buffer); #endif + if (tr->scratch && !(tr->flags & TRACE_ARRAY_FL_LAST_BOOT)) { + struct trace_scratch *tscratch = tr->scratch; + + tscratch->clock_id = i; + } + mutex_unlock(&trace_types_lock); return 0; @@ -9628,6 +9636,15 @@ static void setup_trace_scratch(struct trace_array *tr, /* Scan modules to make text delta for modules. */ module_for_each_mod(make_mod_delta, tr); + + /* Set trace_clock as the same of the previous boot. */ + if (tscratch->clock_id != tr->clock_id) { + if (tscratch->clock_id >= ARRAY_SIZE(trace_clocks) || + tracing_set_clock(tr, trace_clocks[tscratch->clock_id].name) < 0) { + pr_info("the previous trace_clock info is not valid."); + goto reset; + } + } return; reset: /* Invalid trace modules */ |