Re: [PATCH v3 00/22] Move notrace from inline to __always_inline

From: Masami Hiramatsu (Google)

Date: Wed Dec 02 2026 - 08:50:29 EST


Hi Song,

On Mon, 30 Nov 2026 20:21:39 -0800
Song Liu <song@xxxxxxxxxx> wrote:

> Since commit 45959ee7aa64 ("ftrace: Do not function trace inlined
> functions"), every function marked inline is also notrace. When the
> compiler does not inline such a function, the out-of-line copy cannot
> be traced with ftrace, cannot be a BPF fentry/fexit target, and cannot
> be livepatched. This series moves notrace from inline to
> __always_inline, so these copies become traceable. __always_inline
> functions, which are mostly low-level helpers, stay untraced.

I have fundamental concerns regarding making standard inline functions
traceable - specifically, the issue of recursion within the function tracer
and the function graph tracer.

In my view, ftrace operates on the following assumption: it is always
safe to call a standard `static inline` helper function from within a
function marked `notrace` (or from within the ftrace recursion-
protection path in code compiled for instrumentation).
If the `notrace` designation were removed from an inline function, that
function - should it be generated as standalone code rather than being
inlined - would become subject to tracing. This could trigger recursion
within ftrace or fgraph. If this occurs before the recursion-protection
flag is set, it could even lead to infinite recursion.

In v3, there are still some problems here:

- Patch 12 marks tracing_gen_ctx() and tracing_gen_ctx_flags() notrace,
but arch_local_save_flags() and arch_irqs_disabled_flags() that they
call remain plain static inline on arm, csky, loongarch, mips, and
parisc.
- trace_test_and_set_recursion() reads current_thread_info() before
setting current->trace_recursion, yet current_thread_info() in
arch/microblaze/include/asm/thread_info.h is still plain static inline.
- Patch 14 marks is_kernel_text() notrace for core_kernel_text() (called
by the MIPS function graph tracer), but in_gate_area_no_mm() that it
calls remains plain static inline.

More importantly, there is a structural maintainability problem.
It is impossible to know in advance whether a `static inline` helper
function will actually be inlined or generated as standalone code.
Unlike `noinstr` on x86, there is no compile-time check tool
(such as objtool) detecting - across different architectures -
calls from a function marked `notrace` to a function that is
traceable.

So, I am opposed to making global semantic changes before such tools
are in place.

Thank you,

--
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>