linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Ayupov <aaupov@fb.com>
To: <linux-perf-users@vger.kernel.org>, <coresight@lists.linaro.org>,
	<linux-arm-kernel@lists.infradead.org>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	James Clark <james.clark@linaro.org>, Leo Yan <leo.yan@arm.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	John Garry <john.g.garry@oracle.com>,
	Will Deacon <will@kernel.org>
Cc: <linux-doc@vger.kernel.org>, Mike Leach <mike.leach@arm.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Swapnil Sapkal <swapnil.sapkal@amd.com>
Subject: [PATCH v2 0/5] perf: Add CoreSight branch history to existing samples
Date: Mon, 17 Aug 2026 15:22:15 -0700	[thread overview]
Message-ID: <cover.1787005265.git.aaupov@fb.com> (raw)

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


             reply	other threads:[~2026-08-17 22:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-17 22:22 Amir Ayupov [this message]
2026-08-17 22:22 ` [PATCH v2 1/5] perf dlfilter: Add non-empty branch stack filter Amir Ayupov
2026-08-17 22:22 ` [PATCH v2 2/5] perf cs-etm: Split up cs_etm__process_timestamped_queues() Amir Ayupov
2026-08-17 22:22 ` [PATCH v2 3/5] perf cs-etm: Add branch history to existing samples Amir Ayupov
2026-08-17 22:22 ` [PATCH v2 4/5] perf test cs-etm: Test branch history on " Amir Ayupov
2026-08-17 22:22 ` [PATCH v2 5/5] Documentation: coresight: Document context-sensitive PGO workflow Amir Ayupov

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=cover.1787005265.git.aaupov@fb.com \
    --to=aaupov@fb.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=corbet@lwn.net \
    --cc=coresight@lists.linaro.org \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=john.g.garry@oracle.com \
    --cc=jolsa@kernel.org \
    --cc=leo.yan@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mike.leach@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=skhan@linuxfoundation.org \
    --cc=suzuki.poulose@arm.com \
    --cc=swapnil.sapkal@amd.com \
    --cc=will@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).