Skip to contentSkip to conversation

oprofile: Allow setting EDGE/INV/CMASK for Intel counter events v2

PATCH In review Andi Kleen 2 participants 2 messages Mar 16, 2011 – Mar 24, 2011 x86

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 oprofile: Allow setting EDGE/INV/CMASK for Intel counter events v2

From: Andi Kleen <[email protected]>

For some performance events it's useful to set the EDGE and INV bits and the CMASK mask in the counter control register. The list of predefined events Intel releases for each CPU has some events which require these settings to get more "natural" to use higher level events.

oprofile currently doesn't allow this.

This patch adds new extra configuration fields for them, so that they can be specified in oprofilefs.

An updated oprofile daemon can then make use of this to set them.

v2: Write back masked extra value to variable.

---
 arch/x86/oprofile/nmi_int.c    |    5 +++++
 arch/x86/oprofile/op_counter.h |    1 +
 2 files changed, 6 insertions(+), 0 deletions(-)
arch/x86/oprofile/nmi_int.c +5 -0
index e2b7b0c..ee165f1 100644
@@ -49,6 +49,10 @@ u64 op_x86_get_ctrl(struct op_x86_model_spec const *model,
 	val |= counter_config->user ? ARCH_PERFMON_EVENTSEL_USR : 0;
 	val |= counter_config->kernel ? ARCH_PERFMON_EVENTSEL_OS : 0;
 	val |= (counter_config->unit_mask & 0xFF) << 8;
+	counter_config->extra &= (ARCH_PERFMON_EVENTSEL_INV |
+				  ARCH_PERFMON_EVENTSEL_EDGE |
+				  ARCH_PERFMON_EVENTSEL_CMASK);
+	val |= counter_config->extra;
 	event &= model->event_mask ? model->event_mask : 0xFF;
 	val |= event & 0xFF;
 	val |= (event & 0x0F00) << 24;
@@ -440,6 +444,7 @@ static int nmi_create_files(struct super_block *sb, struct dentry *root)
 		oprofilefs_create_ulong(sb, dir, "unit_mask", &counter_config[i].unit_mask);
 		oprofilefs_create_ulong(sb, dir, "kernel", &counter_config[i].kernel);
 		oprofilefs_create_ulong(sb, dir, "user", &counter_config[i].user);
+		oprofilefs_create_ulong(sb, dir, "extra", &counter_config[i].extra);
 	}
 
 	return 0;
arch/x86/oprofile/op_counter.h +1 -0
index e28398d..0b7b7b1 100644
@@ -22,6 +22,7 @@ struct op_counter_config {
 	unsigned long kernel;
 	unsigned long user;
 	unsigned long unit_mask;
+	unsigned long extra;
 };
 
 extern struct op_counter_config counter_config[];
Signature · 1 line
1.7.4
#1 lore raw
Quoted 12 lines · Andi Kleen

From: Andi Kleen <[email protected]>

For some performance events it's useful to set the EDGE and INV bits and the CMASK mask in the counter control register. The list of predefined events Intel releases for each CPU has some events which require these settings to get more "natural" to use higher level events.

oprofile currently doesn't allow this.

This patch adds new extra configuration fields for them, so that they can be specified in oprofilefs.

Quoted 8 lines

An updated oprofile daemon can then make use of this to set them.

v2: Write back masked extra value to variable.

---
 arch/x86/oprofile/nmi_int.c    |    5 +++++
 arch/x86/oprofile/op_counter.h |    1 +
 2 files changed, 6 insertions(+), 0 deletions(-)

Applied to

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

Thanks Andi,

-Robert

Signature · 2 lines
Advanced Micro Devices, Inc.
Operating System Research Center