Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Aaron Tomlin" <atomlin@atomlin.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH perf-tools-next v13 09/10] perf ftrace: Support omitting execution duration in function graph tracer
Date: Mon, 02 Nov 2026 21:54:44 +0000	[thread overview]
Message-ID: <sashiko-outbox-194241@kernel.org> (raw)
In-Reply-To: <20261102214054.911298-10-atomlin@atomlin.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] perf tests ftrace: tautological stack check and leak in test_column_layouts()
- [Low] perf tests ftrace: leak of out_buf on error return in test_column_layouts()
--

commit ef1b99782fcc250d9ee67d7316134fcbad8982cb
Author: Aaron Tomlin <atomlin@atomlin.com>

perf ftrace: Support omitting execution duration in function graph tracer

This commit adds the noduration sub-option to --graph-opts in perf ftrace
to omit function execution duration from function_graph tracer output by
setting the kernel's funcgraph-duration tracing option to 0. It also
updates the inline decoder and tests to handle trace lines without the
duration column and rejects combining noduration with the profile
subcommand.

> diff --git a/tools/perf/tests/ftrace.c b/tools/perf/tests/ftrace.c
> index 900f5390141ff..ec3c26a01ef94 100644
> --- a/tools/perf/tests/ftrace.c
> +++ b/tools/perf/tests/ftrace.c

[ ... ]

> @@ -875,6 +951,28 @@ static int test_column_layouts(void)
>  		out_buf = NULL;
>  	}
>  
> +	/* Test noduration IRQ markers do not pop active frames from tracked stack */
> +	memset(&ftrace, 0, sizeof(ftrace));
> +	ftrace.use_inline = true;
> +	ftrace.graph_noduration = true;
> +	ftrace_cpu_states__clear();
> +
> +	out = open_memstream(&out_buf, &out_len);
> +	if (!out)
> +		return TEST_FAIL;
> +
> +	ftrace_process_fgraph_line(&ftrace, " 0)  root_func() {", out);
> +	ftrace_process_fgraph_line(&ftrace, " 0) ==========>", out);
> +	ftrace_process_fgraph_line(&ftrace, " 0) <==========", out);
> +	ftrace_process_fgraph_line(&ftrace, " 0)  } /* root_func */", out);
> +
> +	fclose(out);
> +	ftrace_cpu_states__clear();
> +
> +	TEST_ASSERT_VAL("noduration irq markers preserved stack",
> +			strstr(out_buf, " 0)  } /* root_func */\n") != NULL);

[Severity: Low]
Can this check in test_column_layouts() actually detect whether the
interrupt markers popped root_func from ts->stack?

Because ftrace is zero-initialized with no machine set and no inlined
frames are pushed onto ts->stack, ftrace_task_state__inlined_depth(ts) is
0. When ftrace_process_fgraph_line() processes the exit line for
root_func, extra_indent evaluates to 0 whether match_idx is found on
ts->stack or not:

tools/perf/util/ftrace.c:ftrace_process_fgraph_line() {
	...
		if (match_idx >= 0) {
			...
			extra_indent = ftrace_task_state__inlined_depth(ts) * 2;
		} else {
			extra_indent = 0;
		}

		fprintf(out, "%.*s%*s%s\n",
			(int)(pipe_char - line + 1), line,
			leading_spaces + extra_indent, "", func_start);
	...
}

As a result, the output line " 0)  } /* root_func */\n" is emitted
identically even if ts->stack was cleared by the interrupt markers.

> +	free(out_buf);

[Severity: Low]
Does test_column_layouts() leak out_buf if the assertion above fails?

open_memstream(&out_buf, &out_len) allocates out_buf on the heap, and if
the assertion condition evaluates to false, the macro returns immediately
before reaching free(out_buf), unlike the earlier loop in
test_column_layouts() which frees out_buf before returning.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261102214054.911298-1-atomlin@atomlin.com?part=9

  reply	other threads:[~2026-11-02 21:54 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02 21:40 [PATCH perf-tools-next v13 00/10] perf ftrace: Support inlined functions and display enhancements in function graph tracer Aaron Tomlin
2026-11-02 21:40 ` [PATCH perf-tools-next v13 01/10] perf ftrace: Handle signals, non-blocking reads and pager exits in __cmd_ftrace() Aaron Tomlin
2026-11-02 21:46   ` sashiko-bot
2026-11-02 21:40 ` [PATCH perf-tools-next v13 02/10] perf ftrace: Optimise __cmd_ftrace() stack frame with strbuf streaming Aaron Tomlin
2026-11-02 21:51   ` sashiko-bot
2026-11-02 21:40 ` [PATCH perf-tools-next v13 03/10] perf ftrace: Support filtering return address comments Aaron Tomlin
2026-11-02 21:46   ` sashiko-bot
2026-11-02 21:40 ` [PATCH perf-tools-next v13 04/10] perf ftrace: Add basic task call stack management Aaron Tomlin
2026-11-02 21:52   ` sashiko-bot
2026-11-02 21:40 ` [PATCH perf-tools-next v13 05/10] perf ftrace: Support context switch tracking in function graph tracer Aaron Tomlin
2026-11-02 21:55   ` sashiko-bot
2026-11-02 21:40 ` [PATCH perf-tools-next v13 06/10] perf ftrace: Support display of inlined functions " Aaron Tomlin
2026-11-02 22:05   ` sashiko-bot
2026-11-02 21:40 ` [PATCH perf-tools-next v13 07/10] perf symbol: Introduce vmlinux_path__find() helper Aaron Tomlin
2026-11-02 21:53   ` sashiko-bot
2026-11-02 21:40 ` [PATCH perf-tools-next v13 08/10] perf test: Add test for ftrace inline and task stack tracking Aaron Tomlin
2026-11-02 21:50   ` sashiko-bot
2026-11-02 21:40 ` [PATCH perf-tools-next v13 09/10] perf ftrace: Support omitting execution duration in function graph tracer Aaron Tomlin
2026-11-02 21:54   ` sashiko-bot [this message]
2026-11-02 21:40 ` [PATCH perf-tools-next v13 10/10] perf ftrace: Filter extraneous functions " Aaron Tomlin
2026-11-02 22:11   ` 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=sashiko-outbox-194241@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