Skip to content

Commit c4735d9

Browse files
Jin Yaoacmel
authored andcommitted
perf evsel: Don't set sample_regs_intr/sample_regs_user for dummy event
Since commit 0a892c1 ("perf record: Add dummy event during system wide synthesis"), a dummy event is added to capture mmaps. But if we run perf-record as, # perf record -e cycles:p -IXMM0 -a -- sleep 1 Error: dummy:HG: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat' The issue is, if we enable the extended regs (-IXMM0), but the pmu->capabilities is not set with PERF_PMU_CAP_EXTENDED_REGS, the kernel will return -EOPNOTSUPP error. See following code: /* in kernel/events/core.c */ static int perf_try_init_event(struct pmu *pmu, struct perf_event *event) { .... if (!(pmu->capabilities & PERF_PMU_CAP_EXTENDED_REGS) && has_extended_regs(event)) ret = -EOPNOTSUPP; .... } For software dummy event, the PMU should not be set with PERF_PMU_CAP_EXTENDED_REGS. But unfortunately now, the dummy event has possibility to be set with PERF_REG_EXTENDED_MASK bit. In evsel__config, /* tools/perf/util/evsel.c */ if (opts->sample_intr_regs) { attr->sample_regs_intr = opts->sample_intr_regs; } If we use -IXMM0, the attr>sample_regs_intr will be set with PERF_REG_EXTENDED_MASK bit. It doesn't make sense to set attr->sample_regs_intr for a software dummy event. This patch adds dummy event checking before setting attr->sample_regs_intr and attr->sample_regs_user. After: # ./perf record -e cycles:p -IXMM0 -a -- sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.413 MB perf.data (45 samples) ] Committer notes: Adrian said this when providing his Acked-by: " This is fine. It will not break PT. no_aux_samples is useful for evsels that have been added by the code rather than requested by the user. For old kernels PT adds sched_switch tracepoint to track context switches (before the current context switch event was added) and having auxiliary sample information unnecessarily uses up space in the perf buffer. " Fixes: 0a892c1 ("perf record: Add dummy event during system wide synthesis") Signed-off-by: Jin Yao <[email protected]> Acked-by: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Jin Yao <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 1d078cc commit c4735d9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tools/perf/util/evsel.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,12 +1014,14 @@ void evsel__config(struct evsel *evsel, struct record_opts *opts,
10141014
if (callchain && callchain->enabled && !evsel->no_aux_samples)
10151015
evsel__config_callchain(evsel, opts, callchain);
10161016

1017-
if (opts->sample_intr_regs && !evsel->no_aux_samples) {
1017+
if (opts->sample_intr_regs && !evsel->no_aux_samples &&
1018+
!evsel__is_dummy_event(evsel)) {
10181019
attr->sample_regs_intr = opts->sample_intr_regs;
10191020
evsel__set_sample_bit(evsel, REGS_INTR);
10201021
}
10211022

1022-
if (opts->sample_user_regs && !evsel->no_aux_samples) {
1023+
if (opts->sample_user_regs && !evsel->no_aux_samples &&
1024+
!evsel__is_dummy_event(evsel)) {
10231025
attr->sample_regs_user |= opts->sample_user_regs;
10241026
evsel__set_sample_bit(evsel, REGS_USER);
10251027
}

0 commit comments

Comments
 (0)