freenode
Kernel & Low-Level

Kernel series would let ftrace and BPF see non-inlined helpers

Song Liu wants notrace only on functions that must stay untraced, not on every function marked inline.

Song Liu has proposed dropping a long-standing rule that makes every function marked inline untraceable. When the compiler leaves such a function out of line, that copy cannot be seen by ftrace, cannot be a BPF fentry or fexit target, and cannot be livepatched, because livepatch redirects functions through ftrace. A fix for one of those copies has to be shipped by patching its callers instead.

The rule dates to a change that told ftrace not to trace inlined functions. Inline was then only a hint, and whether a helper received a tracing call depended on the compiler. Some code that must not be traced, including paravirtualization helpers, was marked inline and relied on actually being inlined. Making every inline function notrace removed that gamble. Liu wrote that the trade-off no longer makes sense: the compiler now inlines unmarked static functions and creates specialized clones, so which functions are traceable already depends on the compiler. notrace on inline, he wrote, "only hides the inline functions that the compiler chose not to inline."

The series does not simply flip the switch. It first marks notrace on helpers that would be unsafe to trace: paravirtualization, resume, and kexec paths; BPF spin-lock, trampoline, and allocator helpers, where an fentry program could deadlock, recurse, or corrupt free lists; ftrace's own recursion protection; and code that runs while RCU is not watching, including exception entry and architecture helpers on arm64, powerpc, and RISC-V. Functions marked always-inline, mostly low-level helpers, stay untraced. Liu said the explicit marks do not change generated code on x86_64, arm64, powerpc, and RISC-V while the old rule is still in force. He found the candidates by comparing builds and listing newly traceable functions called from code that itself has no tracing call, including a build that disabled inlining so helpers the compiler happens to inline today were not missed.

Automated review on the list then asked whether that audit is complete. Comments pointed at possible remaining recursion or deadlock paths, including Microblaze's thread-info accessor on the way to the preemption count, arm64 stack unwinding from no-instrumentation code, Tiny SRCU helpers used by tracepoints, and some BPF spin-lock callees that are already out of line. Those are open questions, not confirmed defects, and the series has not landed.