* Re: [PATCH] rust: enable fentry support
[not found] ` <CANiq72nJ=7TAjtArF2VzDZqwKDcuMFjeisD25R2GuA0NiJwk-Q@mail.gmail.com>
@ 2026-07-28 22:57 ` Vasily Gorbik
0 siblings, 0 replies; only message in thread
From: Vasily Gorbik @ 2026-07-28 22:57 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Paul Murphy, Heiko Carstens, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, sashiko-reviews,
Paul Murphy, ojeda, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, linux-trace-kernel, Jan Polensky, Eddy Stefes
On Mon, Jul 27, 2026 at 08:33:35PM +0200, Miguel Ojeda wrote:
> On Mon, Jul 27, 2026 at 7:18 PM Paul Murphy <paumurph@redhat.com> wrote:
> >
> > Hrm, s390x has more nuanced usage. It still uses -mrecord-mcount and
> > -mnop-mcount. The x86 configurations I've looked at use the kernel's
> > tooling to nop and record as needed. Is there any reason s390x cannot
> > use those, or should rustc support those (for s390x only)?
>
> Cc'ing the s390x maintainers -- they probably know why they use them.
Cc'ing the ftrace maintainers.
I do not think this is true for x86 in general. Generating the
__fentry__ call and recording its location are two separate operations.
-Zinstrument-mcount=fentry only generates the call. Dynamic ftrace also
needs the call site recorded in __mcount_loc section.
The recording mechanism is selected in kernel/trace/Kconfig:
config FTRACE_MCOUNT_USE_CC
def_bool y
depends on $(cc-option,-mrecord-mcount)
depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
depends on DYNAMIC_FTRACE
config FTRACE_MCOUNT_USE_OBJTOOL
def_bool y
depends on HAVE_OBJTOOL_MCOUNT
depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
depends on !FTRACE_MCOUNT_USE_CC <--- NOTICE THAT --
depends on DYNAMIC_FTRACE
select OBJTOOL
config FTRACE_MCOUNT_USE_RECORDMCOUNT
def_bool y
depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
depends on !FTRACE_MCOUNT_USE_CC
depends on !FTRACE_MCOUNT_USE_OBJTOOL
depends on DYNAMIC_FTRACE
There are currently three ways to generate __mcount_loc section:
1. The compiler does it with -mrecord-mcount.
2. Objtool does it with --mcount.
3. scripts/recordmcount does it as a post-processing step.
These are selected in that order.
Looking on my system:
For x86 GCC builds - current GCC supports -mrecord-mcount,
so FTRACE_MCOUNT_USE_CC is selected and the compiler gets
-pg -mfentry -mrecord-mcount
For x86 Clang builds - current x86 Clang does not support -mrecord-mcount,
so FTRACE_MCOUNT_USE_OBJTOOL is selected. Clang gets
-pg -mfentry
and objtool gets
--mcount --mnop
s390 uses the compiler path with both current GCC and Clang:
-pg -mfentry -mrecord-mcount -mnop-mcount
Here -mrecord-mcount creates __mcount_loc and -mnop-mcount emits the
six-byte nop expected by the s390 ftrace code.
So -Zinstrument-mcount=fentry alone is sufficient only when some
later build step records the generated call, as objtool does for
x86 Clang FTRACE_MCOUNT_USE_OBJTOOL builds. It is not sufficient for
FTRACE_MCOUNT_USE_CC. For FTRACE_MCOUNT_USE_RECORDMCOUNT - the
scripts/recordmcount post-processing step is also currently wired to
the C build rule rather than the Rust build rule.
Objtool mcount recording is currently supported only by x86 and powerpc.
Those are the only architectures which select HAVE_OBJTOOL_MCOUNT. And
s390 currently has no objtool support.
So I do not think -mrecord-mcount Rust support is only needed for
s390. The Rust build path needs an equivalent of -mrecord-mcount when
FTRACE_MCOUNT_USE_CC is selected. And additionally an equivalent of
-mnop-mcount for s390 (this is debatable, we could check if this brings
us much or we could drop it).
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-07-28 22:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260724170132.3783816-1-murp@redhat.com>
[not found] ` <20260724172024.0648C1F000E9@smtp.kernel.org>
[not found] ` <CALYDSrQhUbKDHsPnQqp0K4WMe2iZC-G1nGrLT6eQ9doCqdVXKQ@mail.gmail.com>
[not found] ` <CANiq72nJ=7TAjtArF2VzDZqwKDcuMFjeisD25R2GuA0NiJwk-Q@mail.gmail.com>
2026-07-28 22:57 ` [PATCH] rust: enable fentry support Vasily Gorbik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox