linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf, p4: Add format attributes
@ 2012-03-27 14:50 Peter Zijlstra
  2012-03-27 14:57 ` Cyrill Gorcunov
  2012-04-03  8:11 ` [tip:perf/urgent] perf/x86/p4: " tip-bot for Peter Zijlstra
  0 siblings, 2 replies; 10+ messages in thread
From: Peter Zijlstra @ 2012-03-27 14:50 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Jiri Olsa, Cyrill Gorcunov, Lin Ming, rostedt, linux-kernel,
	Stephane Eranian

Subject: perf, p4: Add format attributes
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
Date: Tue Mar 27 16:19:25 CEST 2012

Steven reported his P4 not booting properly, the missing format
attributes cause a NULL ptr deref. Cure this by adding the missing
format specification.

I took the format description out of the comment near 
p4_config_pack*() and hope that comment is still relatively 
accurate.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Lin Ming <ming.m.lin@intel.com>
Reported-by: Steven Rostedt <rostedt@goodmis.org>
Tested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 arch/x86/kernel/cpu/perf_event_p4.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

--- a/arch/x86/kernel/cpu/perf_event_p4.c
+++ b/arch/x86/kernel/cpu/perf_event_p4.c
@@ -1271,6 +1271,17 @@ static int p4_pmu_schedule_events(struct
 	return num ? -EINVAL : 0;
 }
 
+PMU_FORMAT_ATTR(cccr, "config:0-31" );
+PMU_FORMAT_ATTR(escr, "config:32-62");
+PMU_FORMAT_ATTR(ht,   "config:63"   );
+
+static struct attribute *intel_p4_formats_attr[] = {
+	&format_attr_cccr.attr,
+	&format_attr_escr.attr,
+	&format_attr_ht.attr,
+	NULL,
+};
+
 static __initconst const struct x86_pmu p4_pmu = {
 	.name			= "Netburst P4/Xeon",
 	.handle_irq		= p4_pmu_handle_irq,
@@ -1305,6 +1316,8 @@ static __initconst const struct x86_pmu
 	 * the former idea is taken from OProfile code
 	 */
 	.perfctr_second_write	= 1,
+
+	.format_attrs		= intel_p4_formats_attr,
 };
 
 __init int p4_pmu_init(void)


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] perf, p4: Add format attributes
  2012-03-27 14:50 [PATCH] perf, p4: Add format attributes Peter Zijlstra
@ 2012-03-27 14:57 ` Cyrill Gorcunov
  2012-03-27 15:05   ` Cyrill Gorcunov
  2012-03-27 15:05   ` Peter Zijlstra
  2012-04-03  8:11 ` [tip:perf/urgent] perf/x86/p4: " tip-bot for Peter Zijlstra
  1 sibling, 2 replies; 10+ messages in thread
From: Cyrill Gorcunov @ 2012-03-27 14:57 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Ingo Molnar, Jiri Olsa, Lin Ming, rostedt, linux-kernel,
	Stephane Eranian

On Tue, Mar 27, 2012 at 04:50:42PM +0200, Peter Zijlstra wrote:
> Subject: perf, p4: Add format attributes
> From: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Date: Tue Mar 27 16:19:25 CEST 2012
> 
> Steven reported his P4 not booting properly, the missing format
> attributes cause a NULL ptr deref. Cure this by adding the missing
> format specification.
> 
> I took the format description out of the comment near 
> p4_config_pack*() and hope that comment is still relatively 
> accurate.
> 
> Cc: Cyrill Gorcunov <gorcunov@openvz.org>
> Cc: Lin Ming <ming.m.lin@intel.com>
> Reported-by: Steven Rostedt <rostedt@goodmis.org>
> Tested-by: Steven Rostedt <rostedt@goodmis.org>
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>

Thanks a lot, Peter! This format description is somewhat
new to me (I think I've missed when it was introduced first
time).

Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>

	Cyrill

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] perf, p4: Add format attributes
  2012-03-27 14:57 ` Cyrill Gorcunov
@ 2012-03-27 15:05   ` Cyrill Gorcunov
  2012-03-27 15:05   ` Peter Zijlstra
  1 sibling, 0 replies; 10+ messages in thread
From: Cyrill Gorcunov @ 2012-03-27 15:05 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Jiri Olsa, Lin Ming, rostedt,
	linux-kernel, Stephane Eranian

On Tue, Mar 27, 2012 at 06:57:28PM +0400, Cyrill Gorcunov wrote:
> 
> Thanks a lot, Peter! This format description is somewhat
> new to me (I think I've missed when it was introduced first
> time).

By format description I mean of course PMU_FORMAT_ATTR :)

	Cyrill

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] perf, p4: Add format attributes
  2012-03-27 14:57 ` Cyrill Gorcunov
  2012-03-27 15:05   ` Cyrill Gorcunov
@ 2012-03-27 15:05   ` Peter Zijlstra
  2012-03-27 15:07     ` Peter Zijlstra
  2012-03-27 15:12     ` Cyrill Gorcunov
  1 sibling, 2 replies; 10+ messages in thread
From: Peter Zijlstra @ 2012-03-27 15:05 UTC (permalink / raw)
  To: Cyrill Gorcunov
  Cc: Ingo Molnar, Jiri Olsa, Lin Ming, rostedt, linux-kernel,
	Stephane Eranian

On Tue, 2012-03-27 at 18:57 +0400, Cyrill Gorcunov wrote:
> On Tue, Mar 27, 2012 at 04:50:42PM +0200, Peter Zijlstra wrote:
> > Subject: perf, p4: Add format attributes
> > From: Peter Zijlstra <a.p.zijlstra@chello.nl>
> > Date: Tue Mar 27 16:19:25 CEST 2012
> > 
> > Steven reported his P4 not booting properly, the missing format
> > attributes cause a NULL ptr deref. Cure this by adding the missing
> > format specification.
> > 
> > I took the format description out of the comment near 
> > p4_config_pack*() and hope that comment is still relatively 
> > accurate.
> > 
> > Cc: Cyrill Gorcunov <gorcunov@openvz.org>
> > Cc: Lin Ming <ming.m.lin@intel.com>
> > Reported-by: Steven Rostedt <rostedt@goodmis.org>
> > Tested-by: Steven Rostedt <rostedt@goodmis.org>
> > Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
> 
> Thanks a lot, Peter! This format description is somewhat
> new to me (I think I've missed when it was introduced first
> time).

Yeah, its all brand-spanking new stuff.. see
https://lkml.org/lkml/2012/1/16/146 , Jiri added a full fledged
bison/yacc parser to perf so we can now write events like:

perf stat -e cpu/event=0xb7,umask=0x01,offcore_rsp=0x500b/

and it uses /sys/bus/event_source/devices/cpu/format/* to figure out how
to convert that into perf_event_attr::config{,1,2} values.

So with this patch you could, on your P4, write:

perf stat -e cpu/cccr=0x1234,escr=0x4321,ht/

and it would construct the perf_event_attr::config value 0x92344321 for
you.

I've still not actually read the P4-PMU specs, so I don't know if
there's anything more convenient we can do on P4. If there's a
better/more useful format representation possible, don't hesitate to
send a patch! :-)

> Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>

Thanks!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] perf, p4: Add format attributes
  2012-03-27 15:05   ` Peter Zijlstra
@ 2012-03-27 15:07     ` Peter Zijlstra
  2012-03-27 15:12     ` Cyrill Gorcunov
  1 sibling, 0 replies; 10+ messages in thread
From: Peter Zijlstra @ 2012-03-27 15:07 UTC (permalink / raw)
  To: Cyrill Gorcunov
  Cc: Ingo Molnar, Jiri Olsa, Lin Ming, rostedt, linux-kernel,
	Stephane Eranian

On Tue, 2012-03-27 at 17:05 +0200, Peter Zijlstra wrote:
> perf stat -e cpu/cccr=0x1234,escr=0x4321,ht/
> 
> and it would construct the perf_event_attr::config value 0x92344321
> for
> you. 

Or rather, 0xc3211234, I got cccr and escr reversed.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] perf, p4: Add format attributes
  2012-03-27 15:05   ` Peter Zijlstra
  2012-03-27 15:07     ` Peter Zijlstra
@ 2012-03-27 15:12     ` Cyrill Gorcunov
  2012-03-27 22:03       ` Cyrill Gorcunov
  1 sibling, 1 reply; 10+ messages in thread
From: Cyrill Gorcunov @ 2012-03-27 15:12 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Ingo Molnar, Jiri Olsa, Lin Ming, rostedt, linux-kernel,
	Stephane Eranian

On Tue, Mar 27, 2012 at 05:05:59PM +0200, Peter Zijlstra wrote:
> > 
> > Thanks a lot, Peter! This format description is somewhat
> > new to me (I think I've missed when it was introduced first
> > time).
> 
> Yeah, its all brand-spanking new stuff.. see
> https://lkml.org/lkml/2012/1/16/146 , Jiri added a full fledged
> bison/yacc parser to perf so we can now write events like:
> 
> perf stat -e cpu/event=0xb7,umask=0x01,offcore_rsp=0x500b/
> 
> and it uses /sys/bus/event_source/devices/cpu/format/* to figure out how
> to convert that into perf_event_attr::config{,1,2} values.
> 
> So with this patch you could, on your P4, write:
> 
> perf stat -e cpu/cccr=0x1234,escr=0x4321,ht/
> 
> and it would construct the perf_event_attr::config value 0x92344321 for
> you.
> 

Ah, I see thanks for the reference, Peter!

> I've still not actually read the P4-PMU specs, so I don't know if
> there's anything more convenient we can do on P4. If there's a
> better/more useful format representation possible, don't hesitate to
> send a patch! :-)

Sure, I'll try to find some time tonight to read this brand
new stuff. And if I find something -- will send out. At moment
your patch should be more than enough ;)

	Cyrill

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] perf, p4: Add format attributes
  2012-03-27 15:12     ` Cyrill Gorcunov
@ 2012-03-27 22:03       ` Cyrill Gorcunov
  2012-03-27 22:05         ` Peter Zijlstra
  0 siblings, 1 reply; 10+ messages in thread
From: Cyrill Gorcunov @ 2012-03-27 22:03 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Ingo Molnar, Jiri Olsa, Lin Ming, rostedt, linux-kernel,
	Stephane Eranian

On Tue, Mar 27, 2012 at 07:12:50PM +0400, Cyrill Gorcunov wrote:
> 
> Ah, I see thanks for the reference, Peter!
> 
> > I've still not actually read the P4-PMU specs, so I don't know if
> > there's anything more convenient we can do on P4. If there's a
> > better/more useful format representation possible, don't hesitate to
> > send a patch! :-)
> 
> Sure, I'll try to find some time tonight to read this brand
> new stuff. And if I find something -- will send out. At moment
> your patch should be more than enough ;)

Hi, Peter, sorry for delay,

after looking some more I think ht bit might be dropped from
the format, it's used internally by the kernel in attmept to
eliminate redundant msr poking if new event runs on the same
thread as previous one, and it's always cleared before real
write to msr happens, which means user-space might set or
clear it, but it never be considered by the kernel.

(still my earlier reviewed-by is valid because this ht bit
 is harmless ;)

	Cyrill

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] perf, p4: Add format attributes
  2012-03-27 22:03       ` Cyrill Gorcunov
@ 2012-03-27 22:05         ` Peter Zijlstra
  2012-03-27 22:11           ` Cyrill Gorcunov
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Zijlstra @ 2012-03-27 22:05 UTC (permalink / raw)
  To: Cyrill Gorcunov
  Cc: Ingo Molnar, Jiri Olsa, Lin Ming, rostedt, linux-kernel,
	Stephane Eranian

On Wed, 2012-03-28 at 02:03 +0400, Cyrill Gorcunov wrote:
> On Tue, Mar 27, 2012 at 07:12:50PM +0400, Cyrill Gorcunov wrote:
> > 
> > Ah, I see thanks for the reference, Peter!
> > 
> > > I've still not actually read the P4-PMU specs, so I don't know if
> > > there's anything more convenient we can do on P4. If there's a
> > > better/more useful format representation possible, don't hesitate to
> > > send a patch! :-)
> > 
> > Sure, I'll try to find some time tonight to read this brand
> > new stuff. And if I find something -- will send out. At moment
> > your patch should be more than enough ;)
> 
> Hi, Peter, sorry for delay,
> 
> after looking some more I think ht bit might be dropped from
> the format, it's used internally by the kernel in attmept to
> eliminate redundant msr poking if new event runs on the same
> thread as previous one, and it's always cleared before real
> write to msr happens, which means user-space might set or
> clear it, but it never be considered by the kernel.
> 
> (still my earlier reviewed-by is valid because this ht bit
>  is harmless ;)

So does that make escr:32-62 or should that become 32-63 ?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] perf, p4: Add format attributes
  2012-03-27 22:05         ` Peter Zijlstra
@ 2012-03-27 22:11           ` Cyrill Gorcunov
  0 siblings, 0 replies; 10+ messages in thread
From: Cyrill Gorcunov @ 2012-03-27 22:11 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Ingo Molnar, Jiri Olsa, Lin Ming, rostedt, linux-kernel,
	Stephane Eranian

On Wed, Mar 28, 2012 at 12:05:05AM +0200, Peter Zijlstra wrote:
> 
> So does that make escr:32-62 or should that become 32-63 ?

32-63 I think will be better, because it's raw format for
escr, simply 63 bit is never used in hw level so we borrowed
it for own needs.

	Cyrill

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [tip:perf/urgent] perf/x86/p4: Add format attributes
  2012-03-27 14:50 [PATCH] perf, p4: Add format attributes Peter Zijlstra
  2012-03-27 14:57 ` Cyrill Gorcunov
@ 2012-04-03  8:11 ` tip-bot for Peter Zijlstra
  1 sibling, 0 replies; 10+ messages in thread
From: tip-bot for Peter Zijlstra @ 2012-04-03  8:11 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, eranian, bonbons, hpa, mingo, gorcunov,
	a.p.zijlstra, jolsa, rostedt, ming.m.lin, tglx

Commit-ID:  7b8e6da46b921d30ac1553cac56d8fb74f0b431d
Gitweb:     http://git.kernel.org/tip/7b8e6da46b921d30ac1553cac56d8fb74f0b431d
Author:     Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Tue, 27 Mar 2012 16:50:42 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 3 Apr 2012 08:33:38 +0200

perf/x86/p4: Add format attributes

Steven reported his P4 not booting properly, the missing format
attributes cause a NULL ptr deref. Cure this by adding the
missing format specification.

I took the format description out of the comment near
p4_config_pack*() and hope that comment is still relatively
accurate.

Reported-by: Steven Rostedt <rostedt@goodmis.org>
Reported-by: Bruno Prémont <bonbons@linux-vserver.org>
Tested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Lin Ming <ming.m.lin@intel.com>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1332859842.16159.227.camel@twins
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/cpu/perf_event_p4.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_p4.c b/arch/x86/kernel/cpu/perf_event_p4.c
index ef484d9..a2dfacf 100644
--- a/arch/x86/kernel/cpu/perf_event_p4.c
+++ b/arch/x86/kernel/cpu/perf_event_p4.c
@@ -1271,6 +1271,17 @@ done:
 	return num ? -EINVAL : 0;
 }
 
+PMU_FORMAT_ATTR(cccr, "config:0-31" );
+PMU_FORMAT_ATTR(escr, "config:32-62");
+PMU_FORMAT_ATTR(ht,   "config:63"   );
+
+static struct attribute *intel_p4_formats_attr[] = {
+	&format_attr_cccr.attr,
+	&format_attr_escr.attr,
+	&format_attr_ht.attr,
+	NULL,
+};
+
 static __initconst const struct x86_pmu p4_pmu = {
 	.name			= "Netburst P4/Xeon",
 	.handle_irq		= p4_pmu_handle_irq,
@@ -1305,6 +1316,8 @@ static __initconst const struct x86_pmu p4_pmu = {
 	 * the former idea is taken from OProfile code
 	 */
 	.perfctr_second_write	= 1,
+
+	.format_attrs		= intel_p4_formats_attr,
 };
 
 __init int p4_pmu_init(void)

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-04-03  8:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-27 14:50 [PATCH] perf, p4: Add format attributes Peter Zijlstra
2012-03-27 14:57 ` Cyrill Gorcunov
2012-03-27 15:05   ` Cyrill Gorcunov
2012-03-27 15:05   ` Peter Zijlstra
2012-03-27 15:07     ` Peter Zijlstra
2012-03-27 15:12     ` Cyrill Gorcunov
2012-03-27 22:03       ` Cyrill Gorcunov
2012-03-27 22:05         ` Peter Zijlstra
2012-03-27 22:11           ` Cyrill Gorcunov
2012-04-03  8:11 ` [tip:perf/urgent] perf/x86/p4: " tip-bot for Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).