Skip to contentSkip to conversation

oprofile: introduce module parameter oprofile.cpu_type

PATCH In review Robert Richter 2 participants 6 messages May 6, 2009 – Jun 10, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover oprofile: introduce module parameter oprofile.cpu_type

The current userland does not yet fully support all cpu types implemented in the kernel. With the module parameter oprofile.cpu_type a certain cpu type can be reported to the oprofile userland and thus makes the kernel usable with current distros.

The event table may not match fully, so care must be taken when using this parameter.

See also this description:

oprofile.cpu_type= Force an oprofile cpu type
This might be useful if you have an older oprofile userland or if you want common events.
Format: { archperfmon | core_2 }
archperfmon: [X86] Force use of architectural
perfmon on Intel CPUs instead of the CPU specific event set.
core_2: [X86] On Intel systems: report core_2 CPU.

Together with Andi's patches the patch set is also in this tree:

git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git fixes

The fixes are intended for v2.6.30.

Andi, please let me now if this works for you and if things can go upstream this way.

-Robert

#1 lore raw

PATCH 1/2 oprofile: introduce module_param oprofile.cpu_type

This patch removes module_param oprofile.force_arch_perfmon and introduces oprofile.cpu_type=archperfmon instead. This new parameter can be reused for other models and architectures.

Currently only archperfmon is supported.

---
 Documentation/kernel-parameters.txt |   12 +++++++-----
 arch/x86/oprofile/nmi_int.c         |   13 +++++++++++--
 2 files changed, 18 insertions(+), 7 deletions(-)
Documentation/kernel-parameters.txt +7 -5
index 9b9566b..6ce5f48 100644
@@ -1650,11 +1650,13 @@ and is between 256 and 4096 characters. It is defined in the file
 	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.
+	oprofile.cpu_type=	Force an oprofile cpu type
+			This might be useful if you have an older oprofile
+			userland or if you want common events.
+			Format: { archperfmon }
+			archperfmon: [X86] Force use of architectural
+				perfmon on Intel CPUs instead of the
+				CPU specific event set.
 
 	osst=		[HW,SCSI] SCSI Tape Driver
 			Format: <buffer_size>,<write_threshold>
arch/x86/oprofile/nmi_int.c +11 -2
index 3308147..3b285e6 100644
@@ -386,8 +386,17 @@ static int __init p4_init(char **cpu_type)
 	return 0;
 }
 
-int force_arch_perfmon;
-module_param(force_arch_perfmon, int, 0);
+static int force_arch_perfmon;
+static int force_cpu_type(const char *str, struct kernel_param *kp)
+{
+	if (!strcmp(str, "archperfmon")) {
+		force_arch_perfmon = 1;
+		printk(KERN_INFO "oprofile: forcing architectural perfmon\n");
+	}
+
+	return 0;
+}
+module_param_call(cpu_type, force_cpu_type, NULL, NULL, 0);
 
 static int __init ppro_init(char **cpu_type)
 {
Signature · 1 line
1.6.1.3
#2 lore raw

PATCH 2/2 x86/oprofile: add module parameter option to force a core 2 cpu

In reply to Robert Richter

The current userland does not yet fully support all cpu types implemented in the kernel. With the module parameter:

oprofile.cpu_type=core_2

the kernel reports a core_2 cpu to the userland on an Intel system and thus makes oprofile usable with current distros.

Cc Linus Torvalds <[email protected]>
Cc Andi Kleen <[email protected]>
---
 Documentation/kernel-parameters.txt |    3 ++-
 arch/x86/oprofile/nmi_int.c         |   17 ++++++++++++++---
 2 files changed, 16 insertions(+), 4 deletions(-)
Documentation/kernel-parameters.txt +2 -1
index 6ce5f48..ea7ead3 100644
@@ -1653,10 +1653,11 @@ and is between 256 and 4096 characters. It is defined in the file
 	oprofile.cpu_type=	Force an oprofile cpu type
 			This might be useful if you have an older oprofile
 			userland or if you want common events.
-			Format: { archperfmon }
+			Format: { archperfmon | core_2 }
 			archperfmon: [X86] Force use of architectural
 				perfmon on Intel CPUs instead of the
 				CPU specific event set.
+			core_2: [X86] On Intel systems: report core_2 CPU.
 
 	osst=		[HW,SCSI] SCSI Tape Driver
 			Format: <buffer_size>,<write_threshold>
arch/x86/oprofile/nmi_int.c +14 -3
index 3b285e6..d7348a2 100644
@@ -386,12 +386,20 @@ static int __init p4_init(char **cpu_type)
 	return 0;
 }
 
-static int force_arch_perfmon;
+static enum {
+	NONE = 0,
+	ARCH_PERFMON,
+	CORE_2,
+} forced_cpu;
+
 static int force_cpu_type(const char *str, struct kernel_param *kp)
 {
 	if (!strcmp(str, "archperfmon")) {
-		force_arch_perfmon = 1;
+		forced_cpu = ARCH_PERFMON;
 		printk(KERN_INFO "oprofile: forcing architectural perfmon\n");
+	} else if (!strcmp(str, "core_2")) {
+		forced_cpu = CORE_2;
+		printk(KERN_INFO "oprofile: forcing core_2\n");
 	}
 
 	return 0;
@@ -402,9 +410,12 @@ static int __init ppro_init(char **cpu_type)
 {
 	__u8 cpu_model = boot_cpu_data.x86_model;
 
-	if (force_arch_perfmon && cpu_has_arch_perfmon)
+	if (forced_cpu == ARCH_PERFMON && cpu_has_arch_perfmon)
 		return 0;
 
+	if (forced_cpu == CORE_2)
+		cpu_model = 15;
+
 	switch (cpu_model) {
 	case 0 ... 2:
 		*cpu_type = "i386/ppro";
Signature · 1 line
1.6.1.3
#3 lore raw
In reply to Robert Richter
Quoted 4 lines · Robert Richter

The current userland does not yet fully support all cpu types implemented in the kernel. With the module parameter oprofile.cpu_type a certain cpu type can be reported to the oprofile userland and thus makes the kernel usable with current distros.

On Intel systems forcing archperfmon is the only one that makes sense nd only if the CPU supports arch perfmon(btw that's already in my patchkit which you haven't commented on so far)

I don't thinking forcing core2 on a system like Nehalem with completely different events is a good idea though. This just means if the user selects anything unusual they will get junk data, which is just a bad design.

Also if you force core2 on a P4 system the kernel will just oops because it will access MSRs that are not there. So I don't think that's a good idea.

It means you have to update oprofile userland at least once until you have arch perfmon support, but I think even Linus will be able to do that :) Hopefully Maynard will do a new release soon.

The force of core2 is nacked from my side.

-Andi

Signature · 1 line
[email protected] -- Speaking for myself only.
#4 lore raw
Quoted 6 lines · Andi Kleen
Quoted 4 lines · Robert Richter

The current userland does not yet fully support all cpu types implemented in the kernel. With the module parameter oprofile.cpu_type a certain cpu type can be reported to the oprofile userland and thus makes the kernel usable with current distros.

Quoted 8 lines

On Intel systems forcing archperfmon is the only one that makes sense nd only if the CPU supports arch perfmon(btw that's already in my patchkit which you haven't commented on so far)

I don't thinking forcing core2 on a system like Nehalem with completely different events is a good idea though. This just means if the user selects anything unusual they will get junk data, which is just a bad design.

It is a kernel parameter, and users should know what they are doing and what the risks are. I assume counting cpu clk unhalted will work and some other events too. So the patch does not hurt.

Quoted 3 lines

Also if you force core2 on a P4 system the kernel will just oops because it will access MSRs that are not there. So I don't think that's a good idea.

It anables core_2 only on family 6 (ppro implementation).

Quoted 4 lines

It means you have to update oprofile userland at least once until you have arch perfmon support, but I think even Linus will be able to do that :) Hopefully Maynard will do a new release soon.

I agree, a new release of the userland would be the best. But till then it is at least 1-2 months to go.

Quoted 1 line

The force of core2 is nacked from my side.

I do not have any passion with this patch, What I have in mind is "oprofile sucks", and this patch would make oprofile more usable.

-Robert

Signature · 3 lines
Advanced Micro Devices, Inc.
Operating System Research Center
email: [email protected]