[PATCH v2 0/5] perf: Add CoreSight branch history to existing samples
Amir Ayupov <[email protected]>
| Newsgroups | org.kernel.vger.linux-perf-users,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-doc |
|---|---|
| Message-ID | <[email protected]> |
CoreSight ETM can synthesize branch samples from an instruction trace, but
context-sensitive PGO needs the branch history leading to an existing PMU
sample together with that sample's event identity and callchain. This series
implements that mode as --itrace=L, following the corresponding Intel PT
behavior.
The series first separates timestamped queue setup and teardown from the ETM
decode loop so decoding can stop at an existing sample's timestamp. It then
reconstructs branch history in the thread stack and attaches it to eligible
samples without replacing their IP, event, or callchain. The attached history
is consumed after use so a later sample cannot reuse an earlier trace window.
This enables a context-sensitive PGO workflow where a cycles event supplies a
frame-pointer callchain while duty-cycled ETM supplies the path leading to the
sample. A dlfilter removes samples for which no ETM history was available, and
the documentation describes the complete recording and decoding workflow.
Changes since v1:
- Rebased onto perf-tools-next at d17c5b770972.
- Dropped the HEADER_GROUP_DESC reader workaround. The issue is in the writer
and should be fixed separately.
- Dropped the branch-stack hw_idx patch after review established that zero is
appropriate for age-ordered CoreSight branch stacks.
- Dropped the local wrapped branch-stack copy fix in favor of upstream commit
ab9c84d1cd59 ("perf thread-stack: Fix heap buffer overflow on branch stack
wrap copy").
- Added James Clark's Reviewed-by tag to the dlfilter patch.
- Consume branch history after attaching it so samples with no newly decoded
trace cannot reuse a window from before an untraced AUX pause interval.
- Flush all trace-ID frontend thread stacks when their physical ETM queue is
exhausted, preventing stale history from surviving a trace gap.
- Check every matching CoreSight event when deciding whether kernel trace is
enabled.
- Reworked the shell test to use FIFO recording control, removed the invalid
bare timestamp option, reduced the workload to 10000 iterations, and check
proc1 and proc2 callchains independently with bounded failure diagnostics.
- Renamed decoded test outputs to script-L4 and script-L64.
Amir Ayupov (5):
perf dlfilter: Add non-empty branch stack filter
perf cs-etm: Split up cs_etm__process_timestamped_queues()
perf cs-etm: Add branch history to existing samples
perf test cs-etm: Test branch history on existing samples
Documentation: coresight: Document context-sensitive PGO workflow
.../trace/coresight/coresight-perf.rst | 62 +++++
tools/perf/Makefile.perf | 1 +
.../dlfilters/dlfilter-nonempty-brstack.c | 26 ++
.../tests/shell/coresight/add_last_branch.sh | 203 ++++++++++++++
tools/perf/util/cs-etm.c | 252 ++++++++++++++++--
tools/perf/util/thread-stack.c | 17 ++
tools/perf/util/thread-stack.h | 1 +
7 files changed, 546 insertions(+), 16 deletions(-)
create mode 100644 tools/perf/dlfilters/dlfilter-nonempty-brstack.c
create mode 100755 tools/perf/tests/shell/coresight/add_last_branch.sh
base-commit: d17c5b770972854a4fe4cf5cc22e17eb21cdc787
--
2.52.0