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 05/10] perf ftrace: Support context switch tracking in function graph tracer
Date: Tue, 3 Nov 2026 23:42:53 -0800 [thread overview]
Message-ID: <aurh_Uc9loXXZG0O@z2> (raw)
In-Reply-To: <qavabkz2qznknyttzymkppwz64ho6hvqeooqn4ktsxpw5hq4t3@4jfxdhl6c2mu>
On Sun, Nov 01, 2026 at 07:04:17PM -0500, Aaron Tomlin wrote:
> On Sat, Oct 31, 2026 at 03:01:51PM -0700, Namhyung Kim wrote:
> > On Sun, Oct 25, 2026 at 10:57:30PM -0400, Aaron Tomlin wrote:
[SNIP]
> > > +
> > > + /*
> > > + * Prune frames on existing and ts that exited during subsequent
> > > + * execution recorded on the other state.
> > > + */
> > > + ftrace_task_state__prune_stack(existing, ts);
> > > + ftrace_task_state__prune_stack(ts, existing);
> >
> > I'm not sure about this. In this context, it knows the 'ts' is uptodate
> > and the 'existing' contains the old state. Does it need to prune the ts
> > using the existing?
> >
> > IIUC this code assumes either ts or existing may have uptodate state
> > like in general cases but it would make the code unnecessarily longer.
>
> The reason this handled both directions is due to how trace_pipe merges
> per-CPU buffers when a task starts on CPU 0 (unidentified, tracked in ts
> under FTRACE_UNKNOWN_PID(0)) and migrates to CPU 1:
>
> 1. Task X starts on CPU 0 before any context switch banner is seen on
> CPU 0, so its initial frames are recorded in ts.
>
> 2. Task X migrates to CPU 1. If CPU 1's incoming banner ("1) idle =>
> X") and subsequent function exits are read from trace_pipe before
> CPU 0's outgoing banner ("0) X => idle") is flushed, existing is
> created on CPU 1 first and actually holds the newer state, while
> ts holds the older pre-migration frames from CPU 0.
>
> 3. Conversely, if Task X was already known on CPU 1 (existing) and
> migrated to an unbannered CPU 0 (ts), then ts holds the newer state
> and existing holds the older state.
IIRC we use the global trace pipe so I expect its output in time order.
How can it see CPU 1's sched switch before the CPU 0's? Maybe some time
drifts on each CPU? Anyway, if that happens in practice, yeah then we
can check in both directions.
>
> That said, I agree that maintaining a dynamic per-task watermarks[] array
> for arbitrary multi-hop migrations before the first banner is superfluous.
> Replacing the dynamic watermarks array with a single scalar minimum-indent
> watermark on struct ftrace_task_state makes this much simpler and removes
> ftrace_task_state__record_indent(), ftrace_task_state__min_indent_after(),
> and the watermark merge loop in ftrace_task_state__rekey().
Sounds good, thanks!
Namhyung
next prev parent reply other threads:[~2026-11-04 7:42 UTC|newest]
Thread overview: 27+ 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 " 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-31 7:12 ` Namhyung Kim
2026-10-31 22:29 ` Aaron Tomlin
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 2:57 ` [PATCH perf-tools-next v12 03/10] perf ftrace: Support filtering return address comments Aaron Tomlin
2026-10-26 2:57 ` [PATCH perf-tools-next v12 04/10] perf ftrace: Add basic task call stack management Aaron Tomlin
2026-10-31 7:05 ` Namhyung Kim
2026-10-31 22:27 ` Aaron Tomlin
2026-11-04 7:35 ` Namhyung Kim
2026-11-04 16:10 ` Aaron Tomlin
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-31 22:01 ` Namhyung Kim
2026-11-02 0:04 ` Aaron Tomlin
2026-11-04 7:42 ` Namhyung Kim [this message]
2026-11-04 16:45 ` Aaron Tomlin
2026-10-26 2:57 ` [PATCH perf-tools-next v12 06/10] perf ftrace: Support display of inlined functions " Aaron Tomlin
2026-10-31 7:11 ` Namhyung Kim
2026-11-02 15:22 ` Aaron Tomlin
2026-10-31 23:33 ` Namhyung Kim
2026-11-02 19:20 ` Aaron Tomlin
2026-11-04 7:46 ` Namhyung Kim
2026-11-04 16:48 ` Aaron Tomlin
2026-10-26 2:57 ` [PATCH perf-tools-next v12 07/10] perf symbol: Introduce vmlinux_path__find() helper Aaron Tomlin
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 2:57 ` [PATCH perf-tools-next v12 09/10] perf ftrace: Support omitting execution duration in function graph tracer Aaron Tomlin
2026-10-26 2:57 ` [PATCH perf-tools-next v12 10/10] perf ftrace: Filter extraneous functions " Aaron Tomlin
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=aurh_Uc9loXXZG0O@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
all inboxes | Powered by JetHome®