From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>,
Luis Chamberlain <mcgrof@kernel.org>,
Petr Pavlu <petr.pavlu@suse.com>,
Sami Tolvanen <samitolvanen@google.com>,
Daniel Gomez <da.gomez@samsung.com>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-modules@vger.kernel.org
Subject: Re: [RFC PATCH 0/3] tracing: Introduce relative stacktrace
Date: Tue, 28 Jan 2025 11:46:25 -0500 [thread overview]
Message-ID: <c3842632-cb15-469f-a6e8-8e9ccb3fff56@efficios.com> (raw)
In-Reply-To: <20250128112733.37d7c771@gandalf.local.home>
On 2025-01-28 11:27, Steven Rostedt wrote:
> On Tue, 28 Jan 2025 10:46:21 -0500
> Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote:
>
>> This does not handle the situation where a module is already loaded
>> before tracing starts. In LTTng we have a statedump facility for this,
>> where we can iterate on all modules at trace start and dump the relevant
>> information.
>>
>> You may want to consider a similar approach for other tracers.
>
> Last night Masami and I were talking about this. The idea I was thinking of
> was to simply have a module load notifier that would add modules to an
> array. It would only keep track of loaded modules, and when the trace hit,
> if the address was outside of core text, it would search the array for the
> module, and use that. When a module is removed, it would also be removed
> from the array. We currently do not support tracing module removal (if the
> module is traced, the buffers are cleared when the module is removed).
I'm trying to wrap my head around what you are trying to achieve here.
So AFAIU you are aiming to store the relative offset from kernel _text
and module base text address into the traced events rather than the
actual address.
Based on Masami's cover letter, this appears to be done to make sure
users can get to this base+offset information even if they cannot read
kallsyms.
Why make the tracing fast path more complex for a simple matter of
accessing this base address information ?
All you need to have to convert from kernel address to base + offset is:
- The kernel _text base address,
- Each loaded module text base address,
- Unloaded modules events to prune this information.
What is wrong with simply exporting this base address information in the
trace buffers rather than rely on kallsyms, and deal with the conversion
to module name / base+offset at post-processing ?
Thanks,
Mathieu
>
> If it is a module address, set the MSB, and for 32 bit machines use the
> next 7 bits as an index into the module array, and for 64 bit machines, use
> the next 10 bits as an index. This would be exposed in the format file for
> the kernel_stack_rel event, so if these numbers change, user space can cope
> with it. In fact, it would need to use the format file to distinguish the
> 32 bit and 64 bit values.
>
> That is, a stack trace will contain addresses that are core kernel simply
> subtracted from ".text", and the modules address would have the MSB set,
> the next bits would be an index into that array that holds the module
> information, and the address would be the address minus the module address
> where it was loaded.
>
> This way we do not need to save the information from any events. Also, for
> the persistent ring buffer, this array could live in that memory, so that
> it will be available on the next boot.
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
next prev parent reply other threads:[~2025-01-28 16:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-28 15:36 [RFC PATCH 0/3] tracing: Introduce relative stacktrace Masami Hiramatsu (Google)
2025-01-28 15:37 ` [RFC PATCH 1/3] tracing: Record stacktrace as the offset from _stext Masami Hiramatsu (Google)
2025-01-28 15:37 ` [RFC PATCH 2/3] tracing: Introduce "rel_stack" option Masami Hiramatsu (Google)
2025-01-28 16:07 ` Steven Rostedt
2025-01-29 0:14 ` Masami Hiramatsu
2025-01-28 15:37 ` [RFC PATCH 3/3] modules: tracing: Add module_text_offsets event Masami Hiramatsu (Google)
2025-01-28 15:46 ` [RFC PATCH 0/3] tracing: Introduce relative stacktrace Mathieu Desnoyers
2025-01-28 16:27 ` Steven Rostedt
2025-01-28 16:46 ` Mathieu Desnoyers [this message]
2025-01-28 17:30 ` Steven Rostedt
2025-01-29 0:58 ` Masami Hiramatsu
2025-01-29 1:09 ` Steven Rostedt
2025-01-29 7:25 ` Masami Hiramatsu
2025-01-29 14:42 ` Steven Rostedt
2025-01-29 0:17 ` Masami Hiramatsu
2025-01-29 0:19 ` Masami Hiramatsu
2025-01-29 0:23 ` Masami Hiramatsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c3842632-cb15-469f-a6e8-8e9ccb3fff56@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=da.gomez@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=mhiramat@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=rostedt@goodmis.org \
--cc=samitolvanen@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox