[PATCH v3 0/2] perf inject intel-PT LBR/brstack synthesis fixes
From: Ian Rogers
Date: Mon May 18 2026 - 02:12:50 EST
An intel-pt trace can be turned into LBR events either in perf script
or perf inject with the --itrace=L option. With perf inject the
generated perf.data file failed to be parsed as the sample events were
out of sync with their perf_event_attr. A range of fixes were
required.
This patch was separated from a large perf script refactor that
highlighted the breakage:
https://lore.kernel.org/lkml/20260425224951.174663-1-irogers@xxxxxxxxxx/
v3:
- Add missing Fixes: tags on both commits.
- Refactor perf_event__repipe_attr to avoid in-place modifications on
read-only mmap buffers, preventing SIGSEGV in file mode and premature
evsel updates in pipe mode.
- Use perf_event__synthesize_attr to correctly construct and repipe
attributes in pipe mode.
- Replace manual arithmetic in convert_sample_callchain with
perf_event__sample_event_size to prevent uninitialized memory leaks.
- Retrieve evsel branch_sample_type dynamically in util/arm-spe.c and
util/cs-etm.c instead of hardcoding 0, resolving missing hw_idx field
on synthesized branch stacks.
v2: Response to sashiko fixes for patch 2, Namhyung's acked-by for patch 1.
v1: https://lore.kernel.org/lkml/20260428070328.1880314-1-irogers@xxxxxxxxxx/
Ian Rogers (2):
perf event: Fix size of synthesized sample with branch stacks
perf inject: Fix itrace branch stack synthesis
tools/perf/bench/inject-buildid.c | 9 +-
tools/perf/builtin-inject.c | 141 +++++++++++++++++++++++++----
tools/perf/tests/dlfilter-test.c | 8 +-
tools/perf/tests/sample-parsing.c | 5 +-
tools/perf/util/arm-spe.c | 21 ++++-
tools/perf/util/cs-etm.c | 23 +++--
tools/perf/util/intel-bts.c | 3 +-
tools/perf/util/intel-pt.c | 26 ++++--
tools/perf/util/synthetic-events.c | 25 +++--
tools/perf/util/synthetic-events.h | 6 +-
10 files changed, 216 insertions(+), 51 deletions(-)
--
2.54.0.563.g4f69b47b94-goog