[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250828180300.591225320@kernel.org>
Date: Thu, 28 Aug 2025 14:03:00 -0400
From: Steven Rostedt <rostedt@...nel.org>
To: linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org,
bpf@...r.kernel.org,
x86@...nel.org
Cc: Masami Hiramatsu <mhiramat@...nel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>,
Jiri Olsa <jolsa@...nel.org>,
Arnaldo Carvalho de Melo <acme@...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>,
Florian Weimer <fweimer@...hat.com>,
Sam James <sam@...too.org>,
Kees Cook <kees@...nel.org>,
"Carlos O'Donell" <codonell@...hat.com>
Subject: [PATCH v6 0/6] tracing: Deferred unwinding of user space stack traces
This is the tracefs (ftrace) implementation of the deferred stack tracing.
This creates two new events that get set for every trace event when the new
"userstacktrace_delay" option is enabled. The first event happens at the time
of the request (after a trace event) that saves the cookie that represents the
current user space stack trace (it stays the same while the task is in the
kernel, as the user space stack doesn't change during this time). The second
event is where the user space stacktrace is recorded along with the cookie.
Since the callback is called in faultable context, it uses this opportunity
to look at the addresses in the stacktrace and convert them to where
they would be in the executable file (if found). It also records
the inode and device major/minor numbers into the trace, so that post
processing can find the exact location where the stacks are.
To simplify the finding of the files, a new "inode_cache" event is created
that gets triggered whenever a new inode/device is added to a new rhashtable.
It will then look up the path that represents that inode/device via the vma
descriptor. To keep the recording down to a minimum, this event is only
triggered when a new inode/device is added to the rhashtable. The rhashtable
is reset when certain changes occur in the tracefs system so that new readers
of this event can get the latest changes.
Changes since v5: https://lore.kernel.org/linux-trace-kernel/20250424192456.851953422@goodmis.org/
- Removed unwind infrastructure patches as they have already been merged.
- Also add check for PF_USER_WORKER to test for kernel thread
- Have the userstacktrace_delay option not depend on the userstacktrace
option.
- Do not expose the userstacktrace_delay option if it's not supported.
- Set inode to -1L if vma is not found for that address to let user space
know that, and differentiate from a vdso section.
- Added "inode_cache" to dsiplay inode/device paths when added to a stack trace
Steven Rostedt (6):
tracing: Do not bother getting user space stacktraces for kernel threads
tracing: Rename __dynamic_array() to __dynamic_field() for ftrace events
tracing: Implement deferred user space stacktracing
tracing: Have deferred user space stacktrace show file offsets
tracing: Show inode and device major:minor in deferred user space stacktrace
tracing: Add an event to map the inodes to their file names
----
kernel/trace/Makefile | 3 +
kernel/trace/inode_cache.c | 144 ++++++++++++++++++++++++++++++++++++++
kernel/trace/trace.c | 146 ++++++++++++++++++++++++++++++++++++++-
kernel/trace/trace.h | 32 ++++++++-
kernel/trace/trace_entries.h | 38 ++++++++--
kernel/trace/trace_export.c | 25 ++++++-
kernel/trace/trace_inode_cache.h | 42 +++++++++++
kernel/trace/trace_output.c | 99 ++++++++++++++++++++++++++
8 files changed, 520 insertions(+), 9 deletions(-)
create mode 100644 kernel/trace/inode_cache.c
create mode 100644 kernel/trace/trace_inode_cache.h
Powered by blists - more mailing lists