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 08/12] perf/core, x86: implement ARCH_PERFMON_EVENTSEL bit masks
Date: Fri, 22 Jan 2010 15:22:03 +0100 [thread overview]
Message-ID: <1264170127-17402-9-git-send-email-robert.richter@amd.com> (raw)
In-Reply-To: <1264170127-17402-1-git-send-email-robert.richter@amd.com>
ARCH_PERFMON_EVENTSEL bit masks are offen used in the kernel. This
patch adds macros for the bit masks and removes local defines.
Signed-off-by: Robert Richter <robert.richter@amd.com>
---
arch/x86/include/asm/perf_event.h | 16 ++++++++++---
arch/x86/kernel/cpu/perf_event.c | 42 +++++++++++-------------------------
2 files changed, 25 insertions(+), 33 deletions(-)
diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h
index c7f723a..448bcf5 100644
--- a/arch/x86/include/asm/perf_event.h
+++ b/arch/x86/include/asm/perf_event.h
@@ -18,10 +18,18 @@
#define MSR_ARCH_PERFMON_EVENTSEL0 0x186
#define MSR_ARCH_PERFMON_EVENTSEL1 0x187
-#define ARCH_PERFMON_EVENTSEL_ENABLE (1 << 22)
-#define ARCH_PERFMON_EVENTSEL_INT (1 << 20)
-#define ARCH_PERFMON_EVENTSEL_OS (1 << 17)
-#define ARCH_PERFMON_EVENTSEL_USR (1 << 16)
+#define ARCH_PERFMON_EVENTSEL_EVENT 0x000000FFULL
+#define ARCH_PERFMON_EVENTSEL_UMASK 0x0000FF00ULL
+#define ARCH_PERFMON_EVENTSEL_USR (1ULL << 16)
+#define ARCH_PERFMON_EVENTSEL_OS (1ULL << 17)
+#define ARCH_PERFMON_EVENTSEL_EDGE (1ULL << 18)
+#define ARCH_PERFMON_EVENTSEL_INT (1ULL << 20)
+#define ARCH_PERFMON_EVENTSEL_ENABLE (1ULL << 22)
+#define ARCH_PERFMON_EVENTSEL_INV (1ULL << 23)
+#define ARCH_PERFMON_EVENTSEL_CMASK 0xFF000000ULL
+
+#define AMD64_EVENTSEL_EVENT \
+ (ARCH_PERFMON_EVENTSEL_EVENT | 0x0FULL << 32)
/*
* Includes eventsel and unit mask as well:
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 96cbfe6..4eb0355 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -27,6 +27,16 @@
#include <asm/stacktrace.h>
#include <asm/nmi.h>
+#define X86_RAW_EVENT_MASK \
+ (ARCH_PERFMON_EVENTSEL_EVENT | \
+ ARCH_PERFMON_EVENTSEL_UMASK | \
+ ARCH_PERFMON_EVENTSEL_EDGE | \
+ ARCH_PERFMON_EVENTSEL_INV | \
+ ARCH_PERFMON_EVENTSEL_CMASK)
+#define AMD64_RAW_EVENT_MASK \
+ (X86_RAW_EVENT_MASK | \
+ AMD64_EVENTSEL_EVENT)
+
/* The maximal number of PEBS events: */
#define MAX_PEBS_EVENTS 4
@@ -499,20 +509,7 @@ static __initconst u64 atom_hw_cache_event_ids
static u64 intel_pmu_raw_event(u64 hw_event)
{
-#define CORE_EVNTSEL_EVENT_MASK 0x000000FFULL
-#define CORE_EVNTSEL_UNIT_MASK 0x0000FF00ULL
-#define CORE_EVNTSEL_EDGE_MASK 0x00040000ULL
-#define CORE_EVNTSEL_INV_MASK 0x00800000ULL
-#define CORE_EVNTSEL_REG_MASK 0xFF000000ULL
-
-#define CORE_EVNTSEL_MASK \
- (CORE_EVNTSEL_EVENT_MASK | \
- CORE_EVNTSEL_UNIT_MASK | \
- CORE_EVNTSEL_EDGE_MASK | \
- CORE_EVNTSEL_INV_MASK | \
- CORE_EVNTSEL_REG_MASK)
-
- return hw_event & CORE_EVNTSEL_MASK;
+ return hw_event & X86_RAW_EVENT_MASK;
}
static __initconst u64 amd_hw_cache_event_ids
@@ -626,20 +623,7 @@ static u64 amd_pmu_event_map(int hw_event)
static u64 amd_pmu_raw_event(u64 hw_event)
{
-#define K7_EVNTSEL_EVENT_MASK 0x7000000FFULL
-#define K7_EVNTSEL_UNIT_MASK 0x00000FF00ULL
-#define K7_EVNTSEL_EDGE_MASK 0x000040000ULL
-#define K7_EVNTSEL_INV_MASK 0x000800000ULL
-#define K7_EVNTSEL_REG_MASK 0x0FF000000ULL
-
-#define K7_EVNTSEL_MASK \
- (K7_EVNTSEL_EVENT_MASK | \
- K7_EVNTSEL_UNIT_MASK | \
- K7_EVNTSEL_EDGE_MASK | \
- K7_EVNTSEL_INV_MASK | \
- K7_EVNTSEL_REG_MASK)
-
- return hw_event & K7_EVNTSEL_MASK;
+ return hw_event & AMD64_RAW_EVENT_MASK;
}
/*
@@ -1427,7 +1411,7 @@ intel_get_event_idx(struct cpu_hw_events *cpuc, struct hw_perf_event *hwc)
if (!event_constraints)
goto skip;
- code = hwc->config & CORE_EVNTSEL_EVENT_MASK;
+ code = hwc->config & ARCH_PERFMON_EVENTSEL_EVENT;
for_each_event_constraint(event_constraint, event_constraints) {
if (code == event_constraint->code) {
--
1.6.6
next prev parent reply other threads:[~2010-01-22 14:57 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 ` Robert Richter [this message]
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 ` [PATCH 11/12] perf/core, x86: make event_constraints a member of struct x86_pmu Robert Richter
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-9-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