powerpc/perf: Implement get_cpu_str()
PATCH 1/1 powerpc/perf: Implement get_cpu_str()
powerpc/perf: Implement get_cpu_str()
With a file like ~/.cache/pmu-events/004d0100-core.json describing Power8 PMU events, we would need to run:
perf stat \ --events-file ~/.cache/pmu-events/004d0100-core.json \ -e PM_CYC sleep 1
With this get_cpu_str(), on Powerpc, we can skip the --events-file option and run:
perf stat -e PM_CYC sleep 1
---
Note: This patch is based on Andi Kleen's recent patchset
https://lkml.org/lkml/2014/7/30/693
Changelog[v2]:
[Michael Ellerman]: Use PVR instead of AUXV variables
tools/perf/arch/powerpc/util/header.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
tools/perf/arch/powerpc/util/header.c +5 -0
@@ -6,6 +6,7 @@#include "../../util/header.h" #include "../../util/util.h" +#include "../../util/jevents.h" #define mfspr (rn) ({unsigned long rval; \ asm volatile("mfspr %0," __stringify(rn) \
@@ -32,3 +33,14 @@ get_cpuid(char *buffer, size_t sz) }return -1 ; } + +char * +get_cpu_str (void ) +{
Changelog[v2]:
[Michael Ellerman]: Use PVR instead of AUXV variables
+ char *bufp;
+
+ if (asprintf(&bufp, "%.8lx-core", mfspr(SPRN_PVR)) < 0)
+ bufp = NULL;
+
+ return bufp;
+}
Signature · 1 line
1.8.3.1
Quoted 46 lines · Sukadev Bhattiprolu
powerpc/perf: Implement
get_cpu_str()With a file like
~/.cache/pmu-events/004d0100-core.jsondescribing Power8 PMU events, we would need to run:perf stat \ --events-file ~/.cache/pmu-events/004d0100-core.json \ -e PM_CYC sleep 1With this
get_cpu_str(), on Powerpc, we can skip the --events-file option and run:perf stat -e
PM_CYCsleep 1Signed-off-by Sukadev Bhattiprolu <[email protected]>---
Note: This patch is based on Andi Kleen's recent patchsethttps://lkml.org/lkml/2014/7/30/693Changelog[v2]:
[Michael Ellerman]: Use PVR instead of AUXV variablestools/perf/arch/powerpc/util/header.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)tools/perf/arch/powerpc/util/header.c +5
-0@@ -6,6 +6,7 @@#include "../../util/header.h" #include "../../util/util.h" +#include "../../util/jevents.h" #define mfspr (rn) ({unsigned long rval; \ asm volatile("mfspr %0," __stringify(rn) \@@ -32,3 +33,14 @@ get_cpuid(char *buffer, size_t sz) }return -1 ; } + +char * +get_cpu_str (void ) +{
Quoted 2 lines
Changelog[v2]:
[Michael Ellerman]: Use PVR instead of AUXV variables
This was probably not intended to be here and the patch does not apply due to these lines.
Quoted 17 lines
tools/perf/arch/powerpc/util/header.c +7
-0+char *bufp; + +if (asprintf (&bufp,"%.8lx-core" ,mfspr (SPRN_PVR )) <0 ) + bufp =NULL ; + +return bufp; +}Signature · 7 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Tobias Klauser [[email protected]] wrote:
| > diff --git a/tools/perf/arch/powerpc/util/header.c b/tools/perf/arch/powerpc/util/header.c
| > index 6c1b8a7..1bb400e8 100644
| > --- a/tools/perf/arch/powerpc/util/header.c
| > +++ b/tools/perf/arch/powerpc/util/header.c
| > @@ -6,6 +6,7 @@
| >
| > #include "../../util/header.h"
| > #include "../../util/util.h"
| > +#include "../../util/jevents.h"
| >
| > #define mfspr(rn) ({unsigned long rval; \
| > asm volatile("mfspr %0," __stringify(rn) \
| > @@ -32,3 +33,14 @@ get_cpuid(char *buffer, size_t sz)
| > }
| > return -1;
| > }
| > +
| > +char *
| > +get_cpu_str(void)
| > +{
| > Changelog[v2]:
| > [Michael Ellerman]: Use PVR instead of AUXV variables
|
| This was probably not intended to be here and the patch does not apply
| due to these lines.Sorry about that. Will resend.
Sukadev