From: sashiko-bot@kernel.org
To: "Leo Yan" <leo.yan@arm.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v11 6/9] perf cs-etm: Flush thread stacks after decoder reset
Date: Thu, 02 Jul 2026 20:06:33 +0000 [thread overview]
Message-ID: <20260702200634.10AE51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260702-b4-arm_cs_callchain_support_v1-v11-6-846abbf600d7@arm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] cs_etm__flush_all_stack() explicitly skips flushing thread stacks when the trace PID format is CS_ETM_PIDFMT_NONE.
- [Medium] Globally flushing all thread stacks on a per-queue decoder reset indiscriminately destroys valid callchains for unrelated threads on other CPUs.
--
commit 2fc83ea7678b445a0b66d5aa7740246139b71821
Author: Leo Yan <leo.yan@arm.com>
perf cs-etm: Flush thread stacks after decoder reset
Perf resets the CoreSight decoder when moving to a new AUX trace buffer,
causing global trace discontinuity. This patch flushes all host (and
guest) thread stacks after a decoder reset to prevent stale call/return
histories from being attached to threads that are decoded later.
> diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
> index ba9ffb7bdb4bd..996317687ce7b 100644
> --- a/tools/perf/util/cs-etm.c
> +++ b/tools/perf/util/cs-etm.c
[ ... ]
> +static int cs_etm__flush_stack_cb(struct thread *thread,
> + void *data __maybe_unused)
> +{
> + thread_stack__flush(thread);
> + return 0;
> +}
> +
> +static void cs_etm__flush_machine_stack(struct cs_etm_queue *etmq, pid_t pid)
> +{
> + struct machine *machine;
> +
> + machine = machines__find(&etmq->etm->session->machines, pid);
> + if (machine)
> + machine__for_each_thread(machine, cs_etm__flush_stack_cb, NULL);
[Severity: Medium]
Does this globally flush the stacks for all threads in the machine, even
those executing on other CPUs?
Since the decoder reset triggered in cs_etm__get_data_block() happens
per-queue (per-CPU) when it hits a buffer discontinuity, wiping the stack
for all threads indiscriminately might destroy the valid, continuous branch
stacks of threads executing on unrelated CPUs.
Should this flush be limited only to the threads actively traced by the
queue undergoing the reset?
> +}
> +
> +static void cs_etm__flush_all_stack(struct cs_etm_queue *etmq)
> +{
> + enum cs_etm_pid_fmt pid_fmt = cs_etm__get_pid_fmt(etmq);
> +
> + if (!etmq->etm->synth_opts.last_branch)
> + return;
> +
> + switch (pid_fmt) {
> + case CS_ETM_PIDFMT_CTXTID2:
> + /* Clear the guest stack if virtualization is supported */
> + cs_etm__flush_machine_stack(etmq, DEFAULT_GUEST_KERNEL_ID);
> + fallthrough;
> + case CS_ETM_PIDFMT_CTXTID:
> + cs_etm__flush_machine_stack(etmq, HOST_KERNEL_ID);
> + break;
> + case CS_ETM_PIDFMT_NONE:
> + default:
> + break;
[Severity: Medium]
When tracing without hardware context IDs or in per-thread mode, pid_fmt
evaluates to CS_ETM_PIDFMT_NONE.
By explicitly breaking here, doesn't this skip the flush entirely for these
traces? It seems this would leave the stale call and return histories intact
for those workloads, skipping the exact fix this patch intends to apply.
> +
> + }
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260702-b4-arm_cs_callchain_support_v1-v11-0-846abbf600d7@arm.com?part=6
next prev parent reply other threads:[~2026-07-02 20:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 19:51 [PATCH v11 0/9] perf cs-etm: Support thread stack and callchain Leo Yan
2026-07-02 19:51 ` [PATCH v11 1/9] perf cs-etm: Fix thread leaks on trace queue init failure Leo Yan
2026-07-02 20:07 ` sashiko-bot
2026-07-02 19:51 ` [PATCH v11 2/9] perf cs-etm: Filter synthesized branch samples Leo Yan
2026-07-02 19:51 ` [PATCH v11 3/9] perf cs-etm: Decode ETE exception packets Leo Yan
2026-07-02 19:51 ` [PATCH v11 4/9] perf cs-etm: Refactor instruction size handling Leo Yan
2026-07-02 19:51 ` [PATCH v11 5/9] perf cs-etm: Use thread-stack for last branch entries Leo Yan
2026-07-02 20:07 ` sashiko-bot
2026-07-02 19:51 ` [PATCH v11 6/9] perf cs-etm: Flush thread stacks after decoder reset Leo Yan
2026-07-02 20:06 ` sashiko-bot [this message]
2026-07-02 19:51 ` [PATCH v11 7/9] perf cs-etm: Support call indentation Leo Yan
2026-07-02 20:11 ` sashiko-bot
2026-07-02 19:51 ` [PATCH v11 8/9] perf cs-etm: Synthesize callchains for instruction samples Leo Yan
2026-07-02 20:07 ` sashiko-bot
2026-07-02 19:51 ` [PATCH v11 9/9] perf test: Add Arm CoreSight callchain test Leo Yan
2026-07-04 16:11 ` [PATCH v11 0/9] perf cs-etm: Support thread stack and callchain Namhyung Kim
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=20260702200634.10AE51F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=leo.yan@arm.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