Skip to content

Commit f5f8e7e

Browse files
algrant-armacmel
authored andcommitted
perf cs-etm: Fix corrupt data after perf inject from
Commit 42bbabe ("perf tools: Add hw_idx in struct branch_stack") changed the format of branch stacks in perf samples. When samples use this new format, a flag must be set in the corresponding event. Synthesized branch stacks generated from CoreSight ETM trace were using the new format, but not setting the event attribute, leading to consumers seeing corrupt data. This patch fixes the issue by setting the event attribute to indicate use of the new format. Fixes: 42bbabe ("perf tools: Add hw_idx in struct branch_stack") Signed-off-by: Al Grant <al.grant@arm.com> Reviewed-by: Andrea Brunato <andrea.brunato@arm.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Poirier <mathieu.poirier@linaro.org> Cc: Mike Leach <mike.leach@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Suzuki Poulouse <suzuki.poulose@arm.com> Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Leo Yan <leo.yan@linaro.org> Link: http://lore.kernel.org/lkml/20200819084751.17686-1-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent d4ccbac commit f5f8e7e

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

tools/perf/util/cs-etm.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1344,8 +1344,15 @@ static int cs_etm__synth_events(struct cs_etm_auxtrace *etm,
13441344
attr.sample_type &= ~(u64)PERF_SAMPLE_ADDR;
13451345
}
13461346

1347-
if (etm->synth_opts.last_branch)
1347+
if (etm->synth_opts.last_branch) {
13481348
attr.sample_type |= PERF_SAMPLE_BRANCH_STACK;
1349+
/*
1350+
* We don't use the hardware index, but the sample generation
1351+
* code uses the new format branch_stack with this field,
1352+
* so the event attributes must indicate that it's present.
1353+
*/
1354+
attr.branch_sample_type |= PERF_SAMPLE_BRANCH_HW_INDEX;
1355+
}
13491356

13501357
if (etm->synth_opts.instructions) {
13511358
attr.config = PERF_COUNT_HW_INSTRUCTIONS;

0 commit comments

Comments
 (0)