linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6][v3] perf/Power7: Use macros to identify perf events
@ 2013-01-10  1:03 Sukadev Bhattiprolu
  2013-01-10  1:04 ` [PATCH 2/6][v3] perf: Make EVENT_ATTR global Sukadev Bhattiprolu
                   ` (5 more replies)
  0 siblings, 6 replies; 17+ messages in thread
From: Sukadev Bhattiprolu @ 2013-01-10  1:03 UTC (permalink / raw)
  To: Peter Zijlstra, Paul Mackerras, Ingo Molnar
  Cc: Andi Kleen, robert.richter, Anton Blanchard, linux-kernel,
	Stephane Eranian, linuxppc-dev, Arnaldo Carvalho de Melo,
	Jiri Olsa

[PATCH 1/6][v3] perf/Power7: Use macros to identify perf events

Define and use macros to identify perf events codes. This would make it
easier and more readable when these event codes need to be used in more
than one place.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
 arch/powerpc/perf/power7-pmu.c |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/perf/power7-pmu.c b/arch/powerpc/perf/power7-pmu.c
index 441af08..44e70d2 100644
--- a/arch/powerpc/perf/power7-pmu.c
+++ b/arch/powerpc/perf/power7-pmu.c
@@ -51,6 +51,18 @@
 #define MMCR1_PMCSEL_MSK	0xff
 
 /*
+ * Power7 event codes.
+ */
+#define	PME_PM_CYC			0x1e
+#define	PME_PM_GCT_NOSLOT_CYC		0x100f8
+#define	PME_PM_CMPLU_STALL		0x4000a
+#define	PME_PM_INST_CMPL		0x2
+#define	PME_PM_LD_REF_L1		0xc880
+#define	PME_PM_LD_MISS_L1		0x400f0
+#define	PME_PM_BRU_FIN			0x10068
+#define	PME_PM_BRU_MPRED		0x400f6
+
+/*
  * Layout of constraint bits:
  * 6666555555555544444444443333333333222222222211111111110000000000
  * 3210987654321098765432109876543210987654321098765432109876543210
@@ -296,14 +308,14 @@ static void power7_disable_pmc(unsigned int pmc, unsigned long mmcr[])
 }
 
 static int power7_generic_events[] = {
-	[PERF_COUNT_HW_CPU_CYCLES] = 0x1e,
-	[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x100f8, /* GCT_NOSLOT_CYC */
-	[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = 0x4000a,  /* CMPLU_STALL */
-	[PERF_COUNT_HW_INSTRUCTIONS] = 2,
-	[PERF_COUNT_HW_CACHE_REFERENCES] = 0xc880,	/* LD_REF_L1_LSU*/
-	[PERF_COUNT_HW_CACHE_MISSES] = 0x400f0,		/* LD_MISS_L1	*/
-	[PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x10068,	/* BRU_FIN	*/
-	[PERF_COUNT_HW_BRANCH_MISSES] = 0x400f6,	/* BR_MPRED	*/
+	[PERF_COUNT_HW_CPU_CYCLES] =			PME_PM_CYC,
+	[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] =	PME_PM_GCT_NOSLOT_CYC,
+	[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] =	PME_PM_CMPLU_STALL,
+	[PERF_COUNT_HW_INSTRUCTIONS] =			PME_PM_INST_CMPL,
+	[PERF_COUNT_HW_CACHE_REFERENCES] =		PME_PM_LD_REF_L1,
+	[PERF_COUNT_HW_CACHE_MISSES] =			PME_PM_LD_MISS_L1,
+	[PERF_COUNT_HW_BRANCH_INSTRUCTIONS] =		PME_PM_BRU_FIN,
+	[PERF_COUNT_HW_BRANCH_MISSES] =			PME_PM_BRU_MPRED,
 };
 
 #define C(x)	PERF_COUNT_HW_CACHE_##x
-- 
1.7.1

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

* [PATCH 2/6][v3] perf: Make EVENT_ATTR global
  2013-01-10  1:03 [PATCH 1/6][v3] perf/Power7: Use macros to identify perf events Sukadev Bhattiprolu
@ 2013-01-10  1:04 ` Sukadev Bhattiprolu
  2013-01-10  1:05 ` [PATCH 3/6][v3] perf/POWER7: Make generic event translations available in sysfs Sukadev Bhattiprolu
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Sukadev Bhattiprolu @ 2013-01-10  1:04 UTC (permalink / raw)
  To: Peter Zijlstra, Paul Mackerras, Ingo Molnar
  Cc: Andi Kleen, robert.richter, Anton Blanchard, linux-kernel,
	Stephane Eranian, linuxppc-dev, Arnaldo Carvalho de Melo,
	Jiri Olsa

[PATCH 2/6][v3] perf: Make EVENT_ATTR global

Rename EVENT_ATTR() to PMU_EVENT_ATTR() and make it global so it is
available to all architectures.

Further to allow architectures flexibility, have PMU_EVENT_ATTR() pass
in the variable name as a parameter.

Changelog[v3]
	- [Jiri Olsa] No need to define PMU_EVENT_PTR()

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
 arch/x86/kernel/cpu/perf_event.c |   13 +++----------
 include/linux/perf_event.h       |   11 +++++++++++
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 4428fd1..59a1238 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -1316,11 +1316,6 @@ static struct attribute_group x86_pmu_format_group = {
 	.attrs = NULL,
 };
 
-struct perf_pmu_events_attr {
-	struct device_attribute attr;
-	u64 id;
-};
-
 /*
  * Remove all undefined events (x86_pmu.event_map(id) == 0)
  * out of events_attr attributes.
@@ -1354,11 +1349,9 @@ static ssize_t events_sysfs_show(struct device *dev, struct device_attribute *at
 #define EVENT_VAR(_id)  event_attr_##_id
 #define EVENT_PTR(_id) &event_attr_##_id.attr.attr
 
-#define EVENT_ATTR(_name, _id)					\
-static struct perf_pmu_events_attr EVENT_VAR(_id) = {		\
-	.attr = __ATTR(_name, 0444, events_sysfs_show, NULL),	\
-	.id   =  PERF_COUNT_HW_##_id,				\
-};
+#define EVENT_ATTR(_name, _id)						\
+	PMU_EVENT_ATTR(_name, EVENT_VAR(_id), PERF_COUNT_HW_##_id,	\
+			events_sysfs_show)
 
 EVENT_ATTR(cpu-cycles,			CPU_CYCLES		);
 EVENT_ATTR(instructions,		INSTRUCTIONS		);
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 6bfb2fa..42adf01 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -817,6 +817,17 @@ do {									\
 } while (0)
 
 
+struct perf_pmu_events_attr {
+	struct device_attribute attr;
+	u64 id;
+};
+
+#define PMU_EVENT_ATTR(_name, _var, _id, _show)				\
+static struct perf_pmu_events_attr _var = {				\
+	.attr = __ATTR(_name, 0444, _show, NULL),			\
+	.id   =  _id,							\
+};
+
 #define PMU_FORMAT_ATTR(_name, _format)					\
 static ssize_t								\
 _name##_show(struct device *dev,					\
-- 
1.7.1

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

* [PATCH 3/6][v3] perf/POWER7: Make generic event translations available in sysfs
  2013-01-10  1:03 [PATCH 1/6][v3] perf/Power7: Use macros to identify perf events Sukadev Bhattiprolu
  2013-01-10  1:04 ` [PATCH 2/6][v3] perf: Make EVENT_ATTR global Sukadev Bhattiprolu
@ 2013-01-10  1:05 ` Sukadev Bhattiprolu
  2013-01-10  1:06 ` [PATCH 4/6][v3] perf/POWER7: Make some POWER7 events " Sukadev Bhattiprolu
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Sukadev Bhattiprolu @ 2013-01-10  1:05 UTC (permalink / raw)
  To: Peter Zijlstra, Paul Mackerras, Ingo Molnar
  Cc: Andi Kleen, robert.richter, Anton Blanchard, linux-kernel,
	Stephane Eranian, linuxppc-dev, Arnaldo Carvalho de Melo,
	Jiri Olsa

[PATCH 3/6][v3] perf/POWER7: Make generic event translations available in sysfs

Make the generic perf events in POWER7 available via sysfs.

	$ ls /sys/bus/event_source/devices/cpu/events
	branch-instructions
	branch-misses
	cache-misses
	cache-references
	cpu-cycles
	instructions
	stalled-cycles-backend
	stalled-cycles-frontend

	$ cat /sys/bus/event_source/devices/cpu/events/cache-misses
	event=0x400f0

This patch is based on commits that implement this functionality on x86.
Eg:
	commit a47473939db20e3961b200eb00acf5fcf084d755
	Author: Jiri Olsa <jolsa@redhat.com>
	Date:   Wed Oct 10 14:53:11 2012 +0200

	    perf/x86: Make hardware event translations available in sysfs

Changelog:[v3]
	[Jiri Olsa] Drop EVENT_ID() macro since it is only used once.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/perf_event_server.h      |   24 ++++++++++++++
 arch/powerpc/perf/core-book3s.c                   |   12 +++++++
 arch/powerpc/perf/power7-pmu.c                    |   34 +++++++++++++++++++++
 3 files changed, 70 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ABI/stable/sysfs-devices-cpu-events

diff --git a/Documentation/ABI/stable/sysfs-devices-cpu-events b/Documentation/ABI/stable/sysfs-devices-cpu-events
new file mode 100644
index 0000000..e69de29
diff --git a/arch/powerpc/include/asm/perf_event_server.h b/arch/powerpc/include/asm/perf_event_server.h
index 9710be3..3f21d89 100644
--- a/arch/powerpc/include/asm/perf_event_server.h
+++ b/arch/powerpc/include/asm/perf_event_server.h
@@ -11,6 +11,7 @@
 
 #include <linux/types.h>
 #include <asm/hw_irq.h>
+#include <linux/device.h>
 
 #define MAX_HWEVENTS		8
 #define MAX_EVENT_ALTERNATIVES	8
@@ -35,6 +36,7 @@ struct power_pmu {
 	void		(*disable_pmc)(unsigned int pmc, unsigned long mmcr[]);
 	int		(*limited_pmc_event)(u64 event_id);
 	u32		flags;
+	const struct attribute_group	**attr_groups;
 	int		n_generic;
 	int		*generic_events;
 	int		(*cache_events)[PERF_COUNT_HW_CACHE_MAX]
@@ -109,3 +111,25 @@ extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
  * If an event_id is not subject to the constraint expressed by a particular
  * field, then it will have 0 in both the mask and value for that field.
  */
+
+extern ssize_t power_events_sysfs_show(struct device *dev,
+				struct device_attribute *attr, char *page);
+
+/*
+ * EVENT_VAR() is same as PMU_EVENT_VAR with a suffix.
+ *
+ * Having a suffix allows us to have aliases in sysfs - eg: the generic
+ * event 'cpu-cycles' can have two entries in sysfs: 'cpu-cycles' and
+ * 'PM_CYC' where the latter is the name by which the event is known in
+ * POWER CPU specification.
+ */
+#define	EVENT_VAR(_id, _suffix)		event_attr_##_id##_suffix
+#define	EVENT_PTR(_id, _suffix)		&EVENT_VAR(_id, _suffix)
+
+#define	EVENT_ATTR(_name, _id, _suffix)					\
+	PMU_EVENT_ATTR(_name, EVENT_VAR(_id, _suffix), PME_PM_##_id,	\
+			power_events_sysfs_show)
+
+#define	GENERIC_EVENT_ATTR(_name, _id)	EVENT_ATTR(_name, _id, _g)
+#define	GENERIC_EVENT_PTR(_id)		EVENT_PTR(_id, _g)
+
diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index aa2465e..fa476d5 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -1305,6 +1305,16 @@ static int power_pmu_event_idx(struct perf_event *event)
 	return event->hw.idx;
 }
 
+ssize_t power_events_sysfs_show(struct device *dev,
+				struct device_attribute *attr, char *page)
+{
+	struct perf_pmu_events_attr *pmu_attr;
+
+	pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
+
+	return sprintf(page, "event=0x%02llx\n", pmu_attr->id);
+}
+
 struct pmu power_pmu = {
 	.pmu_enable	= power_pmu_enable,
 	.pmu_disable	= power_pmu_disable,
@@ -1537,6 +1547,8 @@ int __cpuinit register_power_pmu(struct power_pmu *pmu)
 	pr_info("%s performance monitor hardware support registered\n",
 		pmu->name);
 
+	power_pmu.attr_groups = ppmu->attr_groups;
+
 #ifdef MSR_HV
 	/*
 	 * Use FCHV to ignore kernel events if MSR.HV is set.
diff --git a/arch/powerpc/perf/power7-pmu.c b/arch/powerpc/perf/power7-pmu.c
index 44e70d2..ae5d757 100644
--- a/arch/powerpc/perf/power7-pmu.c
+++ b/arch/powerpc/perf/power7-pmu.c
@@ -363,6 +363,39 @@ static int power7_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
 	},
 };
 
+
+GENERIC_EVENT_ATTR(cpu-cycles,			CYC);
+GENERIC_EVENT_ATTR(stalled-cycles-frontend,	GCT_NOSLOT_CYC);
+GENERIC_EVENT_ATTR(stalled-cycles-backend,	CMPLU_STALL);
+GENERIC_EVENT_ATTR(instructions,		INST_CMPL);
+GENERIC_EVENT_ATTR(cache-references,		LD_REF_L1);
+GENERIC_EVENT_ATTR(cache-misses,		LD_MISS_L1);
+GENERIC_EVENT_ATTR(branch-instructions,		BRU_FIN);
+GENERIC_EVENT_ATTR(branch-misses,		BRU_MPRED);
+
+static struct attribute *power7_events_attr[] = {
+	GENERIC_EVENT_PTR(CYC),
+	GENERIC_EVENT_PTR(GCT_NOSLOT_CYC),
+	GENERIC_EVENT_PTR(CMPLU_STALL),
+	GENERIC_EVENT_PTR(INST_CMPL),
+	GENERIC_EVENT_PTR(LD_REF_L1),
+	GENERIC_EVENT_PTR(LD_MISS_L1),
+	GENERIC_EVENT_PTR(BRU_FIN),
+	GENERIC_EVENT_PTR(BRU_MPRED),
+	NULL
+};
+
+
+static struct attribute_group power7_pmu_events_group = {
+	.name = "events",
+	.attrs = power7_events_attr,
+};
+
+static const struct attribute_group *power7_pmu_attr_groups[] = {
+	&power7_pmu_events_group,
+	NULL,
+};
+
 static struct power_pmu power7_pmu = {
 	.name			= "POWER7",
 	.n_counter		= 6,
@@ -374,6 +407,7 @@ static struct power_pmu power7_pmu = {
 	.get_alternatives	= power7_get_alternatives,
 	.disable_pmc		= power7_disable_pmc,
 	.flags			= PPMU_ALT_SIPR,
+	.attr_groups		= power7_pmu_attr_groups,
 	.n_generic		= ARRAY_SIZE(power7_generic_events),
 	.generic_events		= power7_generic_events,
 	.cache_events		= &power7_cache_events,
-- 
1.7.1

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

* [PATCH 4/6][v3] perf/POWER7: Make some POWER7 events available in sysfs
  2013-01-10  1:03 [PATCH 1/6][v3] perf/Power7: Use macros to identify perf events Sukadev Bhattiprolu
  2013-01-10  1:04 ` [PATCH 2/6][v3] perf: Make EVENT_ATTR global Sukadev Bhattiprolu
  2013-01-10  1:05 ` [PATCH 3/6][v3] perf/POWER7: Make generic event translations available in sysfs Sukadev Bhattiprolu
@ 2013-01-10  1:06 ` Sukadev Bhattiprolu
  2013-01-10  1:06 ` [PATCH 5/6][v3] perf: Create a sysfs entry for Power event format Sukadev Bhattiprolu
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Sukadev Bhattiprolu @ 2013-01-10  1:06 UTC (permalink / raw)
  To: Peter Zijlstra, Paul Mackerras, Ingo Molnar
  Cc: Andi Kleen, robert.richter, Anton Blanchard, linux-kernel,
	Stephane Eranian, linuxppc-dev, Arnaldo Carvalho de Melo,
	Jiri Olsa

[PATCH 4/6][v3] perf/POWER7: Make some POWER7 events available in sysfs

Make some POWER7-specific perf events available in sysfs.

	$ /bin/ls -1 /sys/bus/event_source/devices/cpu/events/
	branch-instructions
	branch-misses
	cache-misses
	cache-references
	cpu-cycles
	instructions
	PM_BRU_FIN
	PM_BRU_MPRED
	PM_CMPLU_STALL
	PM_CYC
	PM_GCT_NOSLOT_CYC
	PM_INST_CMPL
	PM_LD_MISS_L1
	PM_LD_REF_L1
	stalled-cycles-backend
	stalled-cycles-frontend

where the 'PM_*' events are POWER specific and the others are the
generic events.

This will enable users to specify these events with their symbolic
names rather than with their raw code.

	perf stat -e 'cpu/PM_CYC/' ...

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/perf_event_server.h |    2 ++
 arch/powerpc/perf/power7-pmu.c               |   18 ++++++++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/include/asm/perf_event_server.h b/arch/powerpc/include/asm/perf_event_server.h
index 3f21d89..b29fcc6 100644
--- a/arch/powerpc/include/asm/perf_event_server.h
+++ b/arch/powerpc/include/asm/perf_event_server.h
@@ -133,3 +133,5 @@ extern ssize_t power_events_sysfs_show(struct device *dev,
 #define	GENERIC_EVENT_ATTR(_name, _id)	EVENT_ATTR(_name, _id, _g)
 #define	GENERIC_EVENT_PTR(_id)		EVENT_PTR(_id, _g)
 
+#define	POWER_EVENT_ATTR(_name, _id)	EVENT_ATTR(PM_##_name, _id, _p)
+#define	POWER_EVENT_PTR(_id)		EVENT_PTR(_id, _p)
diff --git a/arch/powerpc/perf/power7-pmu.c b/arch/powerpc/perf/power7-pmu.c
index ae5d757..5627940 100644
--- a/arch/powerpc/perf/power7-pmu.c
+++ b/arch/powerpc/perf/power7-pmu.c
@@ -373,6 +373,15 @@ GENERIC_EVENT_ATTR(cache-misses,		LD_MISS_L1);
 GENERIC_EVENT_ATTR(branch-instructions,		BRU_FIN);
 GENERIC_EVENT_ATTR(branch-misses,		BRU_MPRED);
 
+POWER_EVENT_ATTR(CYC,				CYC);
+POWER_EVENT_ATTR(GCT_NOSLOT_CYC,		GCT_NOSLOT_CYC);
+POWER_EVENT_ATTR(CMPLU_STALL,			CMPLU_STALL);
+POWER_EVENT_ATTR(INST_CMPL,			INST_CMPL);
+POWER_EVENT_ATTR(LD_REF_L1,			LD_REF_L1);
+POWER_EVENT_ATTR(LD_MISS_L1,			LD_MISS_L1);
+POWER_EVENT_ATTR(BRU_FIN,			BRU_FIN)
+POWER_EVENT_ATTR(BRU_MPRED,			BRU_MPRED);
+
 static struct attribute *power7_events_attr[] = {
 	GENERIC_EVENT_PTR(CYC),
 	GENERIC_EVENT_PTR(GCT_NOSLOT_CYC),
@@ -382,6 +391,15 @@ static struct attribute *power7_events_attr[] = {
 	GENERIC_EVENT_PTR(LD_MISS_L1),
 	GENERIC_EVENT_PTR(BRU_FIN),
 	GENERIC_EVENT_PTR(BRU_MPRED),
+
+	POWER_EVENT_PTR(CYC),
+	POWER_EVENT_PTR(GCT_NOSLOT_CYC),
+	POWER_EVENT_PTR(CMPLU_STALL),
+	POWER_EVENT_PTR(INST_CMPL),
+	POWER_EVENT_PTR(LD_REF_L1),
+	POWER_EVENT_PTR(LD_MISS_L1),
+	POWER_EVENT_PTR(BRU_FIN),
+	POWER_EVENT_PTR(BRU_MPRED),
 	NULL
 };
 
-- 
1.7.1

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

* [PATCH 5/6][v3] perf: Create a sysfs entry for Power event format
  2013-01-10  1:03 [PATCH 1/6][v3] perf/Power7: Use macros to identify perf events Sukadev Bhattiprolu
                   ` (2 preceding siblings ...)
  2013-01-10  1:06 ` [PATCH 4/6][v3] perf/POWER7: Make some POWER7 events " Sukadev Bhattiprolu
@ 2013-01-10  1:06 ` Sukadev Bhattiprolu
  2013-01-10  1:07 ` [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries Sukadev Bhattiprolu
  2013-01-23  3:50 ` [PATCH 1/6][v3] perf/Power7: Use macros to identify perf events Michael Ellerman
  5 siblings, 0 replies; 17+ messages in thread
From: Sukadev Bhattiprolu @ 2013-01-10  1:06 UTC (permalink / raw)
  To: Peter Zijlstra, Paul Mackerras, Ingo Molnar
  Cc: Andi Kleen, robert.richter, Anton Blanchard, linux-kernel,
	Stephane Eranian, linuxppc-dev, Arnaldo Carvalho de Melo,
	Jiri Olsa

[PATCH 5/6][v3] perf: Create a sysfs entry for Power event format

Create a sysfs entry, '/sys/bus/event_source/devices/cpu/format/event'
which describes the format of a POWER cpu.

The format of the event is the same for all POWER cpus at least in
(Power6, Power7), so bulk of this change is common in the code common
to POWER cpus.

This code is based on corresponding code in x86.

Changelog[v2]: [Jiri Olsa] Use PMU_FORMAT_ATTR() rather than duplicating it.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/perf_event_server.h |    6 ++++++
 arch/powerpc/perf/core-book3s.c              |   12 ++++++++++++
 arch/powerpc/perf/power7-pmu.c               |    1 +
 3 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/include/asm/perf_event_server.h b/arch/powerpc/include/asm/perf_event_server.h
index b29fcc6..ee63205 100644
--- a/arch/powerpc/include/asm/perf_event_server.h
+++ b/arch/powerpc/include/asm/perf_event_server.h
@@ -135,3 +135,9 @@ extern ssize_t power_events_sysfs_show(struct device *dev,
 
 #define	POWER_EVENT_ATTR(_name, _id)	EVENT_ATTR(PM_##_name, _id, _p)
 #define	POWER_EVENT_PTR(_id)		EVENT_PTR(_id, _p)
+
+/*
+ * Format of a perf event is the same on all POWER cpus. Declare a
+ * common sysfs attribute group that individual POWER cpus can share.
+ */
+extern struct attribute_group power_pmu_format_group;
diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index fa476d5..4ae044b 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -1315,6 +1315,18 @@ ssize_t power_events_sysfs_show(struct device *dev,
 	return sprintf(page, "event=0x%02llx\n", pmu_attr->id);
 }
 
+PMU_FORMAT_ATTR(event, "config:0-20");
+
+static struct attribute *power_pmu_format_attr[] = {
+	&format_attr_event.attr,
+	NULL,
+};
+
+struct attribute_group power_pmu_format_group = {
+	.name = "format",
+	.attrs = power_pmu_format_attr,
+};
+
 struct pmu power_pmu = {
 	.pmu_enable	= power_pmu_enable,
 	.pmu_disable	= power_pmu_disable,
diff --git a/arch/powerpc/perf/power7-pmu.c b/arch/powerpc/perf/power7-pmu.c
index 5627940..5fb3c9b 100644
--- a/arch/powerpc/perf/power7-pmu.c
+++ b/arch/powerpc/perf/power7-pmu.c
@@ -410,6 +410,7 @@ static struct attribute_group power7_pmu_events_group = {
 };
 
 static const struct attribute_group *power7_pmu_attr_groups[] = {
+	&power_pmu_format_group,
 	&power7_pmu_events_group,
 	NULL,
 };
-- 
1.7.1

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

* [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries
  2013-01-10  1:03 [PATCH 1/6][v3] perf/Power7: Use macros to identify perf events Sukadev Bhattiprolu
                   ` (3 preceding siblings ...)
  2013-01-10  1:06 ` [PATCH 5/6][v3] perf: Create a sysfs entry for Power event format Sukadev Bhattiprolu
@ 2013-01-10  1:07 ` Sukadev Bhattiprolu
  2013-01-15 18:57   ` Arnaldo Carvalho de Melo
  2013-01-23  3:50 ` [PATCH 1/6][v3] perf/Power7: Use macros to identify perf events Michael Ellerman
  5 siblings, 1 reply; 17+ messages in thread
From: Sukadev Bhattiprolu @ 2013-01-10  1:07 UTC (permalink / raw)
  To: Peter Zijlstra, Paul Mackerras, Ingo Molnar
  Cc: Andi Kleen, robert.richter, Anton Blanchard, linux-kernel,
	Stephane Eranian, linuxppc-dev, Arnaldo Carvalho de Melo,
	Jiri Olsa

[PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries

This patchset addes two new sets of files to sysfs:

	- generic and POWER-specific perf events in /sys/devices/cpu/events/
	- perf event config format in /sys/devices/cpu/format/event

Document the format of these files which would become part of the ABI.

Changelog[v3]:
	[Greg KH] Include ABI documentation.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
 Documentation/ABI/stable/sysfs-devices-cpu-events |   54 +++++++++++++++++++++
 Documentation/ABI/stable/sysfs-devices-cpu-format |   27 ++++++++++
 2 files changed, 81 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ABI/stable/sysfs-devices-cpu-format

diff --git a/Documentation/ABI/stable/sysfs-devices-cpu-events b/Documentation/ABI/stable/sysfs-devices-cpu-events
index e69de29..f37d542 100644
--- a/Documentation/ABI/stable/sysfs-devices-cpu-events
+++ b/Documentation/ABI/stable/sysfs-devices-cpu-events
@@ -0,0 +1,54 @@
+What:		/sys/devices/cpu/events/
+		/sys/devices/cpu/events/branch-misses
+		/sys/devices/cpu/events/cache-references
+		/sys/devices/cpu/events/cache-misses
+		/sys/devices/cpu/events/stalled-cycles-frontend
+		/sys/devices/cpu/events/branch-instructions
+		/sys/devices/cpu/events/stalled-cycles-backend
+		/sys/devices/cpu/events/instructions
+		/sys/devices/cpu/events/cpu-cycles
+
+Date:		2013/01/08
+
+Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
+
+Description:	Generic performance monitoring events
+
+		A collection of performance monitoring events that may be
+		supported by many/most CPUs. These events can be monitored
+		using the 'perf(1)' tool.
+
+		The contents of each file would look like:
+
+			event=0xNNNN
+
+		where 'N' is a hex digit.
+
+
+What: 		/sys/devices/cpu/events/PM_LD_MISS_L1
+		/sys/devices/cpu/events/PM_LD_REF_L1
+		/sys/devices/cpu/events/PM_CYC
+		/sys/devices/cpu/events/PM_BRU_FIN
+		/sys/devices/cpu/events/PM_GCT_NOSLOT_CYC
+		/sys/devices/cpu/events/PM_BRU_MPRED
+		/sys/devices/cpu/events/PM_INST_CMPL
+		/sys/devices/cpu/events/PM_CMPLU_STALL
+
+Date:		2013/01/08
+
+Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
+		Linux Powerpc mailing list <linuxppc-dev@ozlabs.org>
+
+Description:	POWER specific performance monitoring events
+
+		A collection of performance monitoring events that may be
+		supported by the POWER CPU. These events can be monitored
+		using the 'perf(1)' tool.
+
+		These events may not be supported by other CPUs.
+
+		The contents of each file would look like:
+
+			event=0xNNNN
+
+		where 'N' is a hex digit.
diff --git a/Documentation/ABI/stable/sysfs-devices-cpu-format b/Documentation/ABI/stable/sysfs-devices-cpu-format
new file mode 100644
index 0000000..b15cfb2
--- /dev/null
+++ b/Documentation/ABI/stable/sysfs-devices-cpu-format
@@ -0,0 +1,27 @@
+What:		/sys/devices/cpu/format/
+		/sys/devices/cpu/format/event
+
+Date:		2013/01/08
+
+Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
+
+Description:	Format of performance monitoring events
+
+		Each CPU/architecture may use different format to represent
+		the perf event.  The 'event' file describes the configuration
+		format of the performance monitoring event on the CPU/system.
+
+		The contents of each file would look like:
+
+			config:m-n
+
+		where m and n are the starting and ending bits that are
+		used to represent the event.
+
+		For example, on POWER,
+
+			$ cat /sys/devices/cpu/format/event
+			config:0-20
+
+		meaning that POWER uses the first 20-bits to represent a perf
+		event.
-- 
1.7.1

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

* Re: [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries
  2013-01-10  1:07 ` [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries Sukadev Bhattiprolu
@ 2013-01-15 18:57   ` Arnaldo Carvalho de Melo
  2013-01-15 22:47     ` Greg KH
  2013-01-16 11:30     ` Jiri Olsa
  0 siblings, 2 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-01-15 18:57 UTC (permalink / raw)
  To: Sukadev Bhattiprolu
  Cc: Andi Kleen, Peter Zijlstra, robert.richter, Greg KH,
	Anton Blanchard, linux-kernel, Stephane Eranian, linuxppc-dev,
	Ingo Molnar, Paul Mackerras, Jiri Olsa

Em Wed, Jan 09, 2013 at 05:07:03PM -0800, Sukadev Bhattiprolu escreveu:
> [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries
> 
> This patchset addes two new sets of files to sysfs:
> 
> 	- generic and POWER-specific perf events in /sys/devices/cpu/events/
> 	- perf event config format in /sys/devices/cpu/format/event
> 
> Document the format of these files which would become part of the ABI.
> 
> Changelog[v3]:
> 	[Greg KH] Include ABI documentation.

Jiri, can I have your ack on this one too?

Greg, all ok now?

- Arnaldo
 
> Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
> ---
>  Documentation/ABI/stable/sysfs-devices-cpu-events |   54 +++++++++++++++++++++
>  Documentation/ABI/stable/sysfs-devices-cpu-format |   27 ++++++++++
>  2 files changed, 81 insertions(+), 0 deletions(-)
>  create mode 100644 Documentation/ABI/stable/sysfs-devices-cpu-format
> 
> diff --git a/Documentation/ABI/stable/sysfs-devices-cpu-events b/Documentation/ABI/stable/sysfs-devices-cpu-events
> index e69de29..f37d542 100644
> --- a/Documentation/ABI/stable/sysfs-devices-cpu-events
> +++ b/Documentation/ABI/stable/sysfs-devices-cpu-events
> @@ -0,0 +1,54 @@
> +What:		/sys/devices/cpu/events/
> +		/sys/devices/cpu/events/branch-misses
> +		/sys/devices/cpu/events/cache-references
> +		/sys/devices/cpu/events/cache-misses
> +		/sys/devices/cpu/events/stalled-cycles-frontend
> +		/sys/devices/cpu/events/branch-instructions
> +		/sys/devices/cpu/events/stalled-cycles-backend
> +		/sys/devices/cpu/events/instructions
> +		/sys/devices/cpu/events/cpu-cycles
> +
> +Date:		2013/01/08
> +
> +Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
> +
> +Description:	Generic performance monitoring events
> +
> +		A collection of performance monitoring events that may be
> +		supported by many/most CPUs. These events can be monitored
> +		using the 'perf(1)' tool.
> +
> +		The contents of each file would look like:
> +
> +			event=0xNNNN
> +
> +		where 'N' is a hex digit.
> +
> +
> +What: 		/sys/devices/cpu/events/PM_LD_MISS_L1
> +		/sys/devices/cpu/events/PM_LD_REF_L1
> +		/sys/devices/cpu/events/PM_CYC
> +		/sys/devices/cpu/events/PM_BRU_FIN
> +		/sys/devices/cpu/events/PM_GCT_NOSLOT_CYC
> +		/sys/devices/cpu/events/PM_BRU_MPRED
> +		/sys/devices/cpu/events/PM_INST_CMPL
> +		/sys/devices/cpu/events/PM_CMPLU_STALL
> +
> +Date:		2013/01/08
> +
> +Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
> +		Linux Powerpc mailing list <linuxppc-dev@ozlabs.org>
> +
> +Description:	POWER specific performance monitoring events
> +
> +		A collection of performance monitoring events that may be
> +		supported by the POWER CPU. These events can be monitored
> +		using the 'perf(1)' tool.
> +
> +		These events may not be supported by other CPUs.
> +
> +		The contents of each file would look like:
> +
> +			event=0xNNNN
> +
> +		where 'N' is a hex digit.
> diff --git a/Documentation/ABI/stable/sysfs-devices-cpu-format b/Documentation/ABI/stable/sysfs-devices-cpu-format
> new file mode 100644
> index 0000000..b15cfb2
> --- /dev/null
> +++ b/Documentation/ABI/stable/sysfs-devices-cpu-format
> @@ -0,0 +1,27 @@
> +What:		/sys/devices/cpu/format/
> +		/sys/devices/cpu/format/event
> +
> +Date:		2013/01/08
> +
> +Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
> +
> +Description:	Format of performance monitoring events
> +
> +		Each CPU/architecture may use different format to represent
> +		the perf event.  The 'event' file describes the configuration
> +		format of the performance monitoring event on the CPU/system.
> +
> +		The contents of each file would look like:
> +
> +			config:m-n
> +
> +		where m and n are the starting and ending bits that are
> +		used to represent the event.
> +
> +		For example, on POWER,
> +
> +			$ cat /sys/devices/cpu/format/event
> +			config:0-20
> +
> +		meaning that POWER uses the first 20-bits to represent a perf
> +		event.
> -- 
> 1.7.1

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

* Re: [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries
  2013-01-15 18:57   ` Arnaldo Carvalho de Melo
@ 2013-01-15 22:47     ` Greg KH
  2013-01-16 11:30     ` Jiri Olsa
  1 sibling, 0 replies; 17+ messages in thread
From: Greg KH @ 2013-01-15 22:47 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Andi Kleen, Peter Zijlstra, robert.richter, Anton Blanchard,
	linux-kernel, Stephane Eranian, linuxppc-dev, Ingo Molnar,
	Paul Mackerras, Sukadev Bhattiprolu, Jiri Olsa

On Tue, Jan 15, 2013 at 03:57:59PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Jan 09, 2013 at 05:07:03PM -0800, Sukadev Bhattiprolu escreveu:
> > [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries
> > 
> > This patchset addes two new sets of files to sysfs:
> > 
> > 	- generic and POWER-specific perf events in /sys/devices/cpu/events/
> > 	- perf event config format in /sys/devices/cpu/format/event
> > 
> > Document the format of these files which would become part of the ABI.
> > 
> > Changelog[v3]:
> > 	[Greg KH] Include ABI documentation.
> 
> Jiri, can I have your ack on this one too?
> 
> Greg, all ok now?

No objection from me, thanks.

greg k-h

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

* Re: [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries
  2013-01-15 18:57   ` Arnaldo Carvalho de Melo
  2013-01-15 22:47     ` Greg KH
@ 2013-01-16 11:30     ` Jiri Olsa
  2013-01-16 18:58       ` Sukadev Bhattiprolu
  1 sibling, 1 reply; 17+ messages in thread
From: Jiri Olsa @ 2013-01-16 11:30 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Andi Kleen, Peter Zijlstra, robert.richter, Greg KH,
	Anton Blanchard, linux-kernel, Stephane Eranian, linuxppc-dev,
	Ingo Molnar, Paul Mackerras, Sukadev Bhattiprolu

On Tue, Jan 15, 2013 at 03:57:59PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Jan 09, 2013 at 05:07:03PM -0800, Sukadev Bhattiprolu escreveu:
> > [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries
> > 
> > This patchset addes two new sets of files to sysfs:
> > 
> > 	- generic and POWER-specific perf events in /sys/devices/cpu/events/
> > 	- perf event config format in /sys/devices/cpu/format/event
> > 
> > Document the format of these files which would become part of the ABI.
> > 
> > Changelog[v3]:
> > 	[Greg KH] Include ABI documentation.
> 
> Jiri, can I have your ack on this one too?

hm, we already already 'format' definition but in testing section
(and we are missing 'events' definition there.. my bad)

anyway, after reading Documentation/ABI/README looks like we
should go for 'testing' section with this as well.. stable
seems scary at this point ;-)

jirka

> 
> Greg, all ok now?
> 
> - Arnaldo
>  
> > Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
> > ---
> >  Documentation/ABI/stable/sysfs-devices-cpu-events |   54 +++++++++++++++++++++
> >  Documentation/ABI/stable/sysfs-devices-cpu-format |   27 ++++++++++
> >  2 files changed, 81 insertions(+), 0 deletions(-)
> >  create mode 100644 Documentation/ABI/stable/sysfs-devices-cpu-format
> > 
> > diff --git a/Documentation/ABI/stable/sysfs-devices-cpu-events b/Documentation/ABI/stable/sysfs-devices-cpu-events
> > index e69de29..f37d542 100644
> > --- a/Documentation/ABI/stable/sysfs-devices-cpu-events
> > +++ b/Documentation/ABI/stable/sysfs-devices-cpu-events
> > @@ -0,0 +1,54 @@
> > +What:		/sys/devices/cpu/events/
> > +		/sys/devices/cpu/events/branch-misses
> > +		/sys/devices/cpu/events/cache-references
> > +		/sys/devices/cpu/events/cache-misses
> > +		/sys/devices/cpu/events/stalled-cycles-frontend
> > +		/sys/devices/cpu/events/branch-instructions
> > +		/sys/devices/cpu/events/stalled-cycles-backend
> > +		/sys/devices/cpu/events/instructions
> > +		/sys/devices/cpu/events/cpu-cycles
> > +
> > +Date:		2013/01/08
> > +
> > +Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
> > +
> > +Description:	Generic performance monitoring events
> > +
> > +		A collection of performance monitoring events that may be
> > +		supported by many/most CPUs. These events can be monitored
> > +		using the 'perf(1)' tool.
> > +
> > +		The contents of each file would look like:
> > +
> > +			event=0xNNNN
> > +
> > +		where 'N' is a hex digit.
> > +
> > +
> > +What: 		/sys/devices/cpu/events/PM_LD_MISS_L1
> > +		/sys/devices/cpu/events/PM_LD_REF_L1
> > +		/sys/devices/cpu/events/PM_CYC
> > +		/sys/devices/cpu/events/PM_BRU_FIN
> > +		/sys/devices/cpu/events/PM_GCT_NOSLOT_CYC
> > +		/sys/devices/cpu/events/PM_BRU_MPRED
> > +		/sys/devices/cpu/events/PM_INST_CMPL
> > +		/sys/devices/cpu/events/PM_CMPLU_STALL
> > +
> > +Date:		2013/01/08
> > +
> > +Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
> > +		Linux Powerpc mailing list <linuxppc-dev@ozlabs.org>
> > +
> > +Description:	POWER specific performance monitoring events
> > +
> > +		A collection of performance monitoring events that may be
> > +		supported by the POWER CPU. These events can be monitored
> > +		using the 'perf(1)' tool.
> > +
> > +		These events may not be supported by other CPUs.
> > +
> > +		The contents of each file would look like:
> > +
> > +			event=0xNNNN
> > +
> > +		where 'N' is a hex digit.
> > diff --git a/Documentation/ABI/stable/sysfs-devices-cpu-format b/Documentation/ABI/stable/sysfs-devices-cpu-format
> > new file mode 100644
> > index 0000000..b15cfb2
> > --- /dev/null
> > +++ b/Documentation/ABI/stable/sysfs-devices-cpu-format
> > @@ -0,0 +1,27 @@
> > +What:		/sys/devices/cpu/format/
> > +		/sys/devices/cpu/format/event
> > +
> > +Date:		2013/01/08
> > +
> > +Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
> > +
> > +Description:	Format of performance monitoring events
> > +
> > +		Each CPU/architecture may use different format to represent
> > +		the perf event.  The 'event' file describes the configuration
> > +		format of the performance monitoring event on the CPU/system.
> > +
> > +		The contents of each file would look like:
> > +
> > +			config:m-n
> > +
> > +		where m and n are the starting and ending bits that are
> > +		used to represent the event.
> > +
> > +		For example, on POWER,
> > +
> > +			$ cat /sys/devices/cpu/format/event
> > +			config:0-20
> > +
> > +		meaning that POWER uses the first 20-bits to represent a perf
> > +		event.
> > -- 
> > 1.7.1

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

* Re: [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries
  2013-01-16 11:30     ` Jiri Olsa
@ 2013-01-16 18:58       ` Sukadev Bhattiprolu
  2013-01-17 14:11         ` Jiri Olsa
  0 siblings, 1 reply; 17+ messages in thread
From: Sukadev Bhattiprolu @ 2013-01-16 18:58 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Andi Kleen, Peter Zijlstra, robert.richter, Greg KH,
	Anton Blanchard, linux-kernel, Stephane Eranian, linuxppc-dev,
	Ingo Molnar, Paul Mackerras, Arnaldo Carvalho de Melo

Jiri Olsa [jolsa@redhat.com] wrote:
| On Tue, Jan 15, 2013 at 03:57:59PM -0300, Arnaldo Carvalho de Melo wrote:
| > Em Wed, Jan 09, 2013 at 05:07:03PM -0800, Sukadev Bhattiprolu escreveu:
| > > [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries
| > > 
| > > This patchset addes two new sets of files to sysfs:
| > > 
| > > 	- generic and POWER-specific perf events in /sys/devices/cpu/events/
| > > 	- perf event config format in /sys/devices/cpu/format/event
| > > 
| > > Document the format of these files which would become part of the ABI.
| > > 
| > > Changelog[v3]:
| > > 	[Greg KH] Include ABI documentation.
| > 
| > Jiri, can I have your ack on this one too?
| 
| hm, we already already 'format' definition but in testing section
| (and we are missing 'events' definition there.. my bad)

I see that file now ! I have removed that documentation from my patch.
| 
| anyway, after reading Documentation/ABI/README looks like we
| should go for 'testing' section with this as well.. stable
| seems scary at this point ;-)

Agree.

Here is the updated patch.
---

This patchset addes two new sets of files to sysfs for POWER architecture.

	- perf event config format in /sys/devices/cpu/format/event
	- generic and POWER-specific perf events in /sys/devices/cpu/events/

The format of the first file is already documented in:

	Documentation/ABI/testing/sysfs-bus-event_source-devices-format

Document the format of the second set of files '/sys/devices/cpu/events/*'
which would also become part of the ABI.

Changelog[v3.1]:
	(small changes to this one patch).
	[Jiri Olsa]: Remove the documentation for the 'config format' file
	as it is already documented.
	[Jiri Olsa]: Move the documentation of 'events' also to 'testing/'

Changelog[v3]:
	[Greg KH] Include ABI documentation.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
 .../testing/sysfs-bus-event_source-devices-events  |   58 ++++++++++++++++++++
 1 files changed, 58 insertions(+), 0 deletions(-)
 delete mode 100644 Documentation/ABI/stable/sysfs-devices-cpu-events
 create mode 100644 Documentation/ABI/testing/sysfs-bus-event_source-devices-events

diff --git a/Documentation/ABI/stable/sysfs-devices-cpu-events b/Documentation/ABI/stable/sysfs-devices-cpu-events
deleted file mode 100644
index e69de29..0000000
diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
new file mode 100644
index 0000000..2c4081e
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
@@ -0,0 +1,58 @@
+What:		/sys/devices/cpu/events/
+		/sys/devices/cpu/events/branch-misses
+		/sys/devices/cpu/events/cache-references
+		/sys/devices/cpu/events/cache-misses
+		/sys/devices/cpu/events/stalled-cycles-frontend
+		/sys/devices/cpu/events/branch-instructions
+		/sys/devices/cpu/events/stalled-cycles-backend
+		/sys/devices/cpu/events/instructions
+		/sys/devices/cpu/events/cpu-cycles
+
+Date:		2012/01/NN
+
+Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
+
+Description:	Generic performance monitoring events
+
+		A collection of performance monitoring events that may be
+		supported by many/most CPUs. These events can be monitored
+		using the 'perf(1)' tool.
+
+		The contents of each file would look like:
+
+			event=0xNNNN
+
+		where 'N' is a hex digit and the number '0xNNNN' shows the
+		"raw code" for the perf event identified by the file's
+		"basename".
+
+
+What: 		/sys/devices/cpu/events/PM_LD_MISS_L1
+		/sys/devices/cpu/events/PM_LD_REF_L1
+		/sys/devices/cpu/events/PM_CYC
+		/sys/devices/cpu/events/PM_BRU_FIN
+		/sys/devices/cpu/events/PM_GCT_NOSLOT_CYC
+		/sys/devices/cpu/events/PM_BRU_MPRED
+		/sys/devices/cpu/events/PM_INST_CMPL
+		/sys/devices/cpu/events/PM_CMPLU_STALL
+
+Date:		2013/01/08
+
+Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
+		Linux Powerpc mailing list <linuxppc-dev@ozlabs.org>
+
+Description:	POWER-systems specific performance monitoring events
+
+		A collection of performance monitoring events that may be
+		supported by the POWER CPU. These events can be monitored
+		using the 'perf(1)' tool.
+
+		These events may not be supported by other CPUs.
+
+		The contents of each file would look like:
+
+			event=0xNNNN
+
+		where 'N' is a hex digit and the number '0xNNNN' shows the
+		"raw code" for the perf event identified by the file's
+		"basename".
-- 
1.7.1

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

* Re: [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries
  2013-01-16 18:58       ` Sukadev Bhattiprolu
@ 2013-01-17 14:11         ` Jiri Olsa
  2013-01-18 17:46           ` Sukadev Bhattiprolu
  0 siblings, 1 reply; 17+ messages in thread
From: Jiri Olsa @ 2013-01-17 14:11 UTC (permalink / raw)
  To: Sukadev Bhattiprolu
  Cc: Andi Kleen, Peter Zijlstra, robert.richter, Greg KH,
	Anton Blanchard, linux-kernel, Stephane Eranian, linuxppc-dev,
	Ingo Molnar, Paul Mackerras, Arnaldo Carvalho de Melo

On Wed, Jan 16, 2013 at 10:58:16AM -0800, Sukadev Bhattiprolu wrote:
> Jiri Olsa [jolsa@redhat.com] wrote:
> | On Tue, Jan 15, 2013 at 03:57:59PM -0300, Arnaldo Carvalho de Melo wrote:
> | > Em Wed, Jan 09, 2013 at 05:07:03PM -0800, Sukadev Bhattiprolu escreveu:
> | > > [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries
> | > > 
> | > > This patchset addes two new sets of files to sysfs:
> | > > 
> | > > 	- generic and POWER-specific perf events in /sys/devices/cpu/events/
> | > > 	- perf event config format in /sys/devices/cpu/format/event
> | > > 
> | > > Document the format of these files which would become part of the ABI.
> | > > 
> | > > Changelog[v3]:
> | > > 	[Greg KH] Include ABI documentation.
> | > 
> | > Jiri, can I have your ack on this one too?
> | 
> | hm, we already already 'format' definition but in testing section
> | (and we are missing 'events' definition there.. my bad)
> 
> I see that file now ! I have removed that documentation from my patch.
> | 
> | anyway, after reading Documentation/ABI/README looks like we
> | should go for 'testing' section with this as well.. stable
> | seems scary at this point ;-)
> 
> Agree.
> 
> Here is the updated patch.
> ---
> 
> This patchset addes two new sets of files to sysfs for POWER architecture.
> 
> 	- perf event config format in /sys/devices/cpu/format/event
> 	- generic and POWER-specific perf events in /sys/devices/cpu/events/
> 
> The format of the first file is already documented in:
> 
> 	Documentation/ABI/testing/sysfs-bus-event_source-devices-format
> 
> Document the format of the second set of files '/sys/devices/cpu/events/*'
> which would also become part of the ABI.
> 
> Changelog[v3.1]:
> 	(small changes to this one patch).
> 	[Jiri Olsa]: Remove the documentation for the 'config format' file
> 	as it is already documented.
> 	[Jiri Olsa]: Move the documentation of 'events' also to 'testing/'
> 
> Changelog[v3]:
> 	[Greg KH] Include ABI documentation.
> 
> Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
> ---
>  .../testing/sysfs-bus-event_source-devices-events  |   58 ++++++++++++++++++++
>  1 files changed, 58 insertions(+), 0 deletions(-)
>  delete mode 100644 Documentation/ABI/stable/sysfs-devices-cpu-events
>  create mode 100644 Documentation/ABI/testing/sysfs-bus-event_source-devices-events
> 
> diff --git a/Documentation/ABI/stable/sysfs-devices-cpu-events b/Documentation/ABI/stable/sysfs-devices-cpu-events
> deleted file mode 100644
> index e69de29..0000000
> diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
> new file mode 100644
> index 0000000..2c4081e
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
> @@ -0,0 +1,58 @@
> +What:		/sys/devices/cpu/events/
> +		/sys/devices/cpu/events/branch-misses
> +		/sys/devices/cpu/events/cache-references
> +		/sys/devices/cpu/events/cache-misses
> +		/sys/devices/cpu/events/stalled-cycles-frontend
> +		/sys/devices/cpu/events/branch-instructions
> +		/sys/devices/cpu/events/stalled-cycles-backend
> +		/sys/devices/cpu/events/instructions
> +		/sys/devices/cpu/events/cpu-cycles
> +
> +Date:		2012/01/NN
> +
> +Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
> +
> +Description:	Generic performance monitoring events
> +
> +		A collection of performance monitoring events that may be
> +		supported by many/most CPUs. These events can be monitored
> +		using the 'perf(1)' tool.
> +
> +		The contents of each file would look like:
> +
> +			event=0xNNNN
> +
> +		where 'N' is a hex digit and the number '0xNNNN' shows the
> +		"raw code" for the perf event identified by the file's
> +		"basename".

Maybe it'd worth to mention, that it does not need to be just 'event',
but anything from /sys/bus/event_source/devices/<dev>/format directory,
like

		The can be multiple terms like 'event=0xNNNN' specified
		and separated with comma. All available terms are located
		in /sys/bus/event_source/devices/<dev>/format file.

Please feel free to rephrase or use proper English ;-)

otherwise it's ok,
jirka

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

* Re: [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries
  2013-01-17 14:11         ` Jiri Olsa
@ 2013-01-18 17:46           ` Sukadev Bhattiprolu
  2013-01-18 19:20             ` Arnaldo Carvalho de Melo
  2013-01-22 17:10             ` Jiri Olsa
  0 siblings, 2 replies; 17+ messages in thread
From: Sukadev Bhattiprolu @ 2013-01-18 17:46 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Andi Kleen, Peter Zijlstra, robert.richter, Greg KH,
	Anton Blanchard, linux-kernel, Stephane Eranian, linuxppc-dev,
	Ingo Molnar, Paul Mackerras, Arnaldo Carvalho de Melo

Jiri Olsa [jolsa@redhat.com] wrote:
| Maybe it'd worth to mention, that it does not need to be just 'event',
| but anything from /sys/bus/event_source/devices/<dev>/format directory,
| like
| 
| 		The can be multiple terms like 'event=0xNNNN' specified
| 		and separated with comma. All available terms are located
| 		in /sys/bus/event_source/devices/<dev>/format file.
| 
| Please feel free to rephrase or use proper English ;-)
| 
| otherwise it's ok,
| jirka

Agree.  Thanks for the review. Here is the updated patch.

---
>From 1e3cc6b3ef87f533985b10574af472361e39eecd Mon Sep 17 00:00:00 2001
From: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Date: Tue, 8 Jan 2013 22:31:49 -0800
Subject: [PATCH] perf: Document the ABI of perf sysfs entries

This patchset addes two new sets of files to sysfs for POWER architecture.

	- perf event config format in /sys/devices/cpu/format/event
	- generic and POWER-specific perf events in /sys/devices/cpu/events/

The format of the first file is already documented in:

	sysfs-bus-event_source-devices-format

Document the format of the second set of files '/sys/devices/cpu/events/*'
which would also become part of the ABI.

Changelog[v3.2]: (small changes to this one patch).
	[Jiri Olsa]: Mention that multiple event= like terms can be specified
	in the 'events' file.

Changelog[v3.1]:
	(small changes to just this one patch).
	[Jiri Olsa]: Remove the documentation for the 'config format' file
	as it is already documented in 'Documentation/ABI/testing/'.
	[Jiri Olsa]: Move the documentation of 'events' also to 'testing'
	from 'stable'.

Changelog[v3]:
	[Greg KH] Include ABI documentation.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
 .../testing/sysfs-bus-event_source-devices-events  |   62 ++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)
 delete mode 100644 Documentation/ABI/stable/sysfs-devices-cpu-events
 create mode 100644 Documentation/ABI/testing/sysfs-bus-event_source-devices-events

diff --git a/Documentation/ABI/stable/sysfs-devices-cpu-events b/Documentation/ABI/stable/sysfs-devices-cpu-events
deleted file mode 100644
index e69de29..0000000
diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
new file mode 100644
index 0000000..0adeb52
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
@@ -0,0 +1,62 @@
+What:		/sys/devices/cpu/events/
+		/sys/devices/cpu/events/branch-misses
+		/sys/devices/cpu/events/cache-references
+		/sys/devices/cpu/events/cache-misses
+		/sys/devices/cpu/events/stalled-cycles-frontend
+		/sys/devices/cpu/events/branch-instructions
+		/sys/devices/cpu/events/stalled-cycles-backend
+		/sys/devices/cpu/events/instructions
+		/sys/devices/cpu/events/cpu-cycles
+
+Date:		2013/01/08
+
+Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
+
+Description:	Generic performance monitoring events
+
+		A collection of performance monitoring events that may be
+		supported by many/most CPUs. These events can be monitored
+		using the 'perf(1)' tool.
+
+		The contents of each file would look like:
+
+			event=0xNNNN
+
+		where 'N' is a hex digit and the number '0xNNNN' shows the
+		"raw code" for the perf event identified by the file's
+		"basename".
+
+
+What: 		/sys/devices/cpu/events/PM_LD_MISS_L1
+		/sys/devices/cpu/events/PM_LD_REF_L1
+		/sys/devices/cpu/events/PM_CYC
+		/sys/devices/cpu/events/PM_BRU_FIN
+		/sys/devices/cpu/events/PM_GCT_NOSLOT_CYC
+		/sys/devices/cpu/events/PM_BRU_MPRED
+		/sys/devices/cpu/events/PM_INST_CMPL
+		/sys/devices/cpu/events/PM_CMPLU_STALL
+
+Date:		2013/01/08
+
+Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
+		Linux Powerpc mailing list <linuxppc-dev@ozlabs.org>
+
+Description:	POWER-systems specific performance monitoring events
+
+		A collection of performance monitoring events that may be
+		supported by the POWER CPU. These events can be monitored
+		using the 'perf(1)' tool.
+
+		These events may not be supported by other CPUs.
+
+		The contents of each file would look like:
+
+			event=0xNNNN
+
+		where 'N' is a hex digit and the number '0xNNNN' shows the
+		"raw code" for the perf event identified by the file's
+		"basename".
+
+		Further, multiple terms like 'event=0xNNNN' can be specified
+		and separated with comma. All available terms are defined in
+		the /sys/bus/event_source/devices/<dev>/format file.
-- 
1.7.1

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

* Re: [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries
  2013-01-18 17:46           ` Sukadev Bhattiprolu
@ 2013-01-18 19:20             ` Arnaldo Carvalho de Melo
  2013-01-22 17:10             ` Jiri Olsa
  1 sibling, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-01-18 19:20 UTC (permalink / raw)
  To: Sukadev Bhattiprolu
  Cc: Andi Kleen, Peter Zijlstra, robert.richter, Greg KH,
	Anton Blanchard, linux-kernel, Stephane Eranian, linuxppc-dev,
	Ingo Molnar, Paul Mackerras, Jiri Olsa

Em Fri, Jan 18, 2013 at 09:46:54AM -0800, Sukadev Bhattiprolu escreveu:
> Jiri Olsa [jolsa@redhat.com] wrote:
> | Maybe it'd worth to mention, that it does not need to be just 'event',
> | but anything from /sys/bus/event_source/devices/<dev>/format directory,
> | like
> | 
> | 		The can be multiple terms like 'event=0xNNNN' specified
> | 		and separated with comma. All available terms are located
> | 		in /sys/bus/event_source/devices/<dev>/format file.
> | 
> | Please feel free to rephrase or use proper English ;-)
> | 
> | otherwise it's ok,
> | jirka
> 
> Agree.  Thanks for the review. Here is the updated patch.

Ok, I'll wait for Jiri's final acked-by, then you can resubmit the patch
series and I'll apply it to my perf/core branch.

- Arnaldo

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

* Re: [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries
  2013-01-18 17:46           ` Sukadev Bhattiprolu
  2013-01-18 19:20             ` Arnaldo Carvalho de Melo
@ 2013-01-22 17:10             ` Jiri Olsa
  1 sibling, 0 replies; 17+ messages in thread
From: Jiri Olsa @ 2013-01-22 17:10 UTC (permalink / raw)
  To: Sukadev Bhattiprolu
  Cc: Andi Kleen, Peter Zijlstra, robert.richter, Greg KH,
	Anton Blanchard, linux-kernel, Stephane Eranian, linuxppc-dev,
	Ingo Molnar, Paul Mackerras, Arnaldo Carvalho de Melo

On Fri, Jan 18, 2013 at 09:46:54AM -0800, Sukadev Bhattiprolu wrote:
> Jiri Olsa [jolsa@redhat.com] wrote:

SNIP

> +
> +Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
> +		Linux Powerpc mailing list <linuxppc-dev@ozlabs.org>
> +
> +Description:	POWER-systems specific performance monitoring events
> +
> +		A collection of performance monitoring events that may be
> +		supported by the POWER CPU. These events can be monitored
> +		using the 'perf(1)' tool.
> +
> +		These events may not be supported by other CPUs.
> +
> +		The contents of each file would look like:
> +
> +			event=0xNNNN
> +
> +		where 'N' is a hex digit and the number '0xNNNN' shows the
> +		"raw code" for the perf event identified by the file's
> +		"basename".
> +
> +		Further, multiple terms like 'event=0xNNNN' can be specified
> +		and separated with comma. All available terms are defined in
> +		the /sys/bus/event_source/devices/<dev>/format file.

Acked-by: Jiri Olsa <jolsa@redhat.com>

thanks,
jirka

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

* Re: [PATCH 1/6][v3] perf/Power7: Use macros to identify perf events
  2013-01-10  1:03 [PATCH 1/6][v3] perf/Power7: Use macros to identify perf events Sukadev Bhattiprolu
                   ` (4 preceding siblings ...)
  2013-01-10  1:07 ` [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries Sukadev Bhattiprolu
@ 2013-01-23  3:50 ` Michael Ellerman
  5 siblings, 0 replies; 17+ messages in thread
From: Michael Ellerman @ 2013-01-23  3:50 UTC (permalink / raw)
  To: Sukadev Bhattiprolu
  Cc: Andi Kleen, Peter Zijlstra, robert.richter, Anton Blanchard,
	linux-kernel, Stephane Eranian, linuxppc-dev, Ingo Molnar,
	Paul Mackerras, Arnaldo Carvalho de Melo, Jiri Olsa

On Wed, 2013-01-09 at 17:03 -0800, Sukadev Bhattiprolu wrote:
> [PATCH 1/6][v3] perf/Power7: Use macros to identify perf events
> 
> Define and use macros to identify perf events codes. This would make it
> easier and more readable when these event codes need to be used in more
> than one place.
> 
> Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
> ---
>  arch/powerpc/perf/power7-pmu.c |   28 ++++++++++++++++++++--------
>  1 files changed, 20 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/powerpc/perf/power7-pmu.c b/arch/powerpc/perf/power7-pmu.c
> index 441af08..44e70d2 100644
> --- a/arch/powerpc/perf/power7-pmu.c
> +++ b/arch/powerpc/perf/power7-pmu.c
> @@ -51,6 +51,18 @@
>  #define MMCR1_PMCSEL_MSK	0xff
>  
>  /*
> + * Power7 event codes.
> + */
> +#define	PME_PM_CYC			0x1e
> +#define	PME_PM_GCT_NOSLOT_CYC		0x100f8
> +#define	PME_PM_CMPLU_STALL		0x4000a
> +#define	PME_PM_INST_CMPL		0x2
> +#define	PME_PM_LD_REF_L1		0xc880
> +#define	PME_PM_LD_MISS_L1		0x400f0
> +#define	PME_PM_BRU_FIN			0x10068
> +#define	PME_PM_BRU_MPRED		0x400f6
> +
> +/*
>   * Layout of constraint bits:
>   * 6666555555555544444444443333333333222222222211111111110000000000
>   * 3210987654321098765432109876543210987654321098765432109876543210
> @@ -296,14 +308,14 @@ static void power7_disable_pmc(unsigned int pmc, unsigned long mmcr[])
>  }
>  
>  static int power7_generic_events[] = {
> -	[PERF_COUNT_HW_CPU_CYCLES] = 0x1e,
> -	[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x100f8, /* GCT_NOSLOT_CYC */
> -	[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = 0x4000a,  /* CMPLU_STALL */
> -	[PERF_COUNT_HW_INSTRUCTIONS] = 2,
> -	[PERF_COUNT_HW_CACHE_REFERENCES] = 0xc880,	/* LD_REF_L1_LSU*/
> -	[PERF_COUNT_HW_CACHE_MISSES] = 0x400f0,		/* LD_MISS_L1	*/
> -	[PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x10068,	/* BRU_FIN	*/
> -	[PERF_COUNT_HW_BRANCH_MISSES] = 0x400f6,	/* BR_MPRED	*/
> +	[PERF_COUNT_HW_CPU_CYCLES] =			PME_PM_CYC,
> +	[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] =	PME_PM_GCT_NOSLOT_CYC,
> +	[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] =	PME_PM_CMPLU_STALL,
> +	[PERF_COUNT_HW_INSTRUCTIONS] =			PME_PM_INST_CMPL,
> +	[PERF_COUNT_HW_CACHE_REFERENCES] =		PME_PM_LD_REF_L1,
> +	[PERF_COUNT_HW_CACHE_MISSES] =			PME_PM_LD_MISS_L1,


Your patch is good, but raises the question why we're using L1 events
for HW_CACHE.

AFAICS on Intel they use 0x42fe/0x412e, which are last-level-cache (LLC)
events.
        
        PMU name : ix86arch (Intel X86 architectural PMU)
        Name     : LLC_REFERENCES
        Desc     : count each request originating from the core to
        reference a cache line in the last level cache. The count may
        include speculation, but excludes cache line fills due to
        hardware prefetch
        Code     : 0x4f2e

        PMU name : ix86arch (Intel X86 architectural PMU)
        Name     : LLC_MISSES
        Desc     : count each cache miss condition for references to the
        last level cache. The event count may include speculation, but
        excludes cache line fills due to hardware prefetch
        Code     : 0x412e


That would seem to more closely match our PM_L3_LD_HIT/MISS?

cheers

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

* [PATCH 1/6][v3] perf/Power7: Use macros to identify perf events
@ 2013-01-10  0:20 sukadev
  0 siblings, 0 replies; 17+ messages in thread
From: sukadev @ 2013-01-10  0:20 UTC (permalink / raw)
  To: Peter Zijlstra, Paul Mackerras, Ingo Molnar
  Cc: Andi Kleen, robert.richter, Anton Blanchard, linux-kernel,
	Stephane Eranian, linuxppc-dev, Arnaldo Carvalho de Melo,
	Jiri Olsa

Define and use macros to identify perf events codes. This would make it
easier and more readable when these event codes need to be used in more
than one place.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
 arch/powerpc/perf/power7-pmu.c |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/perf/power7-pmu.c b/arch/powerpc/perf/power7-pmu.c
index 441af08..44e70d2 100644
--- a/arch/powerpc/perf/power7-pmu.c
+++ b/arch/powerpc/perf/power7-pmu.c
@@ -51,6 +51,18 @@
 #define MMCR1_PMCSEL_MSK	0xff
 
 /*
+ * Power7 event codes.
+ */
+#define	PME_PM_CYC			0x1e
+#define	PME_PM_GCT_NOSLOT_CYC		0x100f8
+#define	PME_PM_CMPLU_STALL		0x4000a
+#define	PME_PM_INST_CMPL		0x2
+#define	PME_PM_LD_REF_L1		0xc880
+#define	PME_PM_LD_MISS_L1		0x400f0
+#define	PME_PM_BRU_FIN			0x10068
+#define	PME_PM_BRU_MPRED		0x400f6
+
+/*
  * Layout of constraint bits:
  * 6666555555555544444444443333333333222222222211111111110000000000
  * 3210987654321098765432109876543210987654321098765432109876543210
@@ -296,14 +308,14 @@ static void power7_disable_pmc(unsigned int pmc, unsigned long mmcr[])
 }
 
 static int power7_generic_events[] = {
-	[PERF_COUNT_HW_CPU_CYCLES] = 0x1e,
-	[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x100f8, /* GCT_NOSLOT_CYC */
-	[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = 0x4000a,  /* CMPLU_STALL */
-	[PERF_COUNT_HW_INSTRUCTIONS] = 2,
-	[PERF_COUNT_HW_CACHE_REFERENCES] = 0xc880,	/* LD_REF_L1_LSU*/
-	[PERF_COUNT_HW_CACHE_MISSES] = 0x400f0,		/* LD_MISS_L1	*/
-	[PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x10068,	/* BRU_FIN	*/
-	[PERF_COUNT_HW_BRANCH_MISSES] = 0x400f6,	/* BR_MPRED	*/
+	[PERF_COUNT_HW_CPU_CYCLES] =			PME_PM_CYC,
+	[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] =	PME_PM_GCT_NOSLOT_CYC,
+	[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] =	PME_PM_CMPLU_STALL,
+	[PERF_COUNT_HW_INSTRUCTIONS] =			PME_PM_INST_CMPL,
+	[PERF_COUNT_HW_CACHE_REFERENCES] =		PME_PM_LD_REF_L1,
+	[PERF_COUNT_HW_CACHE_MISSES] =			PME_PM_LD_MISS_L1,
+	[PERF_COUNT_HW_BRANCH_INSTRUCTIONS] =		PME_PM_BRU_FIN,
+	[PERF_COUNT_HW_BRANCH_MISSES] =			PME_PM_BRU_MPRED,
 };
 
 #define C(x)	PERF_COUNT_HW_CACHE_##x
-- 
1.7.1

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

* [PATCH 1/6][v3] perf/Power7: Use macros to identify perf events
@ 2013-01-10  0:06 sukadev
  0 siblings, 0 replies; 17+ messages in thread
From: sukadev @ 2013-01-10  0:06 UTC (permalink / raw)
  To: Peter Zijlstra, Paul Mackerras
  Cc: robert.richter, linuxppc-dev, Anton Blanchard, Jiri Olsa,
	Arnaldo Carvalho de Melo

Define and use macros to identify perf events codes. This would make it
easier and more readable when these event codes need to be used in more
than one place.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
 arch/powerpc/perf/power7-pmu.c |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/perf/power7-pmu.c b/arch/powerpc/perf/power7-pmu.c
index 441af08..44e70d2 100644
--- a/arch/powerpc/perf/power7-pmu.c
+++ b/arch/powerpc/perf/power7-pmu.c
@@ -51,6 +51,18 @@
 #define MMCR1_PMCSEL_MSK	0xff
 
 /*
+ * Power7 event codes.
+ */
+#define	PME_PM_CYC			0x1e
+#define	PME_PM_GCT_NOSLOT_CYC		0x100f8
+#define	PME_PM_CMPLU_STALL		0x4000a
+#define	PME_PM_INST_CMPL		0x2
+#define	PME_PM_LD_REF_L1		0xc880
+#define	PME_PM_LD_MISS_L1		0x400f0
+#define	PME_PM_BRU_FIN			0x10068
+#define	PME_PM_BRU_MPRED		0x400f6
+
+/*
  * Layout of constraint bits:
  * 6666555555555544444444443333333333222222222211111111110000000000
  * 3210987654321098765432109876543210987654321098765432109876543210
@@ -296,14 +308,14 @@ static void power7_disable_pmc(unsigned int pmc, unsigned long mmcr[])
 }
 
 static int power7_generic_events[] = {
-	[PERF_COUNT_HW_CPU_CYCLES] = 0x1e,
-	[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x100f8, /* GCT_NOSLOT_CYC */
-	[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = 0x4000a,  /* CMPLU_STALL */
-	[PERF_COUNT_HW_INSTRUCTIONS] = 2,
-	[PERF_COUNT_HW_CACHE_REFERENCES] = 0xc880,	/* LD_REF_L1_LSU*/
-	[PERF_COUNT_HW_CACHE_MISSES] = 0x400f0,		/* LD_MISS_L1	*/
-	[PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x10068,	/* BRU_FIN	*/
-	[PERF_COUNT_HW_BRANCH_MISSES] = 0x400f6,	/* BR_MPRED	*/
+	[PERF_COUNT_HW_CPU_CYCLES] =			PME_PM_CYC,
+	[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] =	PME_PM_GCT_NOSLOT_CYC,
+	[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] =	PME_PM_CMPLU_STALL,
+	[PERF_COUNT_HW_INSTRUCTIONS] =			PME_PM_INST_CMPL,
+	[PERF_COUNT_HW_CACHE_REFERENCES] =		PME_PM_LD_REF_L1,
+	[PERF_COUNT_HW_CACHE_MISSES] =			PME_PM_LD_MISS_L1,
+	[PERF_COUNT_HW_BRANCH_INSTRUCTIONS] =		PME_PM_BRU_FIN,
+	[PERF_COUNT_HW_BRANCH_MISSES] =			PME_PM_BRU_MPRED,
 };
 
 #define C(x)	PERF_COUNT_HW_CACHE_##x
-- 
1.7.1

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

end of thread, other threads:[~2013-01-23  3:50 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-10  1:03 [PATCH 1/6][v3] perf/Power7: Use macros to identify perf events Sukadev Bhattiprolu
2013-01-10  1:04 ` [PATCH 2/6][v3] perf: Make EVENT_ATTR global Sukadev Bhattiprolu
2013-01-10  1:05 ` [PATCH 3/6][v3] perf/POWER7: Make generic event translations available in sysfs Sukadev Bhattiprolu
2013-01-10  1:06 ` [PATCH 4/6][v3] perf/POWER7: Make some POWER7 events " Sukadev Bhattiprolu
2013-01-10  1:06 ` [PATCH 5/6][v3] perf: Create a sysfs entry for Power event format Sukadev Bhattiprolu
2013-01-10  1:07 ` [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries Sukadev Bhattiprolu
2013-01-15 18:57   ` Arnaldo Carvalho de Melo
2013-01-15 22:47     ` Greg KH
2013-01-16 11:30     ` Jiri Olsa
2013-01-16 18:58       ` Sukadev Bhattiprolu
2013-01-17 14:11         ` Jiri Olsa
2013-01-18 17:46           ` Sukadev Bhattiprolu
2013-01-18 19:20             ` Arnaldo Carvalho de Melo
2013-01-22 17:10             ` Jiri Olsa
2013-01-23  3:50 ` [PATCH 1/6][v3] perf/Power7: Use macros to identify perf events Michael Ellerman
  -- strict thread matches above, loose matches on Subject: below --
2013-01-10  0:20 sukadev
2013-01-10  0:06 sukadev

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).