Skip to contentSkip to conversation

arm64: add OProfile support

PATCH In review Ding Tianhong 4 participants 7 messages Apr 26, 2014 – May 5, 2014 1 message not in the archive

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

PATCH 1/1 arm64: add OProfile support

Add OProfile support for arm64, using the perf backend, and failing back to generic timer based sampling if PMU interrupt is not supported.

I have test this patch on Cortex-A53 and Cortex-A57 motherboard, the OProfile could work well by PMU irq or arch timer irq.

---
 arch/arm64/Kconfig                  |   1 +
 arch/arm64/Makefile                 |   2 +
 arch/arm64/include/asm/stacktrace.h |   1 +
 arch/arm64/kernel/perf_event.c      |  13 ++++-
 arch/arm64/oprofile/Makefile        |  13 +++++
 arch/arm64/oprofile/common.c        | 106 ++++++++++++++++++++++++++++++++++++
 6 files changed, 135 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm64/oprofile/Makefile
 create mode 100644 arch/arm64/oprofile/common.c
arch/arm64/Kconfig +1 -0
index e6e4d37..f711445 100644
@@ -40,6 +40,7 @@ config ARM64
 	select HAVE_HW_BREAKPOINT if PERF_EVENTS
 	select HAVE_MEMBLOCK
 	select HAVE_PATA_PLATFORM
+	select HAVE_OPROFILE if (HAVE_PERF_EVENTS)
 	select HAVE_PERF_EVENTS
 	select HAVE_PERF_REGS
 	select HAVE_PERF_USER_STACK_DUMP
arch/arm64/Makefile +2 -0
index 2fceb71..6bb3d66 100644
@@ -48,6 +48,8 @@ core-$(CONFIG_XEN) += arch/arm64/xen/
 libs-y		:= arch/arm64/lib/ $(libs-y)
 libs-y		+= $(LIBGCC)
 
+drivers-$(CONFIG_OPROFILE)      += arch/arm64/oprofile/
+
 # Default target when executing plain make
 KBUILD_IMAGE	:= Image.gz
 KBUILD_DTBS	:= dtbs
arch/arm64/include/asm/stacktrace.h +1 -0
index 7318f6d..fec7e84 100644
@@ -19,6 +19,7 @@
 struct stackframe {
 	unsigned long fp;
 	unsigned long sp;
+	unsigned long lr;
 	unsigned long pc;
 };
 
arch/arm64/kernel/perf_event.c +12 -1
index baf5afb..a8fd1c1 100644
@@ -51,6 +51,15 @@ static DEFINE_PER_CPU(struct pmu_hw_events, cpu_hw_events);
 /* Set at runtime when we know what CPU type we are. */
 static struct arm_pmu *cpu_pmu;
 
+const char *perf_pmu_name(void)
+{
+	if (!cpu_pmu)
+		return NULL;
+
+	return cpu_pmu->name;
+}
+EXPORT_SYMBOL_GPL(perf_pmu_name);
+
 int
 armpmu_get_max_events(void)
 {
@@ -640,7 +649,7 @@ enum armv8_pmuv3_perf_types {
 	ARMV8_PMUV3_PERFCTR_L1_DCACHE_REFILL			= 0x03,
 	ARMV8_PMUV3_PERFCTR_L1_DCACHE_ACCESS			= 0x04,
 	ARMV8_PMUV3_PERFCTR_PC_BRANCH_MIS_PRED			= 0x10,
-	ARMV8_PMUV3_PERFCTR_CLOCK_CYCLES			= 0x11,
+	ARMV8_PMUV3_PERFCTR_CPU_CYCLES				= 0x11,
 	ARMV8_PMUV3_PERFCTR_PC_BRANCH_PRED			= 0x12,
 
 	/* At least one of the following is required. */
@@ -672,6 +681,8 @@ enum armv8_pmuv3_perf_types {
 	ARMV8_PMUV3_PERFCTR_BUS_ACCESS				= 0x19,
 	ARMV8_PMUV3_PERFCTR_MEM_ERROR				= 0x1A,
 	ARMV8_PMUV3_PERFCTR_BUS_CYCLES				= 0x1D,
+
+	ARMV8_PMUV3_PERFCTR_CLOCK_CYCLES			= 0XFF,
 };
 
 /* PMUv3 HW events mapping. */
arch/arm64/oprofile/Makefile new file +13 -0
new file mode 100644
index 0000000..b2215c6
@@ -0,0 +1,13 @@
+obj-$(CONFIG_OPROFILE) += oprofile.o
+
+DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \
+		oprof.o cpu_buffer.o buffer_sync.o \
+		event_buffer.o oprofile_files.o \
+		oprofilefs.o oprofile_stats.o \
+		timer_int.o )
+
+ifeq ($(CONFIG_HW_PERF_EVENTS),y)
+DRIVER_OBJS += $(addprefix ../../../drivers/oprofile/, oprofile_perf.o)
+endif
+
+oprofile-y				:= $(DRIVER_OBJS) common.o
arch/arm64/oprofile/common.c new file +106 -0

106 lines not on this page · raw message

Signature · 1 line
1.8.0
maintainer
#1 lore raw
Quoted 5 lines · Ding Tianhong

Add OProfile support for arm64, using the perf backend, and failing back to generic timer based sampling if PMU interrupt is not supported.

I have test this patch on Cortex-A53 and Cortex-A57 motherboard, the OProfile could work well by PMU irq or arch timer irq.

This came up before a few times and we also had an implementation but decided not to merge it. We should rather get the user space oprofile to use the perf kernel API.

That’s an old thread, it may have even made it into mainline oprofile but I haven’t followed the development:

http://marc.info/?l=oprofile-list&m=133002515616302&w=2

Catalin

#2 lore raw
Quoted 11 lines · Catalin Marinas
Quoted 5 lines · Ding Tianhong

Add OProfile support for arm64, using the perf backend, and failing back to generic timer based sampling if PMU interrupt is not supported.

I have test this patch on Cortex-A53 and Cortex-A57 motherboard, the OProfile could work well by PMU irq or arch timer irq.

This came up before a few times and we also had an implementation but decided not to merge it. We should rather get the user space oprofile to use the perf kernel API.

Quoted 7 lines

That’s an old thread, it may have even made it into mainline oprofile but I haven’t followed the development:

http://marc.info/?l=oprofile-list&m=133002515616302&w=2

Catalin

Ok, I will check it and then decide the next step, thanks for your feedback.

Regards
Ding

#3 lore raw
Quoted 12 lines · Ding Tianhong
Quoted 11 lines · Catalin Marinas
Quoted 5 lines · Ding Tianhong

Add OProfile support for arm64, using the perf backend, and failing back to generic timer based sampling if PMU interrupt is not supported.

I have test this patch on Cortex-A53 and Cortex-A57 motherboard, the OProfile could work well by PMU irq or arch timer irq.

This came up before a few times and we also had an implementation but decided not to merge it. We should rather get the user space oprofile to use the perf kernel API.

Quoted 7 lines
Quoted 7 lines

That’s an old thread, it may have even made it into mainline oprofile but I haven’t followed the development:

http://marc.info/?l=oprofile-list&m=133002515616302&w=2

Catalin

Hi Cadtalin:

Sorry I could not find the implementation that not to merge the orpfile support for aarch64 till now, and I still have questions that the existing code only support oprofile by arch timer event, but not PMU event, this patch only add HW PMU support for oprofile, it is more accurate and stable, can you give me more advise and appreciate for your help.

Regards
Ding

Quoted 5 lines

Ok, I will check it and then decide the next step, thanks for your feedback.

Regards
Ding

#4 lore raw
Quoted 21 lines · Ding Tianhong
Quoted 12 lines · Ding Tianhong
Quoted 11 lines · Catalin Marinas
Quoted 5 lines · Ding Tianhong

Add OProfile support for arm64, using the perf backend, and failing back to generic timer based sampling if PMU interrupt is not supported.

I have test this patch on Cortex-A53 and Cortex-A57 motherboard, the OProfile could work well by PMU irq or arch timer irq.

This came up before a few times and we also had an implementation but decided not to merge it. We should rather get the user space oprofile to use the perf kernel API.

Quoted 7 lines
Quoted 7 lines

That’s an old thread, it may have even made it into mainline oprofile but I haven’t followed the development:

http://marc.info/?l=oprofile-list&m=133002515616302&w=2

Catalin

Quoted 6 lines

Hi Cadtalin:

Sorry I could not find the implementation that not to merge the orpfile support for aarch64 till now, and I still have questions that the existing code only support oprofile by arch timer event, but not PMU event, this patch only add HW PMU support for oprofile, it is more accurate and stable, can you give me more advise and appreciate for your help.

Just use the operf tool, which is part of the oprofile project. It uses the perf syscall under the hood and doesn't need any kernel-side additions over perf.

Will

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 34 lines · William Cohen
Quoted 23 lines · Ding Tianhong
Quoted 12 lines · Ding Tianhong
Quoted 11 lines · Catalin Marinas
Quoted 5 lines · Ding Tianhong

Add OProfile support for arm64, using the perf backend, and failing back to generic timer based sampling if PMU interrupt is not supported.

I have test this patch on Cortex-A53 and Cortex-A57 motherboard, the OProfile could work well by PMU irq or arch timer irq.

This came up before a few times and we also had an implementation but decided not to merge it. We should rather get the user space oprofile to use the perf kernel API.

Quoted 7 lines
Quoted 7 lines

That’s an old thread, it may have even made it into mainline oprofile but I haven’t followed the development:

http://marc.info/?l=oprofile-list&m=133002515616302&w=2

Catalin

Hi Cadtalin:

Quoted 7 lines

Sorry I could not find the implementation that not to merge the orpfile support for aarch64 till now, and I still have questions that the existing code only support oprofile by arch timer event, but not PMU event, this patch only add HW PMU support for oprofile, it is more accurate and stable, can you give me more advise and appreciate for your help.

Regards
Ding

Hi Ding,

Quoted 8 lines

There is some basic support for arm64 in oprofile using the kernel's perf infrastructure for the Applied Micro X-Gene processor checked into the upstream oprofile git repository:

http://sourceforge.net/p/oprofile/oprofile/ci/34d0065a1a790fc2be05a5ef1d8b0bbf28b814fe/

It should be straight forward to adapt and extend this to work for A53 and A57 processors in libop/op_cpu_type.c. At the time I didn't have access to the cortex a57/a53 documentation so this was implemented for the the base ARMv8 PMUv3 events. The processor identification for Cortex a53 and a57 will also need to be added. to /libop/op_cpu_type.c. I don't currently have access to cortex a53 or a57 processors, so I don't know what the magic vendorid and cpuid values are. What is the output of "cat /proc/cpuinfo" for each of the aarch64 processors you are running oprofile on?

-Will

Hi Will:

Sorry for feedback so late, too busy these days. :)

Thanks for your message, you can add the the A53 and A57 to support arm-v8 for oprofile.

	A53	A57

Vendid 0x41 0x41
cpuid 0xD03 0xD07

-Ding

Quoted 24 lines
Quoted 9 lines
Quoted 6 lines

Ok, I will check it and then decide the next step, thanks for your feedback.

Regards
Ding

Quoted 11 lines

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available. Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
oprofile-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oprofile-list

.

#7 lore raw
Quoted 48 lines · Ding Tianhong
Quoted 34 lines · William Cohen
Quoted 23 lines · Ding Tianhong
Quoted 12 lines · Ding Tianhong
Quoted 11 lines · Catalin Marinas
Quoted 5 lines · Ding Tianhong

Add OProfile support for arm64, using the perf backend, and failing back to generic timer based sampling if PMU interrupt is not supported.

I have test this patch on Cortex-A53 and Cortex-A57 motherboard, the OProfile could work well by PMU irq or arch timer irq.

This came up before a few times and we also had an implementation but decided not to merge it. We should rather get the user space oprofile to use the perf kernel API.

Quoted 7 lines
Quoted 7 lines

That’s an old thread, it may have even made it into mainline oprofile but I haven’t followed the development:

http://marc.info/?l=oprofile-list&m=133002515616302&w=2

Catalin

Hi Cadtalin:

Quoted 7 lines

Sorry I could not find the implementation that not to merge the orpfile support for aarch64 till now, and I still have questions that the existing code only support oprofile by arch timer event, but not PMU event, this patch only add HW PMU support for oprofile, it is more accurate and stable, can you give me more advise and appreciate for your help.

Regards
Ding

Hi Ding,

Quoted 8 lines

There is some basic support for arm64 in oprofile using the kernel's perf infrastructure for the Applied Micro X-Gene processor checked into the upstream oprofile git repository:

http://sourceforge.net/p/oprofile/oprofile/ci/34d0065a1a790fc2be05a5ef1d8b0bbf28b814fe/

It should be straight forward to adapt and extend this to work for A53 and A57 processors in libop/op_cpu_type.c. At the time I didn't have access to the cortex a57/a53 documentation so this was implemented for the the base ARMv8 PMUv3 events. The processor identification for Cortex a53 and a57 will also need to be added. to /libop/op_cpu_type.c. I don't currently have access to cortex a53 or a57 processors, so I don't know what the magic vendorid and cpuid values are. What is the output of "cat /proc/cpuinfo" for each of the aarch64 processors you are running oprofile on?

-Will

Hi Will:

Sorry for feedback so late, too busy these days. :)

Quoted 7 lines

Thanks for your message, you can add the the A53 and A57 to support arm-v8 for oprofile.

	A53	A57

Vendid 0x41 0x41
cpuid 0xD03 0xD07

-Ding

Hi Ding,

Thanks very much for the IDs for Cortex A53 and Cortex A57.

-Will