[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250709212556.32777-6-mathieu.desnoyers@efficios.com>
Date: Wed, 9 Jul 2025 17:25:52 -0400
From: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: linux-kernel@...r.kernel.org,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>,
Jiri Olsa <jolsa@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Andrii Nakryiko <andrii@...nel.org>,
Indu Bhagat <indu.bhagat@...cle.com>,
"Jose E. Marchesi" <jemarch@....org>,
Beau Belgrave <beaub@...ux.microsoft.com>,
Jens Remus <jremus@...ux.ibm.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: [RFC PATCH 5/5] unwind: Introduce unwind user entry type
Introduce a unwind user entry type to allow unwind iterator users to
know which method was used to obtain each of the stack frames.
This allows iterator users to know whether they can trust the
information provided by the stack trace. For instance, on a system with
binaries built with frame pointers omitted, the stack frames fetched
using the frame pointer method should be considered unreliable, whereas
those fetched using sframe should be reliable.
Note that the "none" entry type denotes the first address (start of
iteration), which is present in the pt_regs, and therefore is always
reliable.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Cc: Steven Rostedt (Google) <rostedt@...dmis.org>
Cc: Josh Poimboeuf <jpoimboe@...nel.org>
Cc: Masami Hiramatsu <mhiramat@...nel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Andrii Nakryiko <andrii@...nel.org>
Cc: Indu Bhagat <indu.bhagat@...cle.com>
Cc: "Jose E. Marchesi" <jemarch@....org>
Cc: Beau Belgrave <beaub@...ux.microsoft.com>
Cc: Jens Remus <jremus@...ux.ibm.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>
---
include/linux/unwind_deferred_types.h | 6 ++++--
include/linux/unwind_user_types.h | 9 +++++++--
kernel/unwind/user.c | 7 +++++--
3 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/include/linux/unwind_deferred_types.h b/include/linux/unwind_deferred_types.h
index db6c65daf185..ef9818456fd5 100644
--- a/include/linux/unwind_deferred_types.h
+++ b/include/linux/unwind_deferred_types.h
@@ -2,9 +2,11 @@
#ifndef _LINUX_UNWIND_USER_DEFERRED_TYPES_H
#define _LINUX_UNWIND_USER_DEFERRED_TYPES_H
+#include <linux/unwind_user_types.h>
+
struct unwind_cache {
- unsigned int nr_entries;
- unsigned long entries[];
+ unsigned int nr_entries;
+ struct unwind_user_entry entries[];
};
diff --git a/include/linux/unwind_user_types.h b/include/linux/unwind_user_types.h
index 860f84cd7998..ab29c419099c 100644
--- a/include/linux/unwind_user_types.h
+++ b/include/linux/unwind_user_types.h
@@ -28,9 +28,14 @@ enum unwind_user_type {
UNWIND_USER_TYPE_FP = (1U << UNWIND_USER_TYPE_FP_BIT),
};
+struct unwind_user_entry {
+ enum unwind_user_type type;
+ unsigned long ip;
+};
+
struct unwind_user_stacktrace {
- unsigned int nr;
- unsigned long *entries;
+ unsigned int nr;
+ struct unwind_user_entry *entries;
};
struct unwind_user_frame {
diff --git a/kernel/unwind/user.c b/kernel/unwind/user.c
index dfe7bf50d8f6..9a88fe757327 100644
--- a/kernel/unwind/user.c
+++ b/kernel/unwind/user.c
@@ -180,8 +180,11 @@ int unwind_user(struct unwind_user_stacktrace *trace, unsigned int max_entries)
return 0;
for_each_user_frame(&state) {
- trace->entries[trace->nr++] = state.ip;
- if (trace->nr >= max_entries)
+ unsigned int i = trace->nr++;
+
+ trace->entries[i].type = state.current_type;
+ trace->entries[i].ip = state.ip;
+ if (i >= max_entries)
break;
}
--
2.43.0
Powered by blists - more mailing lists