Skip to contentSkip to conversation

ARC: Add perf support

PATCH In review Mischa Jonker 2 participants 2 messages Aug 28, 2013 – Aug 29, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARC: Add perf support

This adds basic perf support for ARC. Most PERF_COUNT_HW* events are supported now. Cache events and callchains are not (yet).

---
 arch/arc/boot/dts/angel4.dts      |    4 +
 arch/arc/include/asm/perf_event.h |  190 +++++++++++++++++++++-
 arch/arc/kernel/Makefile          |    1 +
 arch/arc/kernel/perf_event.c      |  323 +++++++++++++++++++++++++++++++++++++
 4 files changed, 517 insertions(+), 1 deletion(-)
 create mode 100644 arch/arc/kernel/perf_event.c
arch/arc/boot/dts/angel4.dts +4 -0
index 4fb2d6f..fd34b5d 100644
@@ -67,5 +67,9 @@
 				reg = <1>;
 			};
 		};
+
+		arcpmu0: pmu {
+			compatible = "snps,arc_pmu";
+		};
 	};
 };
arch/arc/include/asm/perf_event.h +189 -1

198 lines not on this page · raw message

arch/arc/kernel/Makefile +1 -0
index c242ef0..8004b4f 100644
@@ -19,6 +19,7 @@ obj-$(CONFIG_KPROBES)      		+= kprobes.o
 obj-$(CONFIG_ARC_MISALIGN_ACCESS) 	+= unaligned.o
 obj-$(CONFIG_KGDB)			+= kgdb.o
 obj-$(CONFIG_ARC_METAWARE_HLINK)	+= arc_hostlink.o
+obj-$(CONFIG_PERF_EVENTS)		+= perf_event.o
 
 obj-$(CONFIG_ARC_FPU_SAVE_RESTORE)	+= fpu.o
 CFLAGS_fpu.o   += -mdpfp
arch/arc/kernel/perf_event.c new file +323 -0

323 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 18 lines · Mischa Jonker
arch/arc/include/asm/perf_event.h +18 -0
+/* The "generalized" performance events seem to really be a copy
+   of the available events on x86 processors; the mapping to ARC
+   events is not always possible 1-to-1. Fortunately, there doesn't
+   seem to be an exact definition for these events, so we can cheat
+   a bit where necessary */
+static const char * const arc_pmu_ev_hw_map[] = {
+	/* cycles not in halted state */
+	[PERF_COUNT_HW_CPU_CYCLES] = "crun",
+	/* reference cycles not in halted state; also "crun" as we don't
+	   do Dynamic Voltage/Frequency Scaling (yet) */
+	[PERF_COUNT_HW_REF_CPU_CYCLES] = "crun",
+	/* Unclear what this means, Intel uses 0x013c, which according to
+	   their datasheet means "unhalted reference cycles". Don't ask
+	   me what the difference is with PERF_COUNT_HW_REF_CPU_CYCLES */
+	[PERF_COUNT_HW_BUS_CYCLES] = "crun",
+	[PERF_COUNT_HW_INSTRUCTIONS] = "iall",
+	[PERF_COUNT_HW_BRANCH_MISSES] = "bpfail",
+	[PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = "ijmp",

arch/arc/include/asm/perf_event.h line 86

Quoted 10 lines
arch/arc/include/asm/perf_event.h +10 -0
+	/* ARC can either measure stalls per pipeline stage, or all stalls
+	   combined; for now we assign all stalls to STALLED_CYCLES_BACKEND
+	   and all pipeline flushes (e.g. caused by mispredicts, etc.) to
+	   STALLED_CYCLES_FRONTEND.
+
+	   We could start multiple performance counters and combine everything
+	   afterwards, but that makes it complicated, and users can always
+	   use PERF_TYPE_RAW.
+
+	   Note that I$ cache misses aren't counted by either of the two! */

Haven't really looked at the patch in detail, just noticed the following nit, please use the customary (multi-line) comment style:

/*
* Comment .....
* ...... goes here.
*/

specified in Documentation/CodingStyle.

Thanks,

Ingo