Skip to contentSkip to conversation

powerpc/perf: Implement get_cpu_str()

PATCH In review Sukadev Bhattiprolu 2 participants 2 messages Aug 19, 2014 – Aug 20, 2014 perf events

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 powerpc/perf: Implement get_cpu_str()

powerpc/perf: Implement get_cpu_str()

With a file ~/.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

---
Changelog[v3]:
[Tobias Klauser]: Fix some changelog damage to patch.

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 +12 -0
index 6c1b8a7..306bf35 100644
@@ -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)
+{
+	char *bufp;
+
+	if (asprintf(&bufp, "%.8lx-core", mfspr(SPRN_PVR)) < 0)
+		bufp = NULL;
+
+	return bufp;
+}
Signature · 1 line
1.8.3.1
Acked-by on v3 1/1
#1 lore raw
Quoted 9 lines · Sukadev Bhattiprolu

powerpc/perf: Implement get_cpu_str()

With a file ~/.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
Quoted 6 lines

With this get_cpu_str(), On Powerpc, we can skip the --events-file option and run:

perf stat -e PM_CYC sleep 1

cheers