[GIT PULL] ftrace: Updates for v7.4

From: Steven Rostedt

Date: Thu Oct 22 2026 - 15:40:53 EST



Linus,

[
Note, there's a slight conflict with Masami's probes pull request as they
both touch code in kernel/trace/trace_btf.h where one touches a parameter
in a prototype and the other adds a new prototype near that location.
It should be a trivial fix up.
]

ftrace updates for v7.4:

- Have the stacktrace option work with func-args

The func_stack_trace option has it's own ftrace handler and so does the
func-args option. When they are both set, neither would run. The function
tracer itself would error out.

Allow the stacktrace and function args to work together.

- Avoid BTF lookup in atomic context

The ftrace_dump() can call function graph tracing output from an atomic
context (like an NMI watchdog going off). The BTF lookup is not safe to
call from atomic context. Have btf_find_func_proto() return if in atomic
context.

- Build trace_btf.c when CONFIG_DEBUG_INFO_BTF is enabled

New code is depending on trace_btf.c but that only gets built when
BPF_SYSCALL is also enabled. As the new code doesn't depend on that, have
trace_btf.c get built with just DEBUG_INFO_BTF set.

- Have function graph return values have BTF processing

Have the return values printed by the function graph tracer use BTF to
print the values in better format. For example, if it's a char, short,
signed or unsigned, print according to the value defined by BTF.

- Add a "max" field to the function profiler stats

The function profiler shows all the functions run in the kernel, the
number of times they are called, and the total time they took up. Also add
a "max" field which holds the longest time a function ran for.

- Fix memory leak in module with all skipped functions

On module load, the ftrace entries are recorded to keep track of what
functions can be traced or not. Some functions may be skipped for various
reasons (some defined by the architecture). If all functions in the module
are skipped, its data page is not freed and can leak. Catch this case and
free the empty page.

- Allow architectures to reject functions from being traced

Allow architectures to skip a function address by returning zero from
ftrace_call_adjust().

- Initialize modname and offset in print_rec()

The variables modname and offset are initialized by kallsyms_lookup().
If that fails, the values are not set, but the code continues to print
other information. The modname and offset are used later, but if the
kallsyms_lookup() failed, they will not be set.

If a module is being loaded and unloaded at the same time as reading
the available_filter_functions file, it can cause a fault due to the
lookup failing and modname and offset being used uninitialized.


Please pull the latest trace-ftrace-v7.4 tree, which can be found at:


git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace-ftrace-v7.4

Tag SHA1: 653342b1940a468bfb7104867950db0d5c92a5d8
Head SHA1: e1f339ff3b83857b93baf8b88186275a413d445e


Aaron Ahmed (1):
ftrace: Initialize modname and offset in print_rec()

Jose Fernandez (Anthropic) (2):
ftrace: Do not leak a module's empty page group
ftrace: Let ftrace_call_adjust() reject a patch site

Steven Rostedt (1):
ftrace: Have stacktrace option work with func-args

Yun Zhou (1):
ftrace: Add max field to function profiler stats

pengdonglin (4):
tracing: Avoid BTF lookup in atomic context
ftrace: Build trace_btf.c when CONFIG_DEBUG_INFO_BTF is enabled
fgraph: Enhance funcgraph-retval with BTF-based type-aware output
tracing: Update funcgraph-retval documentation

----
Documentation/trace/ftrace.rst | 96 ++++++++++++++++++++++--------------
kernel/trace/Kconfig | 2 +-
kernel/trace/Makefile | 2 +-
kernel/trace/ftrace.c | 32 ++++++++++--
kernel/trace/trace_btf.c | 86 ++++++++++++++++++++++++++++++++
kernel/trace/trace_btf.h | 18 +++++++
kernel/trace/trace_functions.c | 5 +-
kernel/trace/trace_functions_graph.c | 56 ++++++++++++++++-----
8 files changed, 239 insertions(+), 58 deletions(-)
---------------------------