From 8a0dbd8f3fce2834292efa50c15ca64d4f6a6536 Mon Sep 17 00:00:00 2001
From: Sukadev Bhattiprolu <redacted>
Date: Wed, 7 Nov 2012 09:36:14 -0800
Subject: [PATCH 2/4] 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 <redacted>
---
arch/powerpc/perf/power7-pmu.c | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
From d05d1ce6d55bf339eee6230ded9f5dd1351f60e5 Mon Sep 17 00:00:00 2001
From: Sukadev Bhattiprolu <redacted>
Date: Tue, 6 Nov 2012 14:07:36 -0800
Subject: [PATCH 3/4] perf/POWER7: Make event translations available in sysfs
Make the perf events supported by 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=0x03
This patch is based on commits that implement this functionality on x86.
Eg:
commit a47473939db20e3961b200eb00acf5fcf084d755
Author: Jiri Olsa [off-list ref]
Date: Wed Oct 10 14:53:11 2012 +0200
perf/x86: Make hardware event translations available in sysfs
Signed-off-by: Sukadev Bhattiprolu <redacted>
---
arch/powerpc/include/asm/perf_event_server.h | 21 +++++++++++++++++
arch/powerpc/perf/core-book3s.c | 12 +++++++++
arch/powerpc/perf/power7-pmu.c | 32 ++++++++++++++++++++++++++
3 files changed, 65 insertions(+), 0 deletions(-)
Jiri Olsa [jolsa@redhat.com] wrote:
| On Wed, Nov 07, 2012 at 11:19:28AM -0800, Sukadev Bhattiprolu wrote:
|
| SNIP
|
| > +struct perf_pmu_events_attr {
| > + struct device_attribute attr;
| > + u64 id;
| > +};
| > +
| > +extern ssize_t power_events_sysfs_show(struct device *dev,
| > + struct device_attribute *attr, char *page);
| > +
| > +#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, power_events_sysfs_show, NULL),\
| > + .id = PM_##_id, \
| > + };
|
| this is duplicating the x86 code, perhaps it could be moved
| to include/linux/perf_event.h and shared globaly
Ok.
Can we remove the assumption that the event id is a generic event that
has PERF_COUNT_HW_ prefix and also let the architectures pass in a "show"
function ? This would allow architectures to display any arch specific
events that don't yet have a generic counterpart.
IOW, can we do something like this (untested) and make PERF_EVENT_ATTR global:
From: Jiri Olsa <hidden> Date: 2012-11-16 12:52:15
On Wed, Nov 14, 2012 at 10:20:45AM -0800, Sukadev Bhattiprolu wrote:
Jiri Olsa [jolsa@redhat.com] wrote:
| On Wed, Nov 07, 2012 at 11:19:28AM -0800, Sukadev Bhattiprolu wrote:
|
| SNIP
|
| > +struct perf_pmu_events_attr {
| > + struct device_attribute attr;
| > + u64 id;
| > +};
| > +
| > +extern ssize_t power_events_sysfs_show(struct device *dev,
| > + struct device_attribute *attr, char *page);
| > +
| > +#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, power_events_sysfs_show, NULL),\
| > + .id = PM_##_id, \
| > + };
|
| this is duplicating the x86 code, perhaps it could be moved
| to include/linux/perf_event.h and shared globaly
Ok.
Can we remove the assumption that the event id is a generic event that
has PERF_COUNT_HW_ prefix and also let the architectures pass in a "show"
function ? This would allow architectures to display any arch specific
events that don't yet have a generic counterpart.
IOW, can we do something like this (untested) and make PERF_EVENT_ATTR global:
Jiri Olsa [jolsa@redhat.com] wrote:
| >
| > Can we remove the assumption that the event id is a generic event that
| > has PERF_COUNT_HW_ prefix and also let the architectures pass in a "show"
| > function ? This would allow architectures to display any arch specific
| > events that don't yet have a generic counterpart.
| >
| > IOW, can we do something like this (untested) and make PERF_EVENT_ATTR global:
|
| hm, then you probably can use following:
|
| http://www.spinics.net/lists/kernel/msg1434233.html
For now, power events can simply be u64 - so am hoping to have something
like this and replace the raw codes:
#define PM_CYC 0x1e
#define PM_GCT_NOSLOT_CYC 0x100f8
EVENT_ATTR_STR() is interesting, but would require new/extra macros like
#define PM_CYC_STR "0x1e"
#define PM_GCT_NOSLOT_CYC_STR "0x100f8"
I went down the path we discussed earlier - to have x86 and Power share
the EVENT_ATTR() macros. This is making the x86 code less concise
EVENT_ATTR(cpu-cycles, CPU_CYCLES)
becomes
EVENT_ATTR(cpu-cycles, PERF_COUNT_HW_CPU_CYCLES, events_sysfs_show)
with each EVENT_ATTR() explcitly adding events_sysfs_show or needing another
wrapper around the wrappers.
Still tweaking it, but would it be flexible to make 'struct pmu_events_attr'
common and let architectures define the EVENT_ATTR() as needed ? Would
duplicate some code but hopefully not a lot.
Sukadev
From: Jiri Olsa <hidden> Date: 2012-11-19 20:34:37
On Fri, Nov 16, 2012 at 11:35:37AM -0800, Sukadev Bhattiprolu wrote:
Jiri Olsa [jolsa@redhat.com] wrote:
| >
| > Can we remove the assumption that the event id is a generic event that
| > has PERF_COUNT_HW_ prefix and also let the architectures pass in a "show"
| > function ? This would allow architectures to display any arch specific
| > events that don't yet have a generic counterpart.
| >
| > IOW, can we do something like this (untested) and make PERF_EVENT_ATTR global:
|
| hm, then you probably can use following:
|
| http://www.spinics.net/lists/kernel/msg1434233.html
For now, power events can simply be u64 - so am hoping to have something
like this and replace the raw codes:
#define PM_CYC 0x1e
#define PM_GCT_NOSLOT_CYC 0x100f8
EVENT_ATTR_STR() is interesting, but would require new/extra macros like
#define PM_CYC_STR "0x1e"
#define PM_GCT_NOSLOT_CYC_STR "0x100f8"
I went down the path we discussed earlier - to have x86 and Power share
the EVENT_ATTR() macros. This is making the x86 code less concise
EVENT_ATTR(cpu-cycles, CPU_CYCLES)
becomes
EVENT_ATTR(cpu-cycles, PERF_COUNT_HW_CPU_CYCLES, events_sysfs_show)
with each EVENT_ATTR() explcitly adding events_sysfs_show or needing another
wrapper around the wrappers.
Still tweaking it, but would it be flexible to make 'struct pmu_events_attr'
common and let architectures define the EVENT_ATTR() as needed ? Would
duplicate some code but hopefully not a lot.
From bafc551c31ce23c1cba0b75d23de6c46aba90f26 Mon Sep 17 00:00:00 2001
From: Sukadev Bhattiprolu <redacted>
Date: Tue, 6 Nov 2012 16:30:28 -0800
Subject: [PATCH 4/4] 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.
$ cat /sys/bus/event_source/devices/cpu/format/event
config:0-20
The format of the event is the same for all POWER cpus, so bulk of this
change is in the code common to POWER cpus.
Signed-off-by: Sukadev Bhattiprolu <redacted>
---
arch/powerpc/include/asm/perf_event_server.h | 8 ++++++++
arch/powerpc/perf/core-book3s.c | 19 +++++++++++++++++++
arch/powerpc/perf/power7-pmu.c | 1 +
3 files changed, 28 insertions(+), 0 deletions(-)
From: Jiri Olsa <hidden> Date: 2012-11-14 10:28:12
On Wed, Nov 07, 2012 at 11:19:52AM -0800, Sukadev Bhattiprolu wrote:
quoted hunk
From bafc551c31ce23c1cba0b75d23de6c46aba90f26 Mon Sep 17 00:00:00 2001
From: Sukadev Bhattiprolu <redacted>
Date: Tue, 6 Nov 2012 16:30:28 -0800
Subject: [PATCH 4/4] 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.
$ cat /sys/bus/event_source/devices/cpu/format/event
config:0-20
The format of the event is the same for all POWER cpus, so bulk of this
change is in the code common to POWER cpus.
Signed-off-by: Sukadev Bhattiprolu <redacted>
---
arch/powerpc/include/asm/perf_event_server.h | 8 ++++++++
arch/powerpc/perf/core-book3s.c | 19 +++++++++++++++++++
arch/powerpc/perf/power7-pmu.c | 1 +
3 files changed, 28 insertions(+), 0 deletions(-)
From: Suzuki K. Poulose <hidden> Date: 2012-11-20 10:43:56
On 11/08/2012 12:48 AM, Sukadev Bhattiprolu wrote:
From b8beef080260c1625c8f801105504a82005295e5 Mon Sep 17 00:00:00 2001
From: Sukadev Bhattiprolu <redacted>
Date: Wed, 31 Oct 2012 11:21:28 -0700
Subject: [PATCH 1/4] perf/powerpc: Use uapi/unistd.h to fix build error
Use the 'unistd.h' from arch/powerpc/include/uapi to build the perf tool.
Signed-off-by: Sukadev Bhattiprolu <redacted>
Without this patch, I couldn't build perf on powerpc, with 3.7.0-rc2
Tested-by: Suzuki K. Poulose <redacted>
Thanks
Suzuki