* [PATCH] oprofile: Allow setting EDGE/INV/CMASK for Intel counter events
@ 2011-03-11 19:12 Andi Kleen
2011-03-16 15:04 ` Robert Richter
0 siblings, 1 reply; 6+ messages in thread
From: Andi Kleen @ 2011-03-11 19:12 UTC (permalink / raw)
To: robert.richter; +Cc: linux-kernel, oprofile-list, Andi Kleen
From: Andi Kleen <ak@linux.intel.com>
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.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
arch/x86/oprofile/nmi_int.c | 4 ++++
arch/x86/oprofile/op_counter.h | 1 +
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
index e2b7b0c..bace252 100644
--- a/arch/x86/oprofile/nmi_int.c
+++ b/arch/x86/oprofile/nmi_int.c
@@ -49,6 +49,9 @@ 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;
+ val |= counter_config->extra & (ARCH_PERFMON_EVENTSEL_INV|
+ ARCH_PERFMON_EVENTSEL_EDGE|
+ ARCH_PERFMON_EVENTSEL_CMASK);
event &= model->event_mask ? model->event_mask : 0xFF;
val |= event & 0xFF;
val |= (event & 0x0F00) << 24;
@@ -440,6 +443,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;
diff --git a/arch/x86/oprofile/op_counter.h b/arch/x86/oprofile/op_counter.h
index e28398d..0b7b7b1 100644
--- a/arch/x86/oprofile/op_counter.h
+++ b/arch/x86/oprofile/op_counter.h
@@ -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[];
--
1.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] oprofile: Allow setting EDGE/INV/CMASK for Intel counter events
2011-03-11 19:12 [PATCH] oprofile: Allow setting EDGE/INV/CMASK for Intel counter events Andi Kleen
@ 2011-03-16 15:04 ` Robert Richter
2011-03-16 15:27 ` Andi Kleen
0 siblings, 1 reply; 6+ messages in thread
From: Robert Richter @ 2011-03-16 15:04 UTC (permalink / raw)
To: Andi Kleen
Cc: linux-kernel@vger.kernel.org, oprofile-list@lists.sf.net,
Andi Kleen
On 11.03.11 14:12:28, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> 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.
>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> ---
> arch/x86/oprofile/nmi_int.c | 4 ++++
> arch/x86/oprofile/op_counter.h | 1 +
> 2 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
> index e2b7b0c..bace252 100644
> --- a/arch/x86/oprofile/nmi_int.c
> +++ b/arch/x86/oprofile/nmi_int.c
> @@ -49,6 +49,9 @@ 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;
> + val |= counter_config->extra & (ARCH_PERFMON_EVENTSEL_INV|
> + ARCH_PERFMON_EVENTSEL_EDGE|
> + ARCH_PERFMON_EVENTSEL_CMASK);
I would like to write the actual value back so that userland may read
it:
counter_config->extra &= (ARCH_PERFMON_EVENTSEL_INV|
ARCH_PERFMON_EVENTSEL_EDGE|
ARCH_PERFMON_EVENTSEL_CMASK);
val |= counter_config->extra;
The value will not be updated emmediately but at least after profiling
was started.
As an alternative, maybe we better put this extra bits in the
unit_mask, e.g. in bits [31:16] of the unit mask for bits [31:16] of
PerfEvtSel? Then, we simply could use the current userland to set it
up.
-Robert
--
Advanced Micro Devices, Inc.
Operating System Research Center
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] oprofile: Allow setting EDGE/INV/CMASK for Intel counter events
2011-03-16 15:04 ` Robert Richter
@ 2011-03-16 15:27 ` Andi Kleen
2011-03-16 15:45 ` Robert Richter
0 siblings, 1 reply; 6+ messages in thread
From: Andi Kleen @ 2011-03-16 15:27 UTC (permalink / raw)
To: Robert Richter
Cc: Andi Kleen, linux-kernel@vger.kernel.org,
oprofile-list@lists.sf.net
> I would like to write the actual value back so that userland may read
> it:
>
> counter_config->extra &= (ARCH_PERFMON_EVENTSEL_INV|
> ARCH_PERFMON_EVENTSEL_EDGE|
> ARCH_PERFMON_EVENTSEL_CMASK);
> val |= counter_config->extra;
>
> The value will not be updated emmediately but at least after profiling
> was started.
Okay.
>
> As an alternative, maybe we better put this extra bits in the
> unit_mask, e.g. in bits [31:16] of the unit mask for bits [31:16] of
> PerfEvtSel? Then, we simply could use the current userland to set it
> up.
We can't anyways, it doesn't support it.
-Andi
--
ak@linux.intel.com -- Speaking for myself only
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] oprofile: Allow setting EDGE/INV/CMASK for Intel counter events
2011-03-16 15:27 ` Andi Kleen
@ 2011-03-16 15:45 ` Robert Richter
2011-03-16 16:56 ` Andi Kleen
0 siblings, 1 reply; 6+ messages in thread
From: Robert Richter @ 2011-03-16 15:45 UTC (permalink / raw)
To: Andi Kleen
Cc: Andi Kleen, linux-kernel@vger.kernel.org,
oprofile-list@lists.sf.net
On 16.03.11 11:27:57, Andi Kleen wrote:
> > I would like to write the actual value back so that userland may read
> > it:
> >
> > counter_config->extra &= (ARCH_PERFMON_EVENTSEL_INV|
> > ARCH_PERFMON_EVENTSEL_EDGE|
> > ARCH_PERFMON_EVENTSEL_CMASK);
> > val |= counter_config->extra;
> >
> > The value will not be updated emmediately but at least after profiling
> > was started.
>
> Okay.
>
> >
> > As an alternative, maybe we better put this extra bits in the
> > unit_mask, e.g. in bits [31:16] of the unit mask for bits [31:16] of
> > PerfEvtSel? Then, we simply could use the current userland to set it
> > up.
>
> We can't anyways, it doesn't support it.
Shouldn't something like the follwing work (assuming the umask table
is modified)?
opcontrol --event SOME_EVENT:100000:0x00800000 ...
(setting the INV flag)
-Robert
--
Advanced Micro Devices, Inc.
Operating System Research Center
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] oprofile: Allow setting EDGE/INV/CMASK for Intel counter events
2011-03-16 15:45 ` Robert Richter
@ 2011-03-16 16:56 ` Andi Kleen
2011-03-16 17:00 ` Robert Richter
0 siblings, 1 reply; 6+ messages in thread
From: Andi Kleen @ 2011-03-16 16:56 UTC (permalink / raw)
To: Robert Richter
Cc: Andi Kleen, Andi Kleen, linux-kernel@vger.kernel.org,
oprofile-list@lists.sf.net
> Shouldn't something like the follwing work (assuming the umask table
> is modified)?
>
> opcontrol --event SOME_EVENT:100000:0x00800000 ...
I think there was some problem with this when I tried it.
Besides I'm more interested in using named events for this;
the raw numbers are quite evil. So this needs new user space
in any case.
-Andi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] oprofile: Allow setting EDGE/INV/CMASK for Intel counter events
2011-03-16 16:56 ` Andi Kleen
@ 2011-03-16 17:00 ` Robert Richter
0 siblings, 0 replies; 6+ messages in thread
From: Robert Richter @ 2011-03-16 17:00 UTC (permalink / raw)
To: Andi Kleen
Cc: Andi Kleen, linux-kernel@vger.kernel.org,
oprofile-list@lists.sf.net
On 16.03.11 12:56:34, Andi Kleen wrote:
> > Shouldn't something like the follwing work (assuming the umask table
> > is modified)?
> >
> > opcontrol --event SOME_EVENT:100000:0x00800000 ...
>
> I think there was some problem with this when I tried it.
>
> Besides I'm more interested in using named events for this;
> the raw numbers are quite evil. So this needs new user space
> in any case.
Ok, in this case we can use also /extra. So I am fine with this too.
Thanks,
-Robert
--
Advanced Micro Devices, Inc.
Operating System Research Center
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-03-16 17:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-11 19:12 [PATCH] oprofile: Allow setting EDGE/INV/CMASK for Intel counter events Andi Kleen
2011-03-16 15:04 ` Robert Richter
2011-03-16 15:27 ` Andi Kleen
2011-03-16 15:45 ` Robert Richter
2011-03-16 16:56 ` Andi Kleen
2011-03-16 17:00 ` Robert Richter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox