On Mon, Jul 27, 2026 at 08:33:35PM +0200, Miguel Ojeda wrote: > On Mon, Jul 27, 2026 at 7:18 PM Paul Murphy <[email protected]> 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).
