* [PATCH 0/2] oprofile, x86: updates for AMD family 15h systems
@ 2010-12-10 11:29 Robert Richter
0 siblings, 0 replies; 5+ messages in thread
From: Robert Richter @ 2010-12-10 11:29 UTC (permalink / raw)
To: Ingo Molnar; +Cc: LKML, oprofile-list
This patch set adds support for AMD family 15h systems. It adds cpu
detection code for family 15h and implements support for 6 counters.
Suravee already sent updates for the oprofile userland to the oprofile
mailing list.
Please review. If the patches are fine I will apply them to the
oprofile git repostitory on kernel.org.
Thanks,
-Robert
>From robert.richter@amd.com Fri Dec 10 12:29:57 2010 +0100
From: Robert Richter <robert.richter@amd.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>, oprofile-list <oprofile-list@lists.sourceforge.net>, Robert Richter <robert.richter@amd.com>
Bcc: osrc-patches@elbe.amd.com
Subject: [PATCH 1/2] oprofile, x86: Add support for AMD family 15h
Date: Fri, 10 Dec 2010 12:29:57 +0100
Message-Id: <1291980598-21625-2-git-send-email-robert.richter@amd.com>
X-Mailer: git-send-email 1.7.3.2
In-Reply-To: <1291980598-21625-1-git-send-email-robert.richter@amd.com>
References: <1291980598-21625-1-git-send-email-robert.richter@amd.com>
This patch adds support for AMD family 15h (Interlagos/Valencia/
Zambezi) cpus.
Signed-off-by: Robert Richter <robert.richter@amd.com>
---
arch/x86/oprofile/nmi_int.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
index 4e8baad..358c8b9 100644
--- a/arch/x86/oprofile/nmi_int.c
+++ b/arch/x86/oprofile/nmi_int.c
@@ -732,6 +732,9 @@ int __init op_nmi_init(struct oprofile_operations *ops)
case 0x14:
cpu_type = "x86-64/family14h";
break;
+ case 0x15:
+ cpu_type = "x86-64/family15h";
+ break;
default:
return -ENODEV;
}
--
1.7.3.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 0/2] oprofile, x86: updates for AMD family 15h systems
@ 2010-12-10 11:49 Robert Richter
2010-12-10 11:49 ` [PATCH 1/2] oprofile, x86: Add support for AMD family 15h Robert Richter
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Robert Richter @ 2010-12-10 11:49 UTC (permalink / raw)
To: Ingo Molnar; +Cc: LKML, oprofile-list
(resending due to mail corruption)
This patch set adds support for AMD family 15h systems. It adds cpu
detection code for family 15h and implements support for 6 counters.
Suravee already sent updates for the oprofile userland to the oprofile
mailing list.
Please review. If the patches are fine I will apply them to the
oprofile git repostitory on kernel.org.
Thanks,
-Robert
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] oprofile, x86: Add support for AMD family 15h
2010-12-10 11:49 [PATCH 0/2] oprofile, x86: updates for AMD family 15h systems Robert Richter
@ 2010-12-10 11:49 ` Robert Richter
2010-12-10 11:49 ` [PATCH 2/2] oprofile, x86: Add support for 6 counters (AMD family 15h) Robert Richter
2010-12-19 13:27 ` [PATCH 0/2] oprofile, x86: updates for AMD family 15h systems Robert Richter
2 siblings, 0 replies; 5+ messages in thread
From: Robert Richter @ 2010-12-10 11:49 UTC (permalink / raw)
To: Ingo Molnar; +Cc: LKML, oprofile-list, Robert Richter
This patch adds support for AMD family 15h (Interlagos/Valencia/
Zambezi) cpus.
Signed-off-by: Robert Richter <robert.richter@amd.com>
---
arch/x86/oprofile/nmi_int.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
index 4e8baad..358c8b9 100644
--- a/arch/x86/oprofile/nmi_int.c
+++ b/arch/x86/oprofile/nmi_int.c
@@ -732,6 +732,9 @@ int __init op_nmi_init(struct oprofile_operations *ops)
case 0x14:
cpu_type = "x86-64/family14h";
break;
+ case 0x15:
+ cpu_type = "x86-64/family15h";
+ break;
default:
return -ENODEV;
}
--
1.7.3.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] oprofile, x86: Add support for 6 counters (AMD family 15h)
2010-12-10 11:49 [PATCH 0/2] oprofile, x86: updates for AMD family 15h systems Robert Richter
2010-12-10 11:49 ` [PATCH 1/2] oprofile, x86: Add support for AMD family 15h Robert Richter
@ 2010-12-10 11:49 ` Robert Richter
2010-12-19 13:27 ` [PATCH 0/2] oprofile, x86: updates for AMD family 15h systems Robert Richter
2 siblings, 0 replies; 5+ messages in thread
From: Robert Richter @ 2010-12-10 11:49 UTC (permalink / raw)
To: Ingo Molnar; +Cc: LKML, oprofile-list, Robert Richter
This patch adds support for up to 6 hardware counters for AMD family
15h cpus. There is a new MSR range for hardware counters beginning at
MSRC001_0200 Performance Event Select (PERF_CTL0).
Signed-off-by: Robert Richter <robert.richter@amd.com>
---
arch/x86/include/asm/msr-index.h | 4 +++
arch/x86/oprofile/op_model_amd.c | 54 +++++++++++++++++++++++++------------
2 files changed, 40 insertions(+), 18 deletions(-)
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 3ea3dc4..e1636d6 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -123,6 +123,10 @@
#define MSR_AMD64_IBSCTL 0xc001103a
#define MSR_AMD64_IBSBRTARGET 0xc001103b
+/* Fam 15h MSRs */
+#define MSR_F15H_PERF_CTL 0xc0010200
+#define MSR_F15H_PERF_CTR 0xc0010201
+
/* Fam 10h MSRs */
#define MSR_FAM10H_MMIO_CONF_BASE 0xc0010058
#define FAM10H_MMIO_CONF_ENABLE (1<<0)
diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
index a011bcc..f2984d4 100644
--- a/arch/x86/oprofile/op_model_amd.c
+++ b/arch/x86/oprofile/op_model_amd.c
@@ -29,11 +29,12 @@
#include "op_x86_model.h"
#include "op_counter.h"
-#define NUM_COUNTERS 4
+#define NUM_COUNTERS 4
+#define NUM_COUNTERS_F15H 6
#ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
-#define NUM_VIRT_COUNTERS 32
+#define NUM_VIRT_COUNTERS 32
#else
-#define NUM_VIRT_COUNTERS NUM_COUNTERS
+#define NUM_VIRT_COUNTERS 0
#endif
#define OP_EVENT_MASK 0x0FFF
@@ -41,7 +42,8 @@
#define MSR_AMD_EVENTSEL_RESERVED ((0xFFFFFCF0ULL<<32)|(1ULL<<21))
-static unsigned long reset_value[NUM_VIRT_COUNTERS];
+static int num_counters;
+static unsigned long reset_value[OP_MAX_COUNTER];
#define IBS_FETCH_SIZE 6
#define IBS_OP_SIZE 12
@@ -387,7 +389,7 @@ static void op_mux_switch_ctrl(struct op_x86_model_spec const *model,
int i;
/* enable active counters */
- for (i = 0; i < NUM_COUNTERS; ++i) {
+ for (i = 0; i < num_counters; ++i) {
int virt = op_x86_phys_to_virt(i);
if (!reset_value[virt])
continue;
@@ -406,7 +408,7 @@ static void op_amd_shutdown(struct op_msrs const * const msrs)
{
int i;
- for (i = 0; i < NUM_COUNTERS; ++i) {
+ for (i = 0; i < num_counters; ++i) {
if (!msrs->counters[i].addr)
continue;
release_perfctr_nmi(MSR_K7_PERFCTR0 + i);
@@ -418,7 +420,7 @@ static int op_amd_fill_in_addresses(struct op_msrs * const msrs)
{
int i;
- for (i = 0; i < NUM_COUNTERS; i++) {
+ for (i = 0; i < num_counters; i++) {
if (!reserve_perfctr_nmi(MSR_K7_PERFCTR0 + i))
goto fail;
if (!reserve_evntsel_nmi(MSR_K7_EVNTSEL0 + i)) {
@@ -426,8 +428,13 @@ static int op_amd_fill_in_addresses(struct op_msrs * const msrs)
goto fail;
}
/* both registers must be reserved */
- msrs->counters[i].addr = MSR_K7_PERFCTR0 + i;
- msrs->controls[i].addr = MSR_K7_EVNTSEL0 + i;
+ if (num_counters == NUM_COUNTERS_F15H) {
+ msrs->counters[i].addr = MSR_F15H_PERF_CTR + (i << 1);
+ msrs->controls[i].addr = MSR_F15H_PERF_CTL + (i << 1);
+ } else {
+ msrs->controls[i].addr = MSR_K7_EVNTSEL0 + i;
+ msrs->counters[i].addr = MSR_K7_PERFCTR0 + i;
+ }
continue;
fail:
if (!counter_config[i].enabled)
@@ -447,7 +454,7 @@ static void op_amd_setup_ctrs(struct op_x86_model_spec const *model,
int i;
/* setup reset_value */
- for (i = 0; i < NUM_VIRT_COUNTERS; ++i) {
+ for (i = 0; i < OP_MAX_COUNTER; ++i) {
if (counter_config[i].enabled
&& msrs->counters[op_x86_virt_to_phys(i)].addr)
reset_value[i] = counter_config[i].count;
@@ -456,7 +463,7 @@ static void op_amd_setup_ctrs(struct op_x86_model_spec const *model,
}
/* clear all counters */
- for (i = 0; i < NUM_COUNTERS; ++i) {
+ for (i = 0; i < num_counters; ++i) {
if (!msrs->controls[i].addr)
continue;
rdmsrl(msrs->controls[i].addr, val);
@@ -472,7 +479,7 @@ static void op_amd_setup_ctrs(struct op_x86_model_spec const *model,
}
/* enable active counters */
- for (i = 0; i < NUM_COUNTERS; ++i) {
+ for (i = 0; i < num_counters; ++i) {
int virt = op_x86_phys_to_virt(i);
if (!reset_value[virt])
continue;
@@ -503,7 +510,7 @@ static int op_amd_check_ctrs(struct pt_regs * const regs,
u64 val;
int i;
- for (i = 0; i < NUM_COUNTERS; ++i) {
+ for (i = 0; i < num_counters; ++i) {
int virt = op_x86_phys_to_virt(i);
if (!reset_value[virt])
continue;
@@ -526,7 +533,7 @@ static void op_amd_start(struct op_msrs const * const msrs)
u64 val;
int i;
- for (i = 0; i < NUM_COUNTERS; ++i) {
+ for (i = 0; i < num_counters; ++i) {
if (!reset_value[op_x86_phys_to_virt(i)])
continue;
rdmsrl(msrs->controls[i].addr, val);
@@ -546,7 +553,7 @@ static void op_amd_stop(struct op_msrs const * const msrs)
* Subtle: stop on all counters to avoid race with setting our
* pm callback
*/
- for (i = 0; i < NUM_COUNTERS; ++i) {
+ for (i = 0; i < num_counters; ++i) {
if (!reset_value[op_x86_phys_to_virt(i)])
continue;
rdmsrl(msrs->controls[i].addr, val);
@@ -698,18 +705,29 @@ static int setup_ibs_files(struct super_block *sb, struct dentry *root)
return 0;
}
+struct op_x86_model_spec op_amd_spec;
+
static int op_amd_init(struct oprofile_operations *ops)
{
init_ibs();
create_arch_files = ops->create_files;
ops->create_files = setup_ibs_files;
+
+ if (boot_cpu_data.x86 == 0x15) {
+ num_counters = NUM_COUNTERS_F15H;
+ } else {
+ num_counters = NUM_COUNTERS;
+ }
+
+ op_amd_spec.num_counters = num_counters;
+ op_amd_spec.num_controls = num_counters;
+ op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
+
return 0;
}
struct op_x86_model_spec op_amd_spec = {
- .num_counters = NUM_COUNTERS,
- .num_controls = NUM_COUNTERS,
- .num_virt_counters = NUM_VIRT_COUNTERS,
+ /* num_counters/num_controls filled in at runtime */
.reserved = MSR_AMD_EVENTSEL_RESERVED,
.event_mask = OP_EVENT_MASK,
.init = op_amd_init,
--
1.7.3.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] oprofile, x86: updates for AMD family 15h systems
2010-12-10 11:49 [PATCH 0/2] oprofile, x86: updates for AMD family 15h systems Robert Richter
2010-12-10 11:49 ` [PATCH 1/2] oprofile, x86: Add support for AMD family 15h Robert Richter
2010-12-10 11:49 ` [PATCH 2/2] oprofile, x86: Add support for 6 counters (AMD family 15h) Robert Richter
@ 2010-12-19 13:27 ` Robert Richter
2 siblings, 0 replies; 5+ messages in thread
From: Robert Richter @ 2010-12-19 13:27 UTC (permalink / raw)
To: Ingo Molnar; +Cc: LKML, oprofile-list
On 10.12.10 06:49:04, Robert Richter wrote:
> (resending due to mail corruption)
>
> This patch set adds support for AMD family 15h systems. It adds cpu
> detection code for family 15h and implements support for 6 counters.
>
> Suravee already sent updates for the oprofile userland to the oprofile
> mailing list.
>
> Please review. If the patches are fine I will apply them to the
> oprofile git repostitory on kernel.org.
I applied the patches to
git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git core
-Robert
--
Advanced Micro Devices, Inc.
Operating System Research Center
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-12-19 13:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-10 11:49 [PATCH 0/2] oprofile, x86: updates for AMD family 15h systems Robert Richter
2010-12-10 11:49 ` [PATCH 1/2] oprofile, x86: Add support for AMD family 15h Robert Richter
2010-12-10 11:49 ` [PATCH 2/2] oprofile, x86: Add support for 6 counters (AMD family 15h) Robert Richter
2010-12-19 13:27 ` [PATCH 0/2] oprofile, x86: updates for AMD family 15h systems Robert Richter
-- strict thread matches above, loose matches on Subject: below --
2010-12-10 11:29 Robert Richter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox