From: Leo Yan <leo.yan@arm.com>
To: Suzuki K Poulose <suzuki.poulose@arm.com>,
Mike Leach <mike.leach@arm.com>,
James Clark <james.clark@linaro.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Tamas Petz <tamas.petz@arm.com>,
Tamas Zsoldos <tamas.zsoldos@arm.com>,
Suyash Mahar <smahar@meta.com>, Amir Ayupov <aaupov@fb.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, coresight@lists.linaro.org,
Leo Yan <leo.yan@arm.com>
Subject: [PATCH v2 10/11] perf cs-etm: Reset decoder on AUX offset discontinuity
Date: Fri, 16 Oct 2026 22:11:48 +0100 [thread overview]
Message-ID: <20261016-trbe_buffer_refactor_v2-v2-10-383ac26382fa@arm.com> (raw)
In-Reply-To: <20261016-trbe_buffer_refactor_v2-v2-0-383ac26382fa@arm.com>
Indexed AUX fragments do not necessarily form a contiguous trace stream.
Snapshot reads can retain only the end of the AUX buffer and advance past
the omitted prefix. AUX metadata records can also be lost when the normal
perf ring buffer is full, leaving the corresponding trace unqueued. Neither
case guarantees that the next queued fragment carries a collision flag or
retains the source's restart synchronization packets.
Track the expected next logical AUX offset for each decoder queue in
cs_etm__get_trace(). Request a decoder reset before processing a fragment
whose offset differs from the expected end. This prevents decoding bytes
after a gap using stale packet and execution state. The comparison also
covers overlapping fragments and backward offsets.
Perf can internally split large buffers into consecutive pieces while
retaining the original AUX offset. Preserve continuity across those pieces
and accumulate their sizes when tracking the expected end. Keep the decoder
byte index separate from the logical AUX offset. Track initialization
separately, as zero is a valid expected offset after the counter wraps.
Zero-length fragments still carry logical offsets. Check them for gaps
and retain any reset request until nonempty data is decoded.
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
tools/perf/util/cs-etm.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index 8f04d7ceddd9d1f7ff22af234b19400efe27ba2b..37ae7ff5149433ed27cb3c9b880e8422d742a74d 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -123,6 +123,9 @@ struct cs_etm_queue {
u8 pending_timestamp_chan_id;
enum cs_etm_format format;
u64 offset;
+ /* Expected logical AUX offset after the last fetched buffer. */
+ u64 next_aux_offset;
+ bool have_aux_offset;
const unsigned char *buf;
size_t buf_len, buf_used;
/* Conversion between traceID and index in traceid_queues array */
@@ -1496,6 +1499,21 @@ cs_etm__get_trace(struct cs_etm_queue *etmq)
old_buffer->cpu.cpu != aux_buffer->cpu.cpu))
etmq->reset_decoder = true;
+ /*
+ * Snapshot clipping or missing AUX records can leave a gap between
+ * fragments. Check logical AUX offsets, as etmq->offset only counts
+ * bytes submitted to the decoder. Internally split buffers retain
+ * the original offset and mark subsequent pieces as consecutive.
+ */
+ if (etmq->have_aux_offset && !aux_buffer->consecutive &&
+ aux_buffer->offset != etmq->next_aux_offset)
+ etmq->reset_decoder = true;
+
+ if (!etmq->have_aux_offset || !aux_buffer->consecutive)
+ etmq->next_aux_offset = aux_buffer->offset;
+ etmq->next_aux_offset += aux_buffer->size;
+ etmq->have_aux_offset = true;
+
return 0;
}
--
2.34.1
next prev parent reply other threads:[~2026-10-16 21:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 21:11 [PATCH v2 00/11] coresight: trbe: Refactor buffer handling and add trigger support Leo Yan
2026-10-16 21:11 ` [PATCH v2 01/11] coresight: trbe: Remove misleading comment Leo Yan
2026-10-16 21:11 ` [PATCH v2 02/11] coresight: trbe: Refactor next buffer computation Leo Yan
2026-10-16 21:11 ` [PATCH v2 03/11] coresight: trbe: Track trigger count support per CPU Leo Yan
2026-10-16 21:11 ` [PATCH v2 04/11] coresight: trbe: Use trigger mode for buffer maintenance Leo Yan
2026-10-16 21:11 ` [PATCH v2 05/11] coresight: trbe: Leave headroom for stop-on-trigger mode Leo Yan
2026-10-16 21:11 ` [PATCH v2 06/11] coresight: trbe: Save and restore trigger counter Leo Yan
2026-10-16 21:11 ` [PATCH v2 07/11] coresight: trbe: Add KUnit tests for compute normal buffer Leo Yan
2026-10-16 21:11 ` [PATCH v2 08/11] perf cs-etm: Reset decoder on COLLISION flag Leo Yan
2026-10-16 21:11 ` [PATCH v2 09/11] perf cs-etm: Reset per-thread decoder on CPU migration Leo Yan
2026-10-16 21:11 ` Leo Yan [this message]
2026-10-16 21:11 ` [PATCH v2 11/11] perf cs-etm: Set watermark for AUX trace Leo Yan
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=20261016-trbe_buffer_refactor_v2-v2-10-383ac26382fa@arm.com \
--to=leo.yan@arm.com \
--cc=aaupov@fb.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=anshuman.khandual@arm.com \
--cc=coresight@lists.linaro.org \
--cc=james.clark@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.leach@arm.com \
--cc=smahar@meta.com \
--cc=suzuki.poulose@arm.com \
--cc=tamas.petz@arm.com \
--cc=tamas.zsoldos@arm.com \
/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