perf tools: Power7 events name available for perf
v2 cover perf tools: Power7 events name available for perf
Thank for Sukadev Bhattip and Xiao Guangrong's help. Thank for Michael Ellerman's review.
There is the Change Log for v2:
1. As Michael Ellerman suggested, I added runtime overhead information in the 0002 patch's description.
2. Put the events name in a new head file which is named "power7-events-list.h", and use several macros, such as,
#define EVENT(_name, _code) POWER_EVENT_ATTR(_name, _code) #include "power7-events-list.h" #undef EVENT
to generate different outputs.
Thanks
Runzhen Wang
Runzhen Wang (2):
perf tools: fix a typo of a Power7 event name perf tools: Make Power7 events available for perf
.../testing/sysfs-bus-event_source-devices-events | 2 +- arch/powerpc/include/asm/perf_event_server.h | 4 +- arch/powerpc/perf/power7-events-list.h | 548 ++++++++++++++++++++ arch/powerpc/perf/power7-pmu.c | 150 ++---- 4 files changed, 584 insertions(+), 120 deletions(-) create mode 100644 arch/powerpc/perf/power7-events-list.h
Signature · 1 line
1.7.9.5
PATCH v2 2/2 perf tools: Make Power7 events available for perf
Power7 supports over 530 different perf events but only a small subset of these can be specified by name, for the remaining events, we must specify them by their raw code:
perf stat -e r2003c <application>
This patch makes all the POWER7 events available in sysfs. So we can instead specify these as:
perf stat -e 'cpu/PM_CMPLU_STALL_DFU/' <application>
where PM_CMPLU_STALL_DFU is the r2003c in previous example.
Before this patch is applied, the size of power7-pmu.o is:
$ size arch/powerpc/perf/power7-pmu.o text data bss dec hex filename 3073 2720 0 5793 16a1 arch/powerpc/perf/power7-pmu.o
and after the patch is applied, it is:
$ size arch/powerpc/perf/power7-pmu.o text data bss dec hex filename 15950 31112 0 47062 b7d6 arch/powerpc/perf/power7-pmu.o
For the run time overhead, I use two scripts, one is "event_name.sh", which contains 50 event names, it looks like:
# ./perf record -e 'cpu/PM_CMPLU_STALL_DFU/' -e ..... /bin/sleep 1
the other one is named "event_code.sh" which use corresponding events raw code instead of events names, it looks like:
# ./perf record -e r2003c -e ...... /bin/sleep 1
below is the result.
Using events name:
[root@localhost perf]# time ./event_name.sh
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.002 MB perf.data (~102 samples) ]
real 0m1.192s
user 0m0.028s
sys 0m0.106s
Using events raw code:
[root@localhost perf]# time ./event_code.sh
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.003 MB perf.data (~112 samples) ]
real 0m1.198s
user 0m0.028s
sys 0m0.105s
--- arch/powerpc/include/asm/perf_event_server.h | 4 +- arch/powerpc/perf/power7-events-list.h | 548 ++++++++++++++++++++++++++ arch/powerpc/perf/power7-pmu.c | 148 ++----- 3 files changed, 582 insertions(+), 118 deletions(-) create mode 100644 arch/powerpc/perf/power7-events-list.h
arch/powerpc/include/asm/perf_event_server.h +2 -2
@@ -136,11 +136,11 @@ extern ssize_t power_events_sysfs_show(struct device *dev,#define EVENT_PTR (_id, _suffix) &EVENT_VAR(_id, _suffix).attr.attr#define EVENT_ATTR (_name, _id, _suffix) \ - PMU_EVENT_ATTR(_name, EVENT_VAR(_id, _suffix), PME_PM_##_id, \ + PMU_EVENT_ATTR(_name, EVENT_VAR(_id, _suffix), PME_##_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) -#define POWER_EVENT_ATTR (_name, _id) EVENT_ATTR(PM_##_name, _id, _p) +#define POWER_EVENT_ATTR (_name, _id) EVENT_ATTR(_name, _id, _p)#define POWER_EVENT_PTR (_id) EVENT_PTR(_id, _p)
arch/powerpc/perf/power7-events-list.h new file +548 -0
548 lines not on this page · raw message
arch/powerpc/perf/power7-pmu.c +32 -116
165 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH v2 2/2] perf tools: Make Power7 events available for perf
Quoted 8 lines · Runzhen Wang
This patch makes all the POWER7 events available in sysfs.
...
$ size arch/powerpc/perf/power7-pmu.o text data bss dec hex filename 3073 2720 0 5793 16a1 arch/powerpc/perf/power7-pmu.o
Quoted 5 lines
and after the patch is applied, it is:
$ size arch/powerpc/perf/power7-pmu.o text data bss dec hex filename 15950 31112 0 47062 b7d6 arch/powerpc/perf/power7-pmu.o
So if I'm reading this right, there's 45k of overhead for just one cpu type?
What happens if we do this on x86?
If we have similar for p6/p4/core2/nehalem/ivb/snb/amd10h/amd15h/amd16h/knb that's 450k of event defintions in the kernel. And may I remind everyone that you can't compile perf_event support as a module, nor can you unconfigure it on x86 (it's always built in, no option to disable).
I'd like to repeat my unpopular position that we just link perf against libpfm4 and keep event tables in userspace where they belong.
Vince
Re: [PATCH v2 2/2] perf tools: Make Power7 events available for perf
Quoted 10 lines · Vince Weaver
Quoted 8 lines · Runzhen Wang
This patch makes all the POWER7 events available in sysfs.
...
$ size arch/powerpc/perf/power7-pmu.o text data bss dec hex filename 3073 2720 0 5793 16a1 arch/powerpc/perf/power7-pmu.o
Quoted 8 lines
Quoted 5 lines
and after the patch is applied, it is:
$ size arch/powerpc/perf/power7-pmu.o text data bss dec hex filename 15950 31112 0 47062 b7d6 arch/powerpc/perf/power7-pmu.oSo if I'm reading this right, there's 45k of overhead for just one cpu type?
I think there's another ~56K at runtime too, at least on my system where each sysfs_dirent is 112 bytes.
Quoted 6 lines
What happens if we do this on x86?
If we have similar for p6/p4/core2/nehalem/ivb/snb/amd10h/amd15h/amd16h/knb that's 450k of event defintions in the kernel. And may I remind everyone that you can't compile
perf_eventsupport as a module, nor can you unconfigure it on x86 (it's always built in, no option to disable).
To be honest on Power7 systems we're not really bothered about ~100K, that's less than two pages. But I agree with your point that it's getting a bit silly.
Various folks have tried over the years to get alternative approaches adopted (as I'm sure you know), and this has just ended up as the path of least resistance.
Quoted 2 lines
I'd like to repeat my unpopular position that we just link perf against libpfm4 and keep event tables in userspace where they belong.
I don't think it even needs libpfm4, just some csv files in tools/perf would do the trick.
Instead we have Google using gooda, which provides event decoding on top of perf (via libpfm4). Andi Kleen at Intel has a tool that provides event decoding on top of perf. Presumably Facebook do too? And at IBM most folks still use oprofile, because it provides event decoding.
cheers
Re: [PATCH v2 2/2] perf tools: Make Power7 events available for perf
Quoted 2 lines · Michael Ellerman
I don't think it even needs libpfm4, just some csv files in
tools/perfwould do the trick.
Right; I think Stephane and Jiri are in favour of creating a 'new' project that includes just the event definitions in a plain text format and a little library with parser to be used by all interested parties.
Its just not something that's moving along at any pace at all atm :/
Re: [PATCH v2 2/2] perf tools: Make Power7 events available for perf
Quoted 7 lines · Peter Zijlstra
Quoted 2 lines · Michael Ellerman
I don't think it even needs libpfm4, just some csv files in
tools/perfwould do the trick.Right; I think Stephane and Jiri are in favour of creating a 'new' project that includes just the event definitions in a plain text format and a little library with parser to be used by all interested parties.
I'd be fine with that if it's stuck somewhere into tools/lib/ or so.
Thanks,
Ingo
Re: [PATCH v2 2/2] perf tools: Make Power7 events available for perf
In reply to Peter ZijlstraQuoted 7 lines · Peter Zijlstra
Quoted 2 lines · Michael Ellerman
I don't think it even needs libpfm4, just some csv files in
tools/perfwould do the trick.Right; I think Stephane and Jiri are in favour of creating a 'new' project that includes just the event definitions in a plain text format and a little library with parser to be used by all interested parties.
OK that would be great.
The part that seems to be missing to make that work is we have no way of matching the PMU that appears in /sys with a list of events.
Eg. on my system I have /sys/bus/event_source/devices/cpu - but there's nothing in there to identify that it's a Sandy Bridge.
For the cpu you can obviously just detect what processor you're on with cpuid or whatever, but it's a bit of a hack. And that really doesn't work for non-cpu PMUs.
So it seems to me we need to add an attribute to the PMU in sysfs so that we can identify it and match it up with a list of events?
cheers
Re: [PATCH v2 2/2] perf tools: Make Power7 events available for perf
Quoted 6 lines · Michael Ellerman
Quoted 4 lines · Peter Zijlstra
Right; I think Stephane and Jiri are in favour of creating a 'new' project that includes just the event definitions in a plain text format and a little library with parser to be used by all interested parties.
Quoted 7 lines
OK that would be great.
The part that seems to be missing to make that work is we have no way of matching the PMU that appears in /sys with a list of events.
Eg. on my system I have
/sys/bus/event_source/devices/cpu- but there's nothing in there to identify that it's a Sandy Bridge.
So something like they have on ARM?
vince@pandaboard:/sys/bus/event_source/devices$ ls -l lrwxrwxrwx 1 root root 0 Jul 8 21:57 ARMv7 Cortex-A9 -> ../../../devices/ARMv7 Cortex-A9 lrwxrwxrwx 1 root root 0 Jul 8 21:57 breakpoint -> ../../../devices/breakpoint lrwxrwxrwx 1 root root 0 Jul 8 21:57 software -> ../../../devices/software lrwxrwxrwx 1 root root 0 Jul 8 21:57 tracepoint -> ../../../devices/tracepoint
Quoted 3 lines
For the cpu you can obviously just detect what processor you're on with cpuid or whatever, but it's a bit of a hack. And that really doesn't work for non-cpu PMUs.
why is it a hack to use cpuid?
People have done event lists in userspace for years. Why must it be the kernel's job?
Vince Weaver
[email protected]
http://www.eece.maine.edu/~vweaver/
Re: [PATCH v2 2/2] perf tools: Make Power7 events available for perf
Quoted 16 lines · Vince Weaver
Quoted 6 lines · Michael Ellerman
Quoted 4 lines · Peter Zijlstra
Right; I think Stephane and Jiri are in favour of creating a 'new' project that includes just the event definitions in a plain text format and a little library with parser to be used by all interested parties.
Quoted 7 lines
OK that would be great.
The part that seems to be missing to make that work is we have no way of matching the PMU that appears in /sys with a list of events.
Eg. on my system I have
/sys/bus/event_source/devices/cpu- but there's nothing in there to identify that it's a Sandy Bridge.
Quoted 7 lines
So something like they have on ARM?
vince@pandaboard:/sys/bus/event_source/devices$ ls -l lrwxrwxrwx 1 root root 0 Jul 8 21:57 ARMv7 Cortex-A9 -> ../../../devices/ARMv7 Cortex-A9 lrwxrwxrwx 1 root root 0 Jul 8 21:57 breakpoint -> ../../../devices/breakpoint lrwxrwxrwx 1 root root 0 Jul 8 21:57 software -> ../../../devices/software lrwxrwxrwx 1 root root 0 Jul 8 21:57 tracepoint -> ../../../devices/tracepoint
Sort of. I wasn't thinking of using the name, rather adding an attribute with a well defined list of values.
Quoted 5 lines
Quoted 3 lines
For the cpu you can obviously just detect what processor you're on with cpuid or whatever, but it's a bit of a hack. And that really doesn't work for non-cpu PMUs.
why is it a hack to use cpuid?
Because you're assuming that the PMU the kernel has exposed is for the cpu you happen to be executing on.
But the real issue is with PMUs that are not in the CPU - there is no easy way for userspace to detect them and determine which event list it should be consulting.
Quoted 2 lines
People have done event lists in userspace for years. Why must it be the kernel's job?
This whole thread is about making the event list not the kernel's job?
The part that _is_ the kernels job is detecting the hardware and providing an API to access it. What I'm saying is that the kernel API should include some sort of identifier so that userspace can reliably determine the event list to use.
cheers
Re: [PATCH v2 2/2] perf tools: Make Power7 events available for perf
Quoted 9 lines · Michael Ellerman
Quoted 1 line · Vince Weaver
why is it a hack to use cpuid?
Because you're assuming that the PMU the kernel has exposed is for the cpu you happen to be executing on.
But the real issue is with PMUs that are not in the CPU - there is no easy way for userspace to detect them and determine which event list it should be consulting.
what kind of devices are you talking about? If they have kernel/perf_event support then they'd be putting a directory entry with a unique name into /sys/bus/event_source/devices/, right?
Quoted 1 line
This whole thread is about making the event list not the kernel's job?
Yes. This has been debated forever here; I'm firmly in the "event lists should be entirely in userspace" camp but that's not the majority position.
Hopefully everyone agrees though that including 100k+ of event lists in the kernel is a bit silly, especially as only a subset of people would ever use them.
There's the other issue that event lists are known to change due to bugs and whatnot (Intel likes to change things up every few months and silently change the event lists in their documentation). It's a lot easier patching and distributing a new user-space event library [hours to days] then trying to get event list changes into the kernel, backported to stable, and then out into vendor kernels, and then on updated machines [weeks to never].
Quoted 4 lines
The part that _is_ the kernels job is detecting the hardware and providing an API to access it. What I'm saying is that the kernel API should include some sort of identifier so that userspace can reliably determine the event list to use.
I'm just curious if you have a specific piece of hardware in mind that won't fit the current model or if this is a theoretical concern.
Vince
Re: [PATCH v2 2/2] perf tools: Make Power7 events available for perf
Quoted 5 lines · Vince Weaver
Quoted 3 lines · Michael Ellerman
Quoted 1 line · Vince Weaver
why is it a hack to use cpuid?
Quoted 8 lines
Quoted 6 lines
Because you're assuming that the PMU the kernel has exposed is for the cpu you happen to be executing on.
But the real issue is with PMUs that are not in the CPU - there is no easy way for userspace to detect them and determine which event list it should be consulting.
what kind of devices are you talking about?
GPUs, PCI host bridges, memory controllers, PCI attached accelerators, strange devices on non standard buses, you name it.
Quoted 3 lines
If they have
kernel/perf_eventsupport then they'd be putting a directory entry with a unique name into/sys/bus/event_source/devices/, right?
Yes. But although the name is unique it's not sufficient to actually identify the list of events.
For example the CPU PMU is called "cpu" on most architectures, so userspace needs to work out which exact CPU it is - and I know that's possible, but it means the "simple little" event parsing library is not so simple anymore.
Then imagine you have a GPU on PCI which registers its PMU as "gpu" - how do you work out which GPU it is? Userspace can probably work it out by trawling through sysfs and finding the vendor and device ids and matching that with a lookup table. The library just got less simple again.
Now say you have a PMU in your memory controller, it's not represented in sysfs except for the PMU. Which memory controller is it? Maybe you can infer it from the CPU you're on, but maybe you can't.
Quoted 5 lines
Quoted 1 line
This whole thread is about making the event list not the kernel's job?
Yes. This has been debated forever here; I'm firmly in the "event lists should be entirely in userspace" camp but that's not the majority position.
Yes we agree on the event list being in userspace, you can stop trying to convince me.
What shouldn't be in userspace is the logic to detect which PMUs are available on the system.
cheers
Re: [PATCH v2 2/2] perf tools: Make Power7 events available for perf
In reply to Vince WeaverQuoted 8 lines · Vince Weaver
So something like they have on ARM?
vince@pandaboard:/sys/bus/event_source/devices$ ls -l lrwxrwxrwx 1 root root 0 Jul 8 21:57 ARMv7 Cortex-A9 -> ../../../devices/ARMv7 Cortex-A9 lrwxrwxrwx 1 root root 0 Jul 8 21:57 breakpoint -> ../../../devices/breakpoint lrwxrwxrwx 1 root root 0 Jul 8 21:57 software -> ../../../devices/software lrwxrwxrwx 1 root root 0 Jul 8 21:57 tracepoint -> ../../../devices/tracepoint
Right so what I remember of the ARM case is that their /proc/cpuinfo isn't sufficient to identify their PMU. And they don't have a cpuid like instruction at all.
Quoted 5 lines
Quoted 3 lines
For the cpu you can obviously just detect what processor you're on with cpuid or whatever, but it's a bit of a hack. And that really doesn't work for non-cpu PMUs.
why is it a hack to use cpuid?
I agree, for x86 cpuid is perfectly fine, as would /proc/cpuinfo be, I suspect that just the model number is sufficient in most cases, even for uncore stuff.
Re: [PATCH v2 2/2] perf tools: Make Power7 events available for perf
Quoted 10 lines · Peter Zijlstra
Quoted 8 lines · Vince Weaver
So something like they have on ARM?
vince@pandaboard:/sys/bus/event_source/devices$ ls -l lrwxrwxrwx 1 root root 0 Jul 8 21:57 ARMv7 Cortex-A9 -> ../../../devices/ARMv7 Cortex-A9 lrwxrwxrwx 1 root root 0 Jul 8 21:57 breakpoint -> ../../../devices/breakpoint lrwxrwxrwx 1 root root 0 Jul 8 21:57 software -> ../../../devices/software lrwxrwxrwx 1 root root 0 Jul 8 21:57 tracepoint -> ../../../devices/tracepoint
Quoted 3 lines
Right so what I remember of the ARM case is that their
/proc/cpuinfoisn't sufficient to identify their PMU. And they don't have a cpuid like instruction at all.
libpfm4 uses the
CPU part : 0xc09
line in /proc/cpuinfo on ARM, and that's enough for the processors PAPI supports (Cortex A8/A9/A15 plus the 1176 on the raspberry-pi). I'm guessing it wouldn't be enough if we wanted to support *all* ARMs with PMUs.
And speaking of ARM, I should be railing at them for breaking the ABI too, with their (understandable yet still ABI breaking) decision to remove BogoMIPS from /proc/cpuinfo. That change will impact PAPI as well as various other programs I maintain that have the misfortune of parsing that file.
Vince
Re: [PATCH v2 2/2] perf tools: Make Power7 events available for perf
Quoted 16 lines · Vince Weaver
Quoted 10 lines · Peter Zijlstra
Quoted 8 lines · Vince Weaver
So something like they have on ARM?
vince@pandaboard:/sys/bus/event_source/devices$ ls -l lrwxrwxrwx 1 root root 0 Jul 8 21:57 ARMv7 Cortex-A9 -> ../../../devices/ARMv7 Cortex-A9 lrwxrwxrwx 1 root root 0 Jul 8 21:57 breakpoint -> ../../../devices/breakpoint lrwxrwxrwx 1 root root 0 Jul 8 21:57 software -> ../../../devices/software lrwxrwxrwx 1 root root 0 Jul 8 21:57 tracepoint -> ../../../devices/tracepointQuoted 3 lines
Right so what I remember of the ARM case is that their
/proc/cpuinfoisn't sufficient to identify their PMU. And they don't have a cpuid like instruction at all.
Quoted 6 lines
libpfm4 uses the
CPU part :0xc09
line in/proc/cpuinfoon ARM, and that's enough for the processors PAPI supports (Cortex A8/A9/A15 plus the 1176 on the raspberry-pi). I'm guessing it wouldn't be enough if we wanted to support *all* ARMs with PMUs.
The CPU part you cite is actually A9-specific, so you probably want to probe each CPU specifically. Take a look at the cpuinfo parsing in OProfile (used by operf).
Quoted 5 lines
And speaking of ARM, I should be railing at them for breaking the ABI too, with their (understandable yet still ABI breaking) decision to remove BogoMIPS from
/proc/cpuinfo. That change will impact PAPI as well as various other programs I maintain that have the misfortune of parsing that file.
Really? Why are you checking for that line at all?
Will
Re: [PATCH v2 2/2] perf tools: Make Power7 events available for perf
Quoted 9 lines · Will Deacon
Quoted 3 lines · Vince Weaver
libpfm4 uses the
CPU part :0xc09
line in/proc/cpuinfoon ARM, and that's enough for the processors PAPIThe CPU part you cite is actually A9-specific, so you probably want to probe each CPU specifically. Take a look at the cpuinfo parsing in OProfile (used by operf).
I meant we use the CPU part line to probe things. I just cut and pasted from a Cortex A9 I had handy as an example.
Quoted 7 lines
Quoted 5 lines
And speaking of ARM, I should be railing at them for breaking the ABI too, with their (understandable yet still ABI breaking) decision to remove BogoMIPS from
/proc/cpuinfo. That change will impact PAPI as well as various other programs I maintain that have the misfortune of parsing that file.Really? Why are you checking for that line at all?
Old programs.
PAPI dates back to the day when processor frequency was meaningful (and stable). In cases where MHz wasn't reported in cpuinfo (mostly MIPS and ARM) it tries to estimate it based on BogoMIPS. Not the sanest thing to do, but it worked well enough at the time. We recently fixed things so it should do something reasonable if BogoMIPS is missing, but if users wrote their code poorly they can get divide by zero errors if BogoMIPS suddenly goes missing from /proc/cpuinfo (and yes we have had a low but non-zero number of users report bugs of this type).
Other programs I have (like linux_logo and ll) are 15+ years old and simply print the BogoMIPS value for historical reasons. So they won't break if the value goes away but it's still sad to see it go.
Vince
Re: [PATCH v2 2/2] perf tools: Make Power7 events available for perf
In reply to Peter ZijlstraQuoted 14 lines · Peter Zijlstra
Quoted 8 lines · Vince Weaver
So something like they have on ARM?
vince@pandaboard:/sys/bus/event_source/devices$ ls -l lrwxrwxrwx 1 root root 0 Jul 8 21:57 ARMv7 Cortex-A9 -> ../../../devices/ARMv7 Cortex-A9 lrwxrwxrwx 1 root root 0 Jul 8 21:57 breakpoint -> ../../../devices/breakpoint lrwxrwxrwx 1 root root 0 Jul 8 21:57 software -> ../../../devices/software lrwxrwxrwx 1 root root 0 Jul 8 21:57 tracepoint -> ../../../devices/tracepointRight so what I remember of the ARM case is that their
/proc/cpuinfoisn't sufficient to identify their PMU. And they don't have a cpuid like instruction at all.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
For the cpu you can obviously just detect what processor you're on with cpuid or whatever, but it's a bit of a hack. And that really doesn't work for non-cpu PMUs.
why is it a hack to use cpuid?
I agree, for x86 cpuid is perfectly fine, as would
/proc/cpuinfobe, I suspect that just the model number is sufficient in most cases, even for uncore stuff.
What about things on PCI? Other strange buses?
As long as everything's in /sys then it should be _possible_ for userspace to work out what's what, but it's going to end up with a bunch of detection logic and heuristics in the library.
At which point you've just rewritten libpfm4.
cheers
Re: [PATCH v2 2/2] perf tools: Make Power7 events available for perf
Quoted 24 lines · Michael Ellerman
Quoted 14 lines · Peter Zijlstra
Quoted 8 lines · Vince Weaver
So something like they have on ARM?
vince@pandaboard:/sys/bus/event_source/devices$ ls -l lrwxrwxrwx 1 root root 0 Jul 8 21:57 ARMv7 Cortex-A9 -> ../../../devices/ARMv7 Cortex-A9 lrwxrwxrwx 1 root root 0 Jul 8 21:57 breakpoint -> ../../../devices/breakpoint lrwxrwxrwx 1 root root 0 Jul 8 21:57 software -> ../../../devices/software lrwxrwxrwx 1 root root 0 Jul 8 21:57 tracepoint -> ../../../devices/tracepointRight so what I remember of the ARM case is that their
/proc/cpuinfoisn't sufficient to identify their PMU. And they don't have a cpuid like instruction at all.Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
For the cpu you can obviously just detect what processor you're on with cpuid or whatever, but it's a bit of a hack. And that really doesn't work for non-cpu PMUs.
why is it a hack to use cpuid?
I agree, for x86 cpuid is perfectly fine, as would
/proc/cpuinfobe, I suspect that just the model number is sufficient in most cases, even for uncore stuff.
Quoted 7 lines
What about things on PCI? Other strange buses?
As long as everything's in /sys then it should be _possible_ for userspace to work out what's what, but it's going to end up with a bunch of detection logic and heuristics in the library.
At which point you've just rewritten libpfm4.
Exactly - PMUs enumerated in /sys should be self-identifying, it's a hardware topology after all ...
Anytime userspace is forced to look into /proc, or into weird places in /sys it's a FAIL really.
perf ABIs want to be self-identifying and self-sufficient, anytime userspace is forced to look elsewhere it adds another source of fragility.
And duplication with something that is 'already in /proc' is not a problem _at all_, these are computers that provide us different views into the same physical reality with dozens of different abstractions, so duplication of information is natural and _good_.
Thanks,
Ingo
Re: [PATCH v2 2/2] perf tools: Make Power7 events available for perf
Quoted 5 lines · Ingo Molnar
Exactly - PMUs enumerated in /sys should be self-identifying, it's a hardware topology after all ...
Anytime userspace is forced to look into /proc, or into weird places in /sys it's a FAIL really.
well on x86 you have to look at /proc/cpuinfo to get the vendor/family/model number. Should we add some specifier under sys? It's probably too late though as all userspace event libs will have to look at /proc/cpuinfo anyway to be backwards compatible.
Vince
Re: [PATCH v2 2/2] perf tools: Make Power7 events available for perf
Quoted 5 lines · Vince Weaver
Quoted 3 lines · Ingo Molnar
Exactly - PMUs enumerated in /sys should be self-identifying, it's a hardware topology after all ...
Quoted 7 lines
Quoted 2 lines
Anytime userspace is forced to look into /proc, or into weird places in /sys it's a FAIL really.
well on x86 you have to look at
/proc/cpuinfoto get the vendor/family/model number. Should we add some specifier under sys? It's probably too late though as all userspace event libs will have to look at/proc/cpuinfoanyway to be backwards compatible.
If it's a new library implementing a new feature then no I don't think it needs to be backward compatible. It's just a choice the library makes as to what extent it depends on new kernel features.
cheers
Re: [PATCH v2 2/2] perf tools: Make Power7 events available for perf
In reply to Runzhen WangQuoted 3 lines · Runzhen Wang
Power7 supports over 530 different perf events but only a small subset of these can be specified by name, for the remaining events, we must specify them by their raw code:
Hi Runzhen,
This is looking good. Sorry one last request below ...
Quoted 6 lines
arch/powerpc/perf/power7-events-list.h new file +0
-0@@ -0,0 +1,548 @@
..
arch/powerpc/perf/power7-events-list.h line 16
Quoted 6 lines
arch/powerpc/perf/power7-events-list.h new file +6
-0+ +EVENT(PM_IC_DEMAND_L2_BR_ALL, 0x4898) +EVENT(PM_GCT_UTIL_7_TO_10_SLOTS, 0x20a0) +EVENT(PM_PMC2_SAVED, 0x10022) +EVENT(PM_CMPLU_STALL_DFU, 0x2003c) +EVENT (PM_VSU0_16FLOP ,0xa0a4 )
Can you add a leading zero to all the events that don't have a PMC, so that they all line up vertically. It makes it a lot easier to scan the list visually.
eg:
EVENT(PM_IC_DEMAND_L2_BR_ALL, 0x04898) EVENT(PM_GCT_UTIL_7_TO_10_SLOTS, 0x020a0) EVENT(PM_PMC2_SAVED, 0x10022) EVENT(PM_CMPLU_STALL_DFU, 0x2003c) EVENT(PM_VSU0_16FLOP, 0x0a0a4)
cheers
PATCH v3 1/2 perf tools: fix a typo of a Power7 event name
In reply to Runzhen WangIn the Power7 PMU guide:
https://www.power.org/documentation/commonly-used-metrics-for-performance-analysis/PM_BRU_MPRED is referred to as PM_BR_MPRED.
It fixed the typo by changing the name of the event in kernel and documentation accordingly.
This patch changes the ABI, there are some reasons I think it's ok:
- It is relatively new interface, specific to the Power7 platform.
- No tools that we know of actually use this interface at this point (none are listed near the interface).
- Users of this interface (eg oprofile users migrating to perf) would be more used to the "PM_BR_MPRED" rather than "PM_BRU_MPRED".
- These are in the ABI/testing at this point rather than ABI/stable, so hoping we have some wiggle room.
--- .../testing/sysfs-bus-event_source-devices-events | 2 +- arch/powerpc/perf/power7-pmu.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
Documentation/ABI/testing/sysfs-bus-event_source-devices-events +1 -1
@@ -29,7 +29,7 @@ Description: Generic performance monitoring events What: /sys/devices/cpu/events/PM_1PLUS_PPC_CMPL /sys/devices/cpu/events/PM_BRU_FIN - /sys/devices/cpu/events/PM_BRU_MPRED + /sys/devices/cpu/events/PM_BR_MPRED /sys/devices/cpu/events/PM_CMPLU_STALL /sys/devices/cpu/events/PM_CMPLU_STALL_BRU /sys/devices/cpu/events/PM_CMPLU_STALL_DCACHE_MISS
arch/powerpc/perf/power7-pmu.c +6 -6
@@ -60,7 +60,7 @@#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 +#define PME_PM_BR_MPRED 0x400f6#define PME_PM_CMPLU_STALL_FXU 0x20014#define PME_PM_CMPLU_STALL_DIV 0x40014
@@ -349,7 +349,7 @@ static int power7_generic_events[] = { [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, + [PERF_COUNT_HW_BRANCH_MISSES] = PME_PM_BR_MPRED, };#define C (x) PERF_COUNT_HW_CACHE_##x
@@ -405,7 +405,7 @@ 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 ); +GENERIC_EVENT_ATTR (branch-misses,BR_MPRED );POWER_EVENT_ATTR (CYC ,CYC );POWER_EVENT_ATTR (GCT_NOSLOT_CYC ,GCT_NOSLOT_CYC );
@@ -414,7 +414,7 @@ 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 ); +POWER_EVENT_ATTR (BR_MPRED ,BR_MPRED );POWER_EVENT_ATTR (CMPLU_STALL_FXU ,CMPLU_STALL_FXU );POWER_EVENT_ATTR (CMPLU_STALL_DIV ,CMPLU_STALL_DIV );
@@ -449,7 +449,7 @@ static struct attribute *power7_events_attr[] = {GENERIC_EVENT_PTR (LD_REF_L1 ),GENERIC_EVENT_PTR (LD_MISS_L1 ),GENERIC_EVENT_PTR (BRU_FIN ), -GENERIC_EVENT_PTR (BRU_MPRED ), +GENERIC_EVENT_PTR (BR_MPRED ),POWER_EVENT_PTR (CYC ), POWER_EVENT_PTR(GCT_NOSLOT_CYC),
@@ -458,7 +458,7 @@ static struct attribute *power7_events_attr[] = {POWER_EVENT_PTR (LD_REF_L1 ),POWER_EVENT_PTR (LD_MISS_L1 ),POWER_EVENT_PTR (BRU_FIN ), -POWER_EVENT_PTR (BRU_MPRED ), +POWER_EVENT_PTR (BR_MPRED ),POWER_EVENT_PTR (CMPLU_STALL_FXU ), POWER_EVENT_PTR(CMPLU_STALL_DIV),
Signature · 1 line
1.7.9.5
Re: [PATCH v3 1/2] perf tools: fix a typo of a Power7 event name
Quoted 6 lines · Runzhen Wang
In the Power7 PMU guide:
https://www.power.org/documentation/commonly-used-metrics-for-performance-analysis/PM_BRU_MPREDis referred to asPM_BR_MPRED.It fixed the typo by changing the name of the event in kernel and documentation accordingly.
This patch fixes the typo by ...
Quoted 7 lines
This patch changes the ABI, there are some reasons I think it's ok:
- It is relatively new interface, specific to the Power7 platform.
- No tools that we know of actually use this interface at this point (none are listed near the interface).
Quoted 7 lines
- Users of this interface (eg oprofile users migrating to perf) would be more used to the "
PM_BR_MPRED" rather than "PM_BRU_MPRED".- These are in the ABI/testing at this point rather than ABI/stable, so hoping we have some wiggle room.
Signed-off-by Runzhen Wang <[email protected]>
cheers