Skip to content

Commit 3d918fb

Browse files
ahunter6acmel
authored andcommitted
perf intel-pt: Fix occasional decoding errors when tracing system-wide
In order to successfully decode Intel PT traces, context switch events are needed from the moment the trace starts. Currently that is ensured by using the 'immediate' flag which enables the switch event when it is opened. However, since commit 86c2786 ("perf intel-pt: Add support for PERF_RECORD_SWITCH") that might not always happen. When tracing system-wide the context switch event is added to the tracking event which was not set as 'immediate'. Change that so it is. Signed-off-by: Adrian Hunter <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: [email protected] # v4.4+ Fixes: 86c2786 ("perf intel-pt: Add support for PERF_RECORD_SWITCH") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 9f31569 commit 3d918fb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tools/perf/arch/x86/util/intel-pt.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
501501
struct intel_pt_recording *ptr =
502502
container_of(itr, struct intel_pt_recording, itr);
503503
struct perf_pmu *intel_pt_pmu = ptr->intel_pt_pmu;
504-
bool have_timing_info;
504+
bool have_timing_info, need_immediate = false;
505505
struct perf_evsel *evsel, *intel_pt_evsel = NULL;
506506
const struct cpu_map *cpus = evlist->cpus;
507507
bool privileged = geteuid() == 0 || perf_event_paranoid() < 0;
@@ -655,6 +655,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
655655
ptr->have_sched_switch = 3;
656656
} else {
657657
opts->record_switch_events = true;
658+
need_immediate = true;
658659
if (cpu_wide)
659660
ptr->have_sched_switch = 3;
660661
else
@@ -700,6 +701,9 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
700701
tracking_evsel->attr.freq = 0;
701702
tracking_evsel->attr.sample_period = 1;
702703

704+
if (need_immediate)
705+
tracking_evsel->immediate = true;
706+
703707
/* In per-cpu case, always need the time of mmap events etc */
704708
if (!cpu_map__empty(cpus)) {
705709
perf_evsel__set_sample_bit(tracking_evsel, TIME);

0 commit comments

Comments
 (0)