perf, x86: Fix BTS condition
Subsystems (2)
Commit-ID: 18a073a3acd3a47fbb5e23333df7fad28d576345 Gitweb: http://git.kernel.org/tip/18a073a3acd3a47fbb5e23333df7fad28d576345 Author: Peter Zijlstra <[email protected]> AuthorDate: Tue, 26 Apr 2011 13:24:33 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 26 Apr 2011 13:34:34 +0200
perf, x86: Fix BTS condition
Currently the x86 backend incorrectly assumes that any BRANCH_INSN with sample_period==1 is a BTS request. This is not true when we do frequency driven profiling such as 'perf record -e branches'.
Solves this error:
$ perf record -e branches ./array Error: sys_perf_event_open() syscall returned with 95 (Operation not supported).
Signed-off-by Peter Zijlstra <[email protected]>
Reported-by Ingo Molnar <[email protected]>
Cc "Metzger, Markus T" <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Signed-off-by Ingo Molnar <[email protected]>
--- arch/x86/kernel/cpu/perf_event.c | 4 ++-- arch/x86/kernel/cpu/perf_event_intel.c | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/perf_event.c +2 -2
@@ -613,8 +613,8 @@ static int x86_setup_perfctr(struct perf_event *event)/* * Branch tracing: */ -if ((attr->config ==PERF_COUNT_HW_BRANCH_INSTRUCTIONS ) && - (hwc->sample_period ==1 )) { +if (attr->config ==PERF_COUNT_HW_BRANCH_INSTRUCTIONS && + !attr->freq && hwc->sample_period ==1 ) {/* BTS is not supported by this architecture. */ if (!x86_pmu.bts_active)return -EOPNOTSUPP ;
arch/x86/kernel/cpu/perf_event_intel.c +3 -0
@@ -998,6 +998,9 @@ intel_bts_constraints(struct perf_event *event)struct hw_perf_event *hwc = &event->hw;unsigned int hw_event, bts_event; +if (event->attr.freq) +return NULL ; + hw_event = hwc->config &INTEL_ARCH_EVENT_MASK ; bts_event = x86_pmu.event_map (PERF_COUNT_HW_BRANCH_INSTRUCTIONS );