[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231213000452.88295-14-graf@amazon.com>
Date: Wed, 13 Dec 2023 00:04:50 +0000
From: Alexander Graf <graf@...zon.com>
To: <linux-kernel@...r.kernel.org>
CC: <linux-trace-kernel@...r.kernel.org>, <linux-mm@...ck.org>,
<devicetree@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<kexec@...ts.infradead.org>, <linux-doc@...r.kernel.org>,
<x86@...nel.org>, Eric Biederman <ebiederm@...ssion.com>,
"H. Peter Anvin" <hpa@...or.com>,
Andy Lutomirski <luto@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
"Rob Herring" <robh+dt@...nel.org>,
Steven Rostedt <rostedt@...dmis.org>,
"Andrew Morton" <akpm@...ux-foundation.org>,
Mark Rutland <mark.rutland@....com>,
"Tom Lendacky" <thomas.lendacky@....com>,
Ashish Kalra <ashish.kalra@....com>,
James Gowans <jgowans@...zon.com>,
Stanislav Kinsburskii <skinsburskii@...ux.microsoft.com>,
<arnd@...db.de>, <pbonzini@...hat.com>,
<madvenka@...ux.microsoft.com>,
Anthony Yznaga <anthony.yznaga@...cle.com>,
Usama Arif <usama.arif@...edance.com>,
David Woodhouse <dwmw@...zon.co.uk>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>
Subject: [PATCH 13/15] tracing: Add kho serialization of trace events
Events and thus their parsing handle in ftrace have dynamic IDs that get
assigned whenever the event is added to the system. If we want to parse
trace events after kexec, we need to link event IDs back to the original
trace event that existed before we kexec'ed.
There are broadly 2 paths we could take for that:
1) Save full event description across KHO, restore after kexec,
merge identical trace events into a single identifier.
2) Recover the ID of post-kexec added events so they get the same
ID after kexec that they had before kexec
This patch implements the second option. It's simpler and thus less
intrusive. However, it means we can not fully parse affected events
when the kernel removes or modifies trace events across a kho kexec.
Signed-off-by: Alexander Graf <graf@...zon.com>
---
kernel/trace/trace.c | 1 +
kernel/trace/trace_output.c | 28 ++++++++++++++++++++++++++++
kernel/trace/trace_output.h | 1 +
3 files changed, 30 insertions(+)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 71c249cc5b43..26edfd2a85fd 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -10639,6 +10639,7 @@ static int trace_kho_notifier(struct notifier_block *self,
err |= fdt_begin_node(fdt, "ftrace");
err |= fdt_property(fdt, "compatible", compatible, sizeof(compatible));
err |= trace_kho_write_trace_array(fdt, &global_trace);
+ err |= trace_kho_write_events(fdt);
err |= fdt_end_node(fdt);
if (!err) {
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index f3677e0da795..113de40c616f 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -12,6 +12,7 @@
#include <linux/sched/clock.h>
#include <linux/sched/mm.h>
#include <linux/idr.h>
+#include <linux/kexec.h>
#include "trace_output.h"
@@ -669,6 +670,33 @@ int trace_print_lat_context(struct trace_iterator *iter)
return !trace_seq_has_overflowed(s);
}
+int trace_kho_write_events(void *fdt)
+{
+#ifdef CONFIG_FTRACE_KHO
+ const char compatible[] = "ftrace,events-v1";
+ const char *name = "events";
+ struct trace_event *event;
+ unsigned key;
+ int err = 0;
+
+ err |= fdt_begin_node(fdt, name);
+ err |= fdt_property(fdt, "compatible", compatible, sizeof(compatible));
+
+ for (key = 0; key < EVENT_HASHSIZE; key++) {
+ hlist_for_each_entry(event, &event_hash[key], node)
+ err |= fdt_property(fdt, event->name, &event->type,
+ sizeof(event->type));
+ }
+
+ err |= fdt_end_node(fdt);
+
+ return err;
+#else
+ return 0;
+#endif
+}
+
+
/**
* ftrace_find_event - find a registered event
* @type: the type of event to look for
diff --git a/kernel/trace/trace_output.h b/kernel/trace/trace_output.h
index dca40f1f1da4..36dc7963269e 100644
--- a/kernel/trace/trace_output.h
+++ b/kernel/trace/trace_output.h
@@ -25,6 +25,7 @@ extern enum print_line_t print_event_fields(struct trace_iterator *iter,
extern void trace_event_read_lock(void);
extern void trace_event_read_unlock(void);
extern struct trace_event *ftrace_find_event(int type);
+extern int trace_kho_write_events(void *fdt);
extern enum print_line_t trace_nop_print(struct trace_iterator *iter,
int flags, struct trace_event *event);
--
2.40.1
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
Powered by blists - more mailing lists