From: kan.liang@intel.com
To: a.p.zijlstra@chello.nl
Cc: eranian@google.com, andi@firstfloor.org,
linux-kernel@vger.kernel.org, Kan Liang <kan.liang@intel.com>
Subject: [PATCH 1/1] perf/x86: filter branches for PEBS event
Date: Thu, 26 Mar 2015 14:13:23 -0400 [thread overview]
Message-ID: <1427393603-3533-1-git-send-email-kan.liang@intel.com> (raw)
From: Kan Liang <kan.liang@intel.com>
For supporting Intel LBR branches filtering, Intel LBR sharing logic
mechanism is introduced from commit b36817e88630 ("perf/x86: Add Intel
LBR sharing logic"). It modifies __intel_shared_reg_get_constraints to
config lbr_sel, which is finally used to set LBR_SELECT.
However, the intel_shared_regs_constraints is called after
intel_pebs_constraints. The PEBS event will return immediately after
intel_pebs_constraints. So it's impossible to filter branches for PEBS
event.
This patch move intel_shared_regs_constraints for branch_reg ahead of
intel_pebs_constraints.
intel_shared_regs_constraints for branch_reg doesn't modify event->hw,
so it's safe to be called before intel_pebs_constraints.
intel_shared_regs_constraints for branch_reg also special case when it
returns &emptyconstraint. It put constraints for extra_reg. This patch
remove it. Because it will never get constraints for extra_reg if return
is &emptyconstraint.
Signed-off-by: Kan Liang <kan.liang@intel.com>
---
arch/x86/kernel/cpu/perf_event_intel.c | 34 ++++++++++++----------------------
1 file changed, 12 insertions(+), 22 deletions(-)
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index 9f1dd18..247780a 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -1587,25 +1587,14 @@ __intel_shared_reg_put_constraints(struct cpu_hw_events *cpuc,
static struct event_constraint *
intel_shared_regs_constraints(struct cpu_hw_events *cpuc,
- struct perf_event *event)
+ struct perf_event *event,
+ struct hw_perf_event_extra *reg)
{
- struct event_constraint *c = NULL, *d;
- struct hw_perf_event_extra *xreg, *breg;
+ struct event_constraint *c = NULL;
+
+ if (reg->idx != EXTRA_REG_NONE)
+ c = __intel_shared_reg_get_constraints(cpuc, event, reg);
- xreg = &event->hw.extra_reg;
- if (xreg->idx != EXTRA_REG_NONE) {
- c = __intel_shared_reg_get_constraints(cpuc, event, xreg);
- if (c == &emptyconstraint)
- return c;
- }
- breg = &event->hw.branch_reg;
- if (breg->idx != EXTRA_REG_NONE) {
- d = __intel_shared_reg_get_constraints(cpuc, event, breg);
- if (d == &emptyconstraint) {
- __intel_shared_reg_put_constraints(cpuc, xreg);
- c = d;
- }
- }
return c;
}
@@ -1629,17 +1618,18 @@ x86_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event)
static struct event_constraint *
intel_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event)
{
- struct event_constraint *c;
+ struct event_constraint *c, *d;
c = intel_bts_constraints(event);
if (c)
return c;
- c = intel_pebs_constraints(event);
- if (c)
- return c;
+ c = intel_shared_regs_constraints(cpuc, event, &event->hw.branch_reg);
+ d = intel_pebs_constraints(event);
+ if (d || c)
+ return (d) ? (d) : (c);
- c = intel_shared_regs_constraints(cpuc, event);
+ c = intel_shared_regs_constraints(cpuc, event, &event->hw.extra_reg);
if (c)
return c;
--
1.8.3.2
next reply other threads:[~2015-03-26 18:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-26 18:13 kan.liang [this message]
2015-03-26 19:40 ` [PATCH 1/1] perf/x86: filter branches for PEBS event Stephane Eranian
2015-03-26 20:20 ` Liang, Kan
2015-03-26 21:02 ` Stephane Eranian
2015-03-27 12:10 ` Peter Zijlstra
2015-03-27 15:28 ` Stephane Eranian
2015-03-27 12:17 ` Peter Zijlstra
2015-03-27 13:09 ` Liang, Kan
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=1427393603-3533-1-git-send-email-kan.liang@intel.com \
--to=kan.liang@intel.com \
--cc=a.p.zijlstra@chello.nl \
--cc=andi@firstfloor.org \
--cc=eranian@google.com \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.