On Wed, 2 Dec 2026 11:12:09 -0800 Song Liu <[email protected]> wrote: > Hi Masami, > > Thanks for your review! > > On Wed, Dec 2, 2026 at 6:49 AM Masami Hiramatsu (Google) > <[email protected]> wrote: > [...] > > > > 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). > > Hmm.. Do we really have the protection today? For example, on x86, > __switch_to is marked with __notrace_funcgraph. But __switch_to > calls switch_to_extra, which calls __switch_to_xtra, and __switch_to_xtra > is actually traceable. Is this a problem? > > > 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. > > To clarify, the motivation is not to trace functions marked with > "inline". We observed the issue when we want to livepatch a > function marked with "inline". If the function is actually inlined > by the compiler, we will livepatch the callers of it, which works > as-is. However, if the compiler decides not to inline this function, > we need extra work for the livepatch (basically apply a bunch of > s/inline/__always_inline/). This is not too difficult or too much > work. However, I still don't think "inline" means "if not inlined, > still not traceable/livepatchable".
Well, the compiler can inline some (but not all) calls to a static function and also inline calls to a non-static function. So unless you force everything either noinline or always_inline you'll always get multiple copies. Not to mention the 'constprop' alternatives it can generate when one argument is constant. David > > Thanks, > Song >
