linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephane Eranian <eranian@google.com>
To: linux-kernel@vger.kernel.org
Cc: peterz@infradead.org, mingo@elte.hu, ak@linux.intel.com,
	jolsa@redhat.com, kan.liang@intel.com, bp@alien8.de,
	maria.n.dimakopoulou@gmail.com
Subject: [PATCH v3 04/13] perf/x86: add index param to get_event_constraint() callback
Date: Mon, 17 Nov 2014 20:06:56 +0100	[thread overview]
Message-ID: <1416251225-17721-5-git-send-email-eranian@google.com> (raw)
In-Reply-To: <1416251225-17721-1-git-send-email-eranian@google.com>

This patch adds an index parameter to the get_event_constraint()
x86_pmu callback. It is expected to represent the index of the
event in the cpuc->event_list[] array. When the callback is used
for fake_cpuc (evnet validation), then the index must be -1. The
motivation for passing the index is to use it to index into another
cpuc array.

Signed-off-by: Stephane Eranian <eranian@google.com>
---
 arch/x86/kernel/cpu/perf_event.c       |  4 ++--
 arch/x86/kernel/cpu/perf_event.h       |  4 +++-
 arch/x86/kernel/cpu/perf_event_amd.c   |  6 ++++--
 arch/x86/kernel/cpu/perf_event_intel.c | 15 ++++++++++-----
 4 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 570e99b..422a423 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -734,7 +734,7 @@ int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)
 
 	for (i = 0, wmin = X86_PMC_IDX_MAX, wmax = 0; i < n; i++) {
 		hwc = &cpuc->event_list[i]->hw;
-		c = x86_pmu.get_event_constraints(cpuc, cpuc->event_list[i]);
+		c = x86_pmu.get_event_constraints(cpuc, i, cpuc->event_list[i]);
 		hwc->constraint = c;
 
 		wmin = min(wmin, c->weight);
@@ -1723,7 +1723,7 @@ static int validate_event(struct perf_event *event)
 	if (IS_ERR(fake_cpuc))
 		return PTR_ERR(fake_cpuc);
 
-	c = x86_pmu.get_event_constraints(fake_cpuc, event);
+	c = x86_pmu.get_event_constraints(fake_cpuc, -1, event);
 
 	if (!c || !c->weight)
 		ret = -EINVAL;
diff --git a/arch/x86/kernel/cpu/perf_event.h b/arch/x86/kernel/cpu/perf_event.h
index 641b2df..141c17c 100644
--- a/arch/x86/kernel/cpu/perf_event.h
+++ b/arch/x86/kernel/cpu/perf_event.h
@@ -447,6 +447,7 @@ struct x86_pmu {
 	u64		max_period;
 	struct event_constraint *
 			(*get_event_constraints)(struct cpu_hw_events *cpuc,
+						 int idx,
 						 struct perf_event *event);
 
 	void		(*put_event_constraints)(struct cpu_hw_events *cpuc,
@@ -693,7 +694,8 @@ static inline int amd_pmu_init(void)
 int intel_pmu_save_and_restart(struct perf_event *event);
 
 struct event_constraint *
-x86_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event);
+x86_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
+			  struct perf_event *event);
 
 struct intel_shared_regs *allocate_shared_regs(int cpu);
 
diff --git a/arch/x86/kernel/cpu/perf_event_amd.c b/arch/x86/kernel/cpu/perf_event_amd.c
index e4302b8..1cee5d2 100644
--- a/arch/x86/kernel/cpu/perf_event_amd.c
+++ b/arch/x86/kernel/cpu/perf_event_amd.c
@@ -430,7 +430,8 @@ static void amd_pmu_cpu_dead(int cpu)
 }
 
 static struct event_constraint *
-amd_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event)
+amd_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
+			  struct perf_event *event)
 {
 	/*
 	 * if not NB event or no NB, then no constraints
@@ -538,7 +539,8 @@ static struct event_constraint amd_f15_PMC50 = EVENT_CONSTRAINT(0, 0x3F, 0);
 static struct event_constraint amd_f15_PMC53 = EVENT_CONSTRAINT(0, 0x38, 0);
 
 static struct event_constraint *
-amd_get_event_constraints_f15h(struct cpu_hw_events *cpuc, struct perf_event *event)
+amd_get_event_constraints_f15h(struct cpu_hw_events *cpuc, int idx,
+			       struct perf_event *event)
 {
 	struct hw_perf_event *hwc = &event->hw;
 	unsigned int event_code = amd_get_event_code(hwc);
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index 9345194..9b60b17 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -1624,7 +1624,8 @@ intel_shared_regs_constraints(struct cpu_hw_events *cpuc,
 }
 
 struct event_constraint *
-x86_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event)
+x86_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
+			  struct perf_event *event)
 {
 	struct event_constraint *c;
 
@@ -1641,7 +1642,8 @@ 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)
+intel_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
+			    struct perf_event *event)
 {
 	struct event_constraint *c;
 
@@ -1657,7 +1659,7 @@ intel_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event
 	if (c)
 		return c;
 
-	return x86_get_event_constraints(cpuc, event);
+	return x86_get_event_constraints(cpuc, idx, event);
 }
 
 static void
@@ -1891,9 +1893,12 @@ static struct event_constraint counter2_constraint =
 			EVENT_CONSTRAINT(0, 0x4, 0);
 
 static struct event_constraint *
-hsw_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event)
+hsw_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
+			  struct perf_event *event)
 {
-	struct event_constraint *c = intel_get_event_constraints(cpuc, event);
+	struct event_constraint *c;
+
+	c = intel_get_event_constraints(cpuc, idx, event);
 
 	/* Handle special quirk on in_tx_checkpointed only in counter 2 */
 	if (event->hw.config & HSW_IN_TX_CHECKPOINTED) {
-- 
1.9.1


  parent reply	other threads:[~2014-11-17 19:08 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-17 19:06 [PATCH v3 00/13] perf/x86: implement HT counter corruption workaround Stephane Eranian
2014-11-17 19:06 ` [PATCH v3 01/13] perf,x86: rename er_flags to flags Stephane Eranian
2015-04-02 18:41   ` [tip:perf/core] perf/x86: Rename x86_pmu::er_flags to 'flags' tip-bot for Stephane Eranian
2014-11-17 19:06 ` [PATCH v3 02/13] perf/x86: vectorize cpuc->kfree_on_online Stephane Eranian
2015-04-02 18:41   ` [tip:perf/core] perf/x86: Vectorize cpuc->kfree_on_online tip-bot for Stephane Eranian
2014-11-17 19:06 ` [PATCH v3 03/13] perf/x86: add 3 new scheduling callbacks Stephane Eranian
2015-04-02 18:42   ` [tip:perf/core] perf/x86: Add " tip-bot for Maria Dimakopoulou
2014-11-17 19:06 ` Stephane Eranian [this message]
2015-04-02 18:42   ` [tip:perf/core] perf/x86: Add 'index' param to get_event_constraint() callback tip-bot for Stephane Eranian
2014-11-17 19:06 ` [PATCH v3 05/13] perf/x86: add cross-HT counter exclusion infrastructure Stephane Eranian
2015-04-02 18:42   ` [tip:perf/core] perf/x86/intel: Add " tip-bot for Maria Dimakopoulou
2014-11-17 19:06 ` [PATCH v3 06/13] perf/x86: implement cross-HT corruption bug workaround Stephane Eranian
2015-04-02 18:43   ` [tip:perf/core] perf/x86/intel: Implement " tip-bot for Maria Dimakopoulou
2014-11-17 19:06 ` [PATCH v3 07/13] perf/x86: enforce HT bug workaround for SNB/IVB/HSW Stephane Eranian
2015-04-02 18:43   ` [tip:perf/core] perf/x86/intel: Enforce HT bug workaround for SNB /IVB/HSW tip-bot for Maria Dimakopoulou
2014-11-17 19:07 ` [PATCH v3 08/13] perf/x86: enforce HT bug workaround with PEBS for SNB/IVB/HSW Stephane Eranian
2015-04-02 18:43   ` [tip:perf/core] perf/x86/intel: Enforce " tip-bot for Maria Dimakopoulou
2014-11-17 19:07 ` [PATCH v3 09/13] perf/x86: fix intel_get_event_constraints() for dynamic constraints Stephane Eranian
2015-04-02 18:43   ` [tip:perf/core] perf/x86/intel: Fix " tip-bot for Stephane Eranian
2014-11-17 19:07 ` [PATCH v3 10/13] perf/x86: limit to half counters to avoid exclusive mode starvation Stephane Eranian
2015-04-02 18:44   ` [tip:perf/core] perf/x86/intel: Limit to half counters when the HT workaround is enabled, " tip-bot for Stephane Eranian
2014-11-17 19:07 ` [PATCH v3 11/13] watchdog: add watchdog enable/disable all functions Stephane Eranian
2015-04-02 18:44   ` [tip:perf/core] watchdog: Add watchdog enable/ disable " tip-bot for Stephane Eranian
2014-11-17 19:07 ` [PATCH v3 12/13] perf/x86: make HT bug workaround conditioned on HT enabled Stephane Eranian
2015-04-02 18:44   ` [tip:perf/core] perf/x86/intel: Make the HT bug workaround conditional " tip-bot for Stephane Eranian
2014-11-17 19:07 ` [PATCH v3 13/13] perf/x86: add syfs entry to disable HT bug workaround Stephane Eranian
2014-11-17 23:02   ` Borislav Petkov
2014-11-17 23:38     ` Thomas Gleixner
2014-11-17 23:58       ` Borislav Petkov
2014-11-18  0:31         ` Thomas Gleixner
2014-11-18 15:29           ` Stephane Eranian
2014-11-18 15:43             ` Borislav Petkov
2014-11-18 16:37               ` Stephane Eranian
2014-11-18 16:42                 ` Borislav Petkov
2014-11-18 15:01     ` Maria Dimakopoulou
2014-11-18 15:12       ` Borislav Petkov

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=1416251225-17721-5-git-send-email-eranian@google.com \
    --to=eranian@google.com \
    --cc=ak@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=jolsa@redhat.com \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maria.n.dimakopoulou@gmail.com \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).