public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Richter <robert.richter@amd.com>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Stephane Eranian <eranian@googlemail.com>
Cc: Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@elte.hu>,
	LKML <linux-kernel@vger.kernel.org>,
	Robert Richter <robert.richter@amd.com>
Subject: [PATCH 11/12] perf/core, x86: make event_constraints a member of struct x86_pmu
Date: Fri, 22 Jan 2010 15:22:06 +0100	[thread overview]
Message-ID: <1264170127-17402-12-git-send-email-robert.richter@amd.com> (raw)
In-Reply-To: <1264170127-17402-1-git-send-email-robert.richter@amd.com>

The event_constraints describe the x86 pmu and thus are better located
in struct x86_pmu than in a separate static variable. This is also
necessary to generalize some model specific functions such as
intel_get_event_idx().

Signed-off-by: Robert Richter <robert.richter@amd.com>
---
 arch/x86/kernel/cpu/perf_event.c |   24 ++++++++++--------------
 1 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 3e0fc29..b893ee7 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -123,6 +123,7 @@ struct x86_pmu {
 	void		(*disable_bts)(void);
 	int		(*get_event_idx)(struct cpu_hw_events *cpuc,
 					 struct hw_perf_event *hwc);
+	struct event_constraint *event_constraints;
 };
 
 static struct x86_pmu x86_pmu __read_mostly;
@@ -131,8 +132,6 @@ static DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events) = {
 	.enabled = 1,
 };
 
-static const struct event_constraint *event_constraints;
-
 /*
  * Not sure about some of these
  */
@@ -160,7 +159,7 @@ static u64 p6_pmu_event_map(int hw_event)
  */
 #define P6_NOP_EVENT			0x0000002EULL
 
-static const struct event_constraint intel_p6_event_constraints[] =
+static struct event_constraint intel_p6_event_constraints[] =
 {
 	EVENT_CONSTRAINT(0xc1, 0x1),	/* FLOPS */
 	EVENT_CONSTRAINT(0x10, 0x1),	/* FP_COMP_OPS_EXE */
@@ -185,7 +184,7 @@ static const u64 intel_perfmon_event_map[] =
   [PERF_COUNT_HW_BUS_CYCLES]		= 0x013c,
 };
 
-static const struct event_constraint intel_core_event_constraints[] =
+static struct event_constraint intel_core_event_constraints[] =
 {
 	EVENT_CONSTRAINT(0x10, 0x1),	/* FP_COMP_OPS_EXE */
 	EVENT_CONSTRAINT(0x11, 0x2),	/* FP_ASSIST */
@@ -199,7 +198,7 @@ static const struct event_constraint intel_core_event_constraints[] =
 	EVENT_CONSTRAINT_END
 };
 
-static const struct event_constraint intel_nehalem_event_constraints[] =
+static struct event_constraint intel_nehalem_event_constraints[] =
 {
 	EVENT_CONSTRAINT(0x40, 0x3),	/* L1D_CACHE_LD */
 	EVENT_CONSTRAINT(0x41, 0x3),	/* L1D_CACHE_ST */
@@ -1413,12 +1412,12 @@ __intel_get_event_idx(struct cpu_hw_events *cpuc, struct hw_perf_event *hwc)
 	const struct event_constraint *event_constraint;
 	int i, code;
 
-	if (!event_constraints)
+	if (!x86_pmu.event_constraints)
 		goto skip;
 
 	code = hwc->config & ARCH_PERFMON_EVENTSEL_EVENT;
 
-	for_each_event_constraint(event_constraint, event_constraints) {
+	for_each_event_constraint(event_constraint, x86_pmu.event_constraints) {
 		if (code == event_constraint->code) {
 			for_each_bit(i, event_constraint->idxmsk, X86_PMC_IDX_MAX) {
 				if (!test_and_set_bit(i, cpuc->used_mask))
@@ -1990,6 +1989,7 @@ static __initconst struct x86_pmu p6_pmu = {
 	.cntval_bits		= 32,
 	.cntval_mask		= (1ULL << 32) - 1,
 	.get_event_idx		= intel_get_event_idx,
+	.event_constraints	= intel_p6_event_constraints,
 };
 
 static __initconst struct x86_pmu intel_pmu = {
@@ -2047,12 +2047,8 @@ static __init int p6_pmu_init(void)
 	case 7:
 	case 8:
 	case 11: /* Pentium III */
-		event_constraints = intel_p6_event_constraints;
-		break;
 	case 9:
-	case 13:
-		/* Pentium M */
-		event_constraints = intel_p6_event_constraints;
+	case 13: /* Pentium M */
 		break;
 	default:
 		pr_cont("unsupported p6 CPU model %d ",
@@ -2118,14 +2114,14 @@ static __init int intel_pmu_init(void)
 		       sizeof(hw_cache_event_ids));
 
 		pr_cont("Core2 events, ");
-		event_constraints = intel_core_event_constraints;
+		x86_pmu.event_constraints = intel_core_event_constraints;
 		break;
 	default:
 	case 26:
 		memcpy(hw_cache_event_ids, nehalem_hw_cache_event_ids,
 		       sizeof(hw_cache_event_ids));
 
-		event_constraints = intel_nehalem_event_constraints;
+		x86_pmu.event_constraints = intel_nehalem_event_constraints;
 		pr_cont("Nehalem/Corei7 events, ");
 		break;
 	case 28:
-- 
1.6.6



  parent reply	other threads:[~2010-01-22 14:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-22 14:21 [PATCH 01/12] perf/core: x86 and AMD pmu updates Robert Richter
2010-01-22 14:21 ` [PATCH 01/12] perf/core: correct files in MAINTAINERS entry Robert Richter
2010-01-22 14:21 ` [PATCH 02/12] perf/core, x86: undo some some *_counter* -> *_event* renames Robert Richter
2010-01-22 14:21 ` [PATCH 03/12] perf/core, x86: remove duplicate perf_event_mask variable Robert Richter
2010-01-22 14:21 ` [PATCH 04/12] perf/core, x86: remove cpu_hw_events.interrupts Robert Richter
2010-01-22 14:22 ` [PATCH 05/12] perf/core, x86: reduce number of CONFIG_X86_LOCAL_APIC macros Robert Richter
2010-01-22 14:22 ` [PATCH 06/12] perf/core, x86: removing p6_pmu_raw_event() Robert Richter
2010-01-22 14:22 ` [PATCH 07/12] perf/core, x86: rename macro in ARCH_PERFMON_EVENTSEL_ENABLE Robert Richter
2010-01-22 14:22 ` [PATCH 08/12] perf/core, x86: implement ARCH_PERFMON_EVENTSEL bit masks Robert Richter
2010-01-22 14:22 ` [PATCH 09/12] perf/core, x86: use test_and_set_bit() to when grabbing a counter Robert Richter
2010-01-22 14:22 ` [PATCH 10/12] perf/core, x86: removing fixed counter handling for AMD pmu Robert Richter
2010-01-22 14:22 ` Robert Richter [this message]
2010-01-22 14:22 ` [PATCH 12/12] perf/core, x86: make event constraint handler generic Robert Richter

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=1264170127-17402-12-git-send-email-robert.richter@amd.com \
    --to=robert.richter@amd.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=eranian@googlemail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.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