From: Stephane Eranian <eranian@google.com>
To: linux-kernel@vger.kernel.org
Cc: peterz@infradead.org, mingo@elte.hu, acme@redhat.com,
ming.m.lin@intel.com, andi@firstfloor.org,
robert.richter@amd.com, ravitillo@lbl.gov, will.deacon@arm.com,
paulus@samba.org, benh@kernel.crashing.org, rth@twiddle.net,
ralf@linux-mips.org, davem@davemloft.net, lethal@linux-sh.org
Subject: [PATCH 04/12] perf_events: sync branch stack sampling with X86 precise_sampling (v2)
Date: Fri, 14 Oct 2011 14:37:05 +0200 [thread overview]
Message-ID: <1318595833-29984-5-git-send-email-eranian@google.com> (raw)
In-Reply-To: <1318595833-29984-1-git-send-email-eranian@google.com>
If precise sampling is enabled on Intel X86, then perf_event uses PEBS.
To correct for the off-by-one error of PEBS, perf_event uses LBR when
precise_sample > 1.
On Intel X86 PERF_SAMPLE_BRANCH_STACK is implemented using LBR,
therefore both features must be coordinated as they may not
configure LBR the same way.
For PEBS, LBR needs to capture all branches at all priv levels.
This patch sets this up.
The configuration of PERF_SAMPLE_BRANCH_STACK may not be compatible
in which case an error must be returned.
Signed-off-by: Stephane Eranian <eranian@google.com>
---
arch/x86/kernel/cpu/perf_event.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index cfef90e..e2efa90 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -358,6 +358,7 @@ int x86_setup_perfctr(struct perf_event *event)
int x86_pmu_hw_config(struct perf_event *event)
{
if (event->attr.precise_ip) {
+ u64 *br_type, br_sel;
int precise = 0;
/* Support for constant skid */
@@ -371,6 +372,27 @@ int x86_pmu_hw_config(struct perf_event *event)
if (event->attr.precise_ip > precise)
return -EOPNOTSUPP;
+ /*
+ * check that PEBS LBR correction does not conflict with
+ * whatever the user is asking with attr->branch_sample_type
+ */
+ if (event->attr.precise_ip > 1) {
+
+ br_type = &event->attr.branch_sample_type;
+
+ if (has_branch_stack(event)) {
+ br_sel = *br_type & PERF_SAMPLE_BRANCH_ANY;
+ if (br_sel != PERF_SAMPLE_BRANCH_ANY)
+ return -EOPNOTSUPP;
+ } else {
+ /*
+ * For PEBS fixups, we capture all
+ * the branches at all priv levels
+ */
+ *br_type = PERF_SAMPLE_BRANCH_ANY
+ | PERF_SAMPLE_BRANCH_PLM_ALL;
+ }
+ }
}
/*
--
1.7.1
next prev parent reply other threads:[~2011-10-14 12:38 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-14 12:37 [PATCH 00/12] perf_events: add support for sampling taken branches (v2) Stephane Eranian
2011-10-14 12:37 ` [PATCH 01/12] perf_events: add generic taken branch sampling support (v2) Stephane Eranian
2011-12-05 21:06 ` Peter Zijlstra
2011-12-06 19:42 ` Stephane Eranian
2011-12-05 22:14 ` Peter Zijlstra
2011-12-06 19:27 ` Stephane Eranian
2011-10-14 12:37 ` [PATCH 02/12] perf_events: add Intel LBR MSR definitions (v2) Stephane Eranian
2011-10-14 12:37 ` [PATCH 03/12] perf_events: add Intel X86 LBR sharing logic (v2) Stephane Eranian
2011-10-14 12:37 ` Stephane Eranian [this message]
2011-10-14 12:37 ` [PATCH 05/12] perf_events: add LBR mappings for PERF_SAMPLE_BRANCH filters (v2) Stephane Eranian
2011-12-05 22:35 ` Peter Zijlstra
2011-12-07 4:22 ` Stephane Eranian
2011-10-14 12:37 ` [PATCH 06/12] perf_events: implement PERF_SAMPLE_BRANCH for Intel X86 (v2) Stephane Eranian
2011-10-14 12:37 ` [PATCH 07/12] perf_events: add LBR software filter support " Stephane Eranian
2011-12-05 22:29 ` Peter Zijlstra
2011-10-14 12:37 ` [PATCH 08/12] perf_events: disable PERF_SAMPLE_BRANCH_* when not supported (v2) Stephane Eranian
2011-10-14 12:37 ` [PATCH 09/12] perf_events: add hook to flush branch_stack on context switch (v2) Stephane Eranian
2011-12-05 21:10 ` Peter Zijlstra
2011-12-05 21:37 ` Peter Zijlstra
2011-12-07 18:25 ` Stephane Eranian
2011-12-08 10:49 ` Peter Zijlstra
2011-12-08 18:04 ` Stephane Eranian
2011-12-08 18:13 ` Peter Zijlstra
2011-12-08 22:06 ` Stephane Eranian
2011-12-09 9:00 ` Peter Zijlstra
2011-10-14 12:37 ` [PATCH 10/12] perf: add code to support PERF_SAMPLE_BRANCH_STACK (v2) Stephane Eranian
2011-10-14 12:37 ` [PATCH 11/12] perf: add support for sampling taken branch to perf record (v2) Stephane Eranian
2011-10-14 12:37 ` [PATCH 12/12] perf: add support for taken branch sampling to perf report (v2) Stephane Eranian
2011-12-04 20:11 ` [PATCH 00/12] perf_events: add support for sampling taken branches (v2) Stephane Eranian
2011-12-05 15:27 ` Peter Zijlstra
2011-12-05 22:39 ` Peter Zijlstra
2011-12-06 9:49 ` Will Deacon
2011-12-06 11:03 ` Peter Zijlstra
2011-12-06 19:14 ` Stephane Eranian
2011-12-06 19:20 ` Peter Zijlstra
2011-12-06 19:22 ` Stephane Eranian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1318595833-29984-5-git-send-email-eranian@google.com \
--to=eranian@google.com \
--cc=acme@redhat.com \
--cc=andi@firstfloor.org \
--cc=benh@kernel.crashing.org \
--cc=davem@davemloft.net \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.m.lin@intel.com \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=ralf@linux-mips.org \
--cc=ravitillo@lbl.gov \
--cc=robert.richter@amd.com \
--cc=rth@twiddle.net \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®