Skip to content

Commit a347306

Browse files
algrant-armacmel
authored andcommitted
perf intel-pt: 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 Intel PT 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> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org> 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: Leo Yan <leo.yan@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> 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 Link: http://lore.kernel.org/lkml/20200819084751.17686-2-leo.yan@linaro.org Signed-off-by: Leo Yan <leo.yan@linaro.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent f5f8e7e commit a347306

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

tools/perf/util/intel-pt.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3017,8 +3017,15 @@ static int intel_pt_synth_events(struct intel_pt *pt,
30173017

30183018
if (pt->synth_opts.callchain)
30193019
attr.sample_type |= PERF_SAMPLE_CALLCHAIN;
3020-
if (pt->synth_opts.last_branch)
3020+
if (pt->synth_opts.last_branch) {
30213021
attr.sample_type |= PERF_SAMPLE_BRANCH_STACK;
3022+
/*
3023+
* We don't use the hardware index, but the sample generation
3024+
* code uses the new format branch_stack with this field,
3025+
* so the event attributes must indicate that it's present.
3026+
*/
3027+
attr.branch_sample_type |= PERF_SAMPLE_BRANCH_HW_INDEX;
3028+
}
30223029

30233030
if (pt->synth_opts.instructions) {
30243031
attr.config = PERF_COUNT_HW_INSTRUCTIONS;

0 commit comments

Comments
 (0)