[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <173807864506.1525539.5749974707383492634.stgit@mhiramat.roam.corp.google.com>
Date: Wed, 29 Jan 2025 00:37:25 +0900
From: "Masami Hiramatsu (Google)" <mhiramat@...nel.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Masami Hiramatsu <mhiramat@...nel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Luis Chamberlain <mcgrof@...nel.org>,
Petr Pavlu <petr.pavlu@...e.com>,
Sami Tolvanen <samitolvanen@...gle.com>,
Daniel Gomez <da.gomez@...sung.com>,
linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org,
linux-modules@...r.kernel.org
Subject: [RFC PATCH 3/3] modules: tracing: Add module_text_offsets event
From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
Add new module_text_offsets event which records the offset of module
text and init_text section address and size.
This information is required for decoding the relative stacktrace
entries for modules.
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@...nel.org>
---
include/trace/events/module.h | 40 ++++++++++++++++++++++++++++++++++++++++
kernel/module/main.c | 1 +
2 files changed, 41 insertions(+)
diff --git a/include/trace/events/module.h b/include/trace/events/module.h
index e5a006be9dc6..1e5c84cc8d15 100644
--- a/include/trace/events/module.h
+++ b/include/trace/events/module.h
@@ -47,6 +47,46 @@ TRACE_EVENT(module_load,
TP_printk("%s %s", __get_str(name), show_module_flags(__entry->taints))
);
+/* Module address offset from _stext */
+TRACE_EVENT(module_text_offsets,
+
+ TP_PROTO(struct module *mod),
+
+ TP_ARGS(mod),
+
+ TP_STRUCT__entry(
+ __string( name, mod->name )
+ __field( unsigned long, text_offset )
+ __field( unsigned int, text_size )
+ __field( unsigned long, init_offset )
+ __field( unsigned int, init_size )
+ ),
+
+ TP_fast_assign(
+ if (mod->mem[MOD_TEXT].size) {
+ __entry->text_offset = (unsigned long)mod->mem[MOD_TEXT].base
+ - (unsigned long)_stext;
+ __entry->text_size = mod->mem[MOD_TEXT].size;
+ } else {
+ __entry->text_offset = 0;
+ __entry->text_size = 0;
+ }
+ if (mod->mem[MOD_INIT_TEXT].size) {
+ __entry->init_offset = (unsigned long)mod->mem[MOD_INIT_TEXT].base
+ - (unsigned long)_stext;
+ __entry->init_size = mod->mem[MOD_INIT_TEXT].size;
+ } else {
+ __entry->init_offset = 0;
+ __entry->init_size = 0;
+ }
+ __assign_str(name);
+ ),
+
+ TP_printk("%s text_offset=0x%lx text_size=%d init_offset=0x%lx init_size=%d",
+ __get_str(name), __entry->text_offset, __entry->text_size,
+ __entry->init_offset, __entry->init_size)
+);
+
TRACE_EVENT(module_free,
TP_PROTO(struct module *mod),
diff --git a/kernel/module/main.c b/kernel/module/main.c
index 5399c182b3cb..9f1ca8730a71 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -3372,6 +3372,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
/* Done! */
trace_module_load(mod);
+ trace_module_text_offsets(mod);
return do_init_module(mod);
Powered by blists - more mailing lists