From: sashiko-bot@kernel.org
To: "Aaron Tomlin" <atomlin@atomlin.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH perf-tools-next v3 5/5] perf ftrace: Filter extraneous functions in function graph tracer
Date: Mon, 12 Oct 2026 00:37:54 +0000 [thread overview]
Message-ID: <sashiko-outbox-167526@kernel.org> (raw)
In-Reply-To: <20261012003016.263063-6-atomlin@atomlin.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] perf ftrace: Target filter state leaks for leaf functions at non-zero depth
--
commit 1481567e7a5dda207ce5b61e39c1b59803ca97c4
Author: Aaron Tomlin <atomlin@atomlin.com>
perf ftrace: Filter extraneous functions in function graph tracer
This commit enhances perf ftrace to filter out extraneous top-level functions
and detached orphan calls from the function graph output when using a target
filter.
> diff --git a/tools/perf/util/ftrace.c b/tools/perf/util/ftrace.c
> index 5cae01a28529f..96a41077dccbf 100644
> --- a/tools/perf/util/ftrace.c
> +++ b/tools/perf/util/ftrace.c
[ ... ]
> @@ -509,6 +564,92 @@ int ftrace_process_fgraph_line(struct perf_ftrace *ftrace, const char *line, FIL
> has_open_brace = (strchr(func_start, '{') != NULL);
> has_semicolon = (strchr(func_start, ';') != NULL);
>
[ ... ]
> + print_line(ftrace, line, out);
> + if (has_filter && cs->in_target && cs->depth == 0 &&
> + has_semicolon && !has_open_brace) {
> + cs->in_target = false;
> + cs->orphan_depth = 0;
> + }
> + return 0;
> + }
[Severity: Medium]
When a targeted function is a leaf call (no braces, only a semicolon) and
occurs at a call stack depth greater than 0, doesn't the hardcoded check for
cs->depth == 0 prevent the filter state from resetting?
It appears that cs->in_target will remain true indefinitely if the target is
not at the root depth, causing subsequent non-targeted sibling functions and
their descendants within the same parent frame to bypass the filter and
incorrectly appear in the trace output.
[ ... ]
> @@ -645,6 +801,12 @@ int ftrace_process_fgraph_line(struct perf_ftrace *ftrace, const char *line, FIL
> }
> }
>
> + if (has_filter && cs->in_target && cs->depth == 0 &&
> + has_semicolon && !has_open_brace) {
> + cs->in_target = false;
> + cs->orphan_depth = 0;
> + }
> +
> for (i = 0; i < num_inlines; i++)
> free((void *)inlined_names[i]);
> return 0;
[Severity: Medium]
The identical logic exists here for the use_inline code path. Should these
checks verify cs->depth == cs->target_root_depth instead of cs->depth == 0
to properly reset the filter for leaf targets at non-zero depths?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261012003016.263063-1-atomlin@atomlin.com?part=5
prev parent reply other threads:[~2026-10-12 0:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 0:30 [PATCH perf-tools-next v3 0/5] perf ftrace: Support inlined functions and display enhancements in function graph tracer Aaron Tomlin
2026-10-12 0:30 ` [PATCH perf-tools-next v3 1/5] perf ftrace: Optimise __cmd_ftrace() stack frame with strbuf streaming Aaron Tomlin
2026-10-12 0:41 ` sashiko-bot
2026-10-12 0:30 ` [PATCH perf-tools-next v3 2/5] perf ftrace: Support filtering return address comments Aaron Tomlin
2026-10-12 0:38 ` sashiko-bot
2026-10-12 0:30 ` [PATCH perf-tools-next v3 3/5] perf ftrace: Support display of inlined functions in function graph tracer Aaron Tomlin
2026-10-12 0:43 ` sashiko-bot
2026-10-12 0:30 ` [PATCH perf-tools-next v3 4/5] perf ftrace: Support omitting execution duration " Aaron Tomlin
2026-10-12 0:39 ` sashiko-bot
2026-10-12 0:30 ` [PATCH perf-tools-next v3 5/5] perf ftrace: Filter extraneous functions " Aaron Tomlin
2026-10-12 0:37 ` sashiko-bot [this message]
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=sashiko-outbox-167526@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=atomlin@atomlin.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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