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 10/12] perf/core, x86: removing fixed counter handling for AMD pmu
Date: Fri, 22 Jan 2010 15:22:05 +0100 [thread overview]
Message-ID: <1264170127-17402-11-git-send-email-robert.richter@amd.com> (raw)
In-Reply-To: <1264170127-17402-1-git-send-email-robert.richter@amd.com>
The AMD pmu does not support fixed counters. Thus, fixed counters may
not be considered for scheduling decissions. This patch implements an
AMD specific event scheduler without fixed counter calculation that
also improves code performance in the fast path.
Signed-off-by: Robert Richter <robert.richter@amd.com>
---
arch/x86/kernel/cpu/perf_event.c | 36 +++++++++++++++++++++++++++++++-----
1 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 3f81f91..3e0fc29 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -1407,8 +1407,8 @@ again:
/*
* intel-specific counter allocator: check event constraints
*/
-static int
-intel_get_event_idx(struct cpu_hw_events *cpuc, struct hw_perf_event *hwc)
+static inline int
+__intel_get_event_idx(struct cpu_hw_events *cpuc, struct hw_perf_event *hwc)
{
const struct event_constraint *event_constraint;
int i, code;
@@ -1432,7 +1432,7 @@ skip:
}
static int
-x86_schedule_event(struct cpu_hw_events *cpuc, struct hw_perf_event *hwc)
+intel_get_event_idx(struct cpu_hw_events *cpuc, struct hw_perf_event *hwc)
{
int idx;
@@ -1466,7 +1466,7 @@ x86_schedule_event(struct cpu_hw_events *cpuc, struct hw_perf_event *hwc)
/* Try to get the previous generic event again */
if (idx == -1 || test_and_set_bit(idx, cpuc->used_mask)) {
try_generic:
- idx = x86_pmu.get_event_idx(cpuc, hwc);
+ idx = __intel_get_event_idx(cpuc, hwc);
if (idx == -1)
return -EAGAIN;
@@ -1479,6 +1479,32 @@ try_generic:
return idx;
}
+static int
+amd_get_event_idx(struct cpu_hw_events *cpuc, struct hw_perf_event *hwc)
+{
+ int idx;
+
+ idx = hwc->idx;
+ /* Try to get the previous generic event again */
+ if (idx == -1 || test_and_set_bit(idx, cpuc->used_mask)) {
+ idx = gen_get_event_idx(cpuc, hwc);
+ if (idx == -1)
+ return -EAGAIN;
+
+ hwc->idx = idx;
+ }
+ hwc->config_base = x86_pmu.eventsel;
+ hwc->event_base = x86_pmu.perfctr;
+
+ return idx;
+}
+
+static int
+x86_schedule_event(struct cpu_hw_events *cpuc, struct hw_perf_event *hwc)
+{
+ return x86_pmu.get_event_idx(cpuc, hwc);
+}
+
/*
* Find a PMC slot for the freshly enabled / scheduled in event:
*/
@@ -2008,7 +2034,7 @@ static __initconst struct x86_pmu amd_pmu = {
.apic = 1,
/* use highest bit to detect overflow */
.max_period = (1ULL << 47) - 1,
- .get_event_idx = gen_get_event_idx,
+ .get_event_idx = amd_get_event_idx,
};
static __init int p6_pmu_init(void)
--
1.6.6
next prev parent reply other threads:[~2010-01-22 14:55 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 ` Robert Richter [this message]
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-11-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