From: Namhyung Kim <namhyung@kernel.org>
To: Aaron Tomlin <atomlin@atomlin.com>
Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com,
chjohnst@mail.com, neelx@suse.com, sean@ashe.io,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH perf-tools-next v12 06/10] perf ftrace: Support display of inlined functions in function graph tracer
Date: Sat, 31 Oct 2026 00:11:34 -0700 [thread overview]
Message-ID: <auWUpl0toDFpwSYS@z2> (raw)
In-Reply-To: <20261026025735.546101-7-atomlin@atomlin.com>
On Sun, Oct 25, 2026 at 10:57:31PM -0400, Aaron Tomlin wrote:
> The Linux kernel's function graph tracer operates at the machine
> instruction level via compiler instrumentation
> (-fpatchable-function-entry), recording entry and return events for
> physical function calls. Consequently, functions inlined by the compiler
> are invisible in the resulting call graph, as no discrete call or return
> instructions are emitted for them. While technically expected, this
> omission frequently obscures the logical execution flow when analysing
> kernel subsystems heavily reliant upon inlining.
>
> Address this by introducing the --inline option to perf ftrace for the
> function_graph tracer.
>
> When the kernel is configured with CONFIG_FUNCTION_GRAPH_RETADDR=y, the
> funcgraph-retaddr trace option records the caller's return address on
> each function entry, manifested in the trace stream as a comment
> (e.g. /* <-irq_work_queue_on+0x81/0xa0 */). By interrogating DWARF debug
> information from the kernel image (vmlinux) utilising libdw, perf ftrace
> resolves this return address to its inlined callchain and synthesises the
> intermediate inlined frames directly into the streamed call graph.
>
> Key aspects of this implementation:
>
> 1. DWARF inline resolution
>
> Implement ftrace_resolve_inlines() using libdw to locate inlined
> subroutines at the instruction address corresponding to the
> caller's return address.
>
> Implement perf_ftrace__setup_inlines() and
> perf_ftrace__cleanup_inlines() to initialise machine symbol
> tracking, load vmlinux symbols, and verify kernel
> CONFIG_FUNCTION_GRAPH_RETADDR support.
>
> 2. Inline frame synthesis
>
> In ftrace_process_fgraph_line(), when --inline is active:
> - Interrogate return addresses using ftrace_parse_retaddr()
> and resolve inlines via ftrace_resolve_inlines().
>
> - Identify common inlined ancestors on the tracked stack and
> unwind inactive frames.
>
> - Open new inlined frames with /* (inline) */ and indent by
> inlined_depth * 2.
>
> - On function exit, close matching inlined frames with
> } /* func (inline) */.
>
> 3. Command-line options and documentation
>
> Add --inline and -k/--vmlinux options in
> tools/perf/builtin-ftrace.c and document their usage in
> tools/perf/Documentation/perf-ftrace.txt.
>
> Tested-by: Ian Rogers <irogers@google.com>
> Reviewed-by: Ian Rogers <irogers@google.com>
> Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
> ---
[SNIP]
> @@ -664,11 +834,16 @@ static void extract_exit_func_name(const char *str, char *buf, size_t size)
> * @cpu: Pointer to store the CPU number
> *
> * Locate the context columns that precede the function call column of a
> - * function_graph trace record.
> + * function_graph trace record. Depending on the funcgraph-* options set
> + * up by perf, a record looks like:
> + *
> + * [ abstime |] CPU) [ comm-pid |] [ duration |] func
> + *
> + * The abstime and comm-pid columns are only present with --graph-opts
> + * verbose.
> *
> * Return: A pointer to the last character of the context columns (the final
> - * '|' delimiter, or the CPU ')' when no delimiter follows it). Returns NULL
> - * if @line is not a trace record.
> + * '|' delimiter). Returns NULL if @line is not a trace record.
> */
It'd be nice if you could move the comments to the original commit that
introduced the function.
> static const char *find_func_column(const struct perf_ftrace *ftrace,
> const char *line, int *cpu)
[SNIP]
> diff --git a/tools/perf/util/ftrace.h b/tools/perf/util/ftrace.h
> index 45f5090d0115..7b9e0919ae8d 100644
> --- a/tools/perf/util/ftrace.h
> +++ b/tools/perf/util/ftrace.h
> @@ -42,6 +42,8 @@ struct perf_ftrace {
> int graph_verbose;
> int graph_thresh;
> int graph_tail;
> + bool use_inline;
> + struct machine *machine;
> };
>
> struct filter_entry {
> @@ -96,44 +98,18 @@ perf_ftrace__latency_cleanup_bpf(struct perf_ftrace *ftrace __maybe_unused)
>
> #endif /* HAVE_BPF_SKEL */
>
> -#define FTRACE_MAX_CPUS 4096
> -#define FTRACE_MAX_STACK 256
> -#define FTRACE_PID_HASH_BITS 10
> -#define FTRACE_PID_HASH_SIZE (1 << FTRACE_PID_HASH_BITS)
> +struct machine;
>
> -#define FTRACE_IDLE_PID(cpu) ((pid_t)(-1 - (cpu)))
> -#define FTRACE_UNKNOWN_PID(cpu) ((pid_t)(-1 - FTRACE_MAX_CPUS - (cpu)))
> -
> -struct ftrace_stack_frame {
> - char *name;
> - bool inlined;
> - int indent;
> - int raw_indent;
> - u64 seq;
> -};
> -
> -struct ftrace_indent_watermark {
> - u64 seq;
> - int raw_indent;
> -};
> -
> -struct ftrace_task_state {
> - struct hlist_node node;
> - pid_t pid;
> - struct ftrace_stack_frame *stack;
> - int max_stack;
> - int depth;
> - int inlined_depth;
> - int overflow_depth;
> - u64 seq;
> - struct ftrace_indent_watermark *watermarks;
> - int max_watermarks;
> - int nr_watermarks;
> -};
Hmm.. probably better to define the structs in the .c file in the first
place?
Thanks,
Namhyung
> +#define FTRACE_MAX_INLINES 32
>
> bool ftrace_parse_retaddr(const char *str, char *sym_name, size_t sym_len, u64 *offset);
> void ftrace_filter_retaddr(char *str);
> -void ftrace_cpu_states__clear(void);
> +int ftrace_resolve_inlines(struct machine *machine,
> + const char *sym_name, u64 offset,
> + const char **inlined_names, int max_inlines);
> int ftrace_process_fgraph_line(struct perf_ftrace *ftrace, const char *line, FILE *out);
> +void ftrace_cpu_states__clear(void);
> +int perf_ftrace__setup_inlines(struct perf_ftrace *ftrace);
> +void perf_ftrace__cleanup_inlines(struct perf_ftrace *ftrace);
>
> #endif /* __PERF_FTRACE_H__ */
> --
> 2.55.0
>
next prev parent reply other threads:[~2026-10-31 7:11 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 2:57 [PATCH perf-tools-next v12 00/10] perf ftrace: Support inlined functions and display enhancements in function graph tracer Aaron Tomlin
2026-10-26 2:57 ` [PATCH perf-tools-next v12 01/10] perf ftrace: Handle signals, non-blocking reads and pager exits in __cmd_ftrace() Aaron Tomlin
2026-10-26 9:23 ` sashiko-bot
2026-10-31 7:12 ` Namhyung Kim
2026-10-26 2:57 ` [PATCH perf-tools-next v12 02/10] perf ftrace: Optimise __cmd_ftrace() stack frame with strbuf streaming Aaron Tomlin
2026-10-26 9:27 ` sashiko-bot
2026-10-26 2:57 ` [PATCH perf-tools-next v12 03/10] perf ftrace: Support filtering return address comments Aaron Tomlin
2026-10-26 9:33 ` sashiko-bot
2026-10-26 2:57 ` [PATCH perf-tools-next v12 04/10] perf ftrace: Add basic task call stack management Aaron Tomlin
2026-10-26 9:37 ` sashiko-bot
2026-10-31 7:05 ` Namhyung Kim
2026-10-26 2:57 ` [PATCH perf-tools-next v12 05/10] perf ftrace: Support context switch tracking in function graph tracer Aaron Tomlin
2026-10-26 9:45 ` sashiko-bot
2026-10-26 2:57 ` [PATCH perf-tools-next v12 06/10] perf ftrace: Support display of inlined functions " Aaron Tomlin
2026-10-26 9:55 ` sashiko-bot
2026-10-31 7:11 ` Namhyung Kim [this message]
2026-10-26 2:57 ` [PATCH perf-tools-next v12 07/10] perf symbol: Introduce vmlinux_path__find() helper Aaron Tomlin
2026-10-26 10:04 ` sashiko-bot
2026-10-26 2:57 ` [PATCH perf-tools-next v12 08/10] perf test: Add test for ftrace inline and task stack tracking Aaron Tomlin
2026-10-26 10:09 ` sashiko-bot
2026-10-26 2:57 ` [PATCH perf-tools-next v12 09/10] perf ftrace: Support omitting execution duration in function graph tracer Aaron Tomlin
2026-10-26 10:15 ` sashiko-bot
2026-10-26 2:57 ` [PATCH perf-tools-next v12 10/10] perf ftrace: Filter extraneous functions " Aaron Tomlin
2026-10-26 10:30 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=auWUpl0toDFpwSYS@z2 \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=atomlin@atomlin.com \
--cc=chjohnst@mail.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=neelx@suse.com \
--cc=peterz@infradead.org \
--cc=sean@ashe.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox