Skip to contentSkip to conversation

oprofile: re-add force_arch_perfmon option

PATCH In review Andi Kleen 2 participants 5 messages Apr 27, 2009 – May 6, 2009

Subsystems (2)
lore
Share & tools
lore
author
#1 lore raw

PATCH 2/3 oprofile: remove undocumented oprofile.p4force option

In reply to Andi Kleen

There are no new P4s and the oprofile code knows about all existing ones, so we don't really need the p4force option anymore.

Remove it.

---
 arch/x86/oprofile/nmi_int.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
arch/x86/oprofile/nmi_int.c +1 -4
Index: linux-2.6.28-test/arch/x86/oprofile/nmi_int.c
===================================================================
@@ -356,14 +356,11 @@
 #define exit_sysfs() do { } while (0)
 #endif /* CONFIG_PM */
 
-static int p4force;
-module_param(p4force, int, 0);
-
 static int __init p4_init(char **cpu_type)
 {
 	__u8 cpu_model = boot_cpu_data.x86_model;
 
-	if (!p4force && (cpu_model > 6 || cpu_model == 5))
+	if (cpu_model > 6 || cpu_model == 5)
 		return 0;
 
 #ifndef CONFIG_SMP

Andi Kleen

author
#0 lore raw

PATCH 1/3 oprofile: re-add force_arch_perfmon option

This re-adds the force_arch_perfmon option that was in the original arch perfmon patchkit. Originally this was rejected in favour of a generalized perfmon=name option, but it turned out implementing the later in a reliable way is hard (and it would have been easy to crash the kernel if a user gets it wrong)

But now Atom and Core i7 support being readded a user would
need to update their oprofile userland to beyond 0.9.4 to use oprofile again on Atom or Core i7.

To avoid this problem readd the force_arch_perfmon option.

---
 Documentation/kernel-parameters.txt |    6 ++++++
 arch/x86/oprofile/nmi_int.c         |    6 ++++++
 2 files changed, 12 insertions(+)
Documentation/kernel-parameters.txt +6 -0
Index: linux-2.6.30-rc3-ak/Documentation/kernel-parameters.txt
===================================================================
@@ -1648,6 +1648,12 @@
 	oprofile.timer=	[HW]
 			Use timer interrupt instead of performance counters
 
+	oprofile.force_arch_perfmon=1	[X86]
+			Force use of architectural perfmon instead of
+			the CPU specific event set.
+			This might be useful if you have older oprofile
+			userland or if you want common events over Intel CPUs.
+
 	osst=		[HW,SCSI] SCSI Tape Driver
 			Format: <buffer_size>,<write_threshold>
 			See also Documentation/scsi/st.txt.
arch/x86/oprofile/nmi_int.c +6 -0
Index: linux-2.6.30-rc3-ak/arch/x86/oprofile/nmi_int.c
===================================================================
@@ -389,10 +389,16 @@
 	return 0;
 }
 
+int force_arch_perfmon;
+module_param(force_arch_perfmon, int, 0);
+
 static int __init ppro_init(char **cpu_type)
 {
 	__u8 cpu_model = boot_cpu_data.x86_model;
 
+	if (force_arch_perfmon && cpu_has_arch_perfmon)
+		return 0;
+
 	switch (cpu_model) {
 	case 0 ... 2:
 		*cpu_type = "i386/ppro";
author
#2 lore raw

PATCH 3/3 oprofile: add support for Core i7 and Atom

The registers are about the same as other Family 6 CPUs so we only need to add detection.

I'm not completely happy with calling Nehalem Core i7 because there will be undoubtedly other Nehalem based CPUs in the future with different marketing names, but it's the best we got for now.

Requires updated oprofile userland for the new event files.

If you don't want to update right now you can also use oprofile.force_arch_perfmon=1 (added in the next patch) with 0.9.4

---
 arch/x86/oprofile/nmi_int.c |    7 +++++++
 1 file changed, 7 insertions(+)
arch/x86/oprofile/nmi_int.c +7 -0
Index: linux-2.6.30-rc3-ak/arch/x86/oprofile/nmi_int.c
===================================================================
@@ -417,6 +417,13 @@
 	case 15: case 23:
 		*cpu_type = "i386/core_2";
 		break;
+	case 26:
+		arch_perfmon_setup_counters();
+		*cpu_type = "i386/core_i7";
+		break;
+	case 28:
+		*cpu_type = "i386/atom";
+		break;
 	default:
 		/* Unknown */
 		return 0;
#3 lore raw
In reply to Andi Kleen

Andi,

I applied your patches. Please see my follow on patches and test them.

Thanks,

-Robert

Quoted 58 lines · Andi Kleen

This re-adds the force_arch_perfmon option that was in the original arch perfmon patchkit. Originally this was rejected in favour of a generalized perfmon=name option, but it turned out implementing the later in a reliable way is hard (and it would have been easy to crash the kernel if a user gets it wrong)

But now Atom and Core i7 support being readded a user would
need to update their oprofile userland to beyond 0.9.4 to use oprofile again on Atom or Core i7.

To avoid this problem readd the force_arch_perfmon option.

---
 Documentation/kernel-parameters.txt |    6 ++++++
 arch/x86/oprofile/nmi_int.c         |    6 ++++++
 2 files changed, 12 insertions(+)

Index: linux-2.6.30-rc3-ak/Documentation/kernel-parameters.txt
===================================================================

Documentation/kernel-parameters.txt +6 -0
@@ -1648,6 +1648,12 @@
 	oprofile.timer=	[HW]
 			Use timer interrupt instead of performance counters
 
+	oprofile.force_arch_perfmon=1	[X86]
+			Force use of architectural perfmon instead of
+			the CPU specific event set.
+			This might be useful if you have older oprofile
+			userland or if you want common events over Intel CPUs.
+
 	osst=		[HW,SCSI] SCSI Tape Driver
 			Format: <buffer_size>,<write_threshold>
 			See also Documentation/scsi/st.txt.

Index: linux-2.6.30-rc3-ak/arch/x86/oprofile/nmi_int.c
===================================================================

arch/x86/oprofile/nmi_int.c +6 -0
@@ -389,10 +389,16 @@
 	return 0;
 }
 
+int force_arch_perfmon;
+module_param(force_arch_perfmon, int, 0);
+
 static int __init ppro_init(char **cpu_type)
 {
 	__u8 cpu_model = boot_cpu_data.x86_model;
 
+	if (force_arch_perfmon && cpu_has_arch_perfmon)
+		return 0;
+
 	switch (cpu_model) {
 	case 0 ... 2:
 		*cpu_type = "i386/ppro";
Signature · 3 lines
Advanced Micro Devices, Inc.
Operating System Research Center
email: [email protected]
author
#4 lore raw
Quoted 3 lines · Robert Richter

Andi,

I applied your patches. Please see my follow on patches and test them.

Thanks.

-Andi

Signature · 1 line
[email protected] -- Speaking for myself only.