Skip to contentSkip to conversation

MIPS: implementing hardware performance event support

PATCH Superseded Deng-Cheng Zhu 1 participant 1 message Apr 23, 2010

Subsystems (2)

v2 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 4/4 MIPS: implementing hardware performance event support

This patch is the HW perf event support. To enable this feature, we can not choose the SMTC kernel; Oprofile should be disabled; kernel performance events be selected. Then we can enable it in Kernel type menu.

Oprofile for MIPS platforms initializes irq at arch init time. Currently we do not change this logic to allow PMU reservation.

If a platform has EIC, we can use the irq base and perf counter irq offset defines for the interrupt controller in mipspmu_get_irq().

Besides generic hardware events and cache events, raw events are also supported by this patch. Please refer to processor core software user's manual and the comments for mipsxx_pmu_map_raw_event() for more details.

---
 arch/mips/Kconfig                    |    8 +
 arch/mips/include/asm/perf_event.h   |   28 ++
 arch/mips/kernel/Makefile            |    2 +
 arch/mips/kernel/perf_event.c        |  557 ++++++++++++++++++++++
 arch/mips/kernel/perf_event_mipsxx.c |  871 ++++++++++++++++++++++++++++++++++
 5 files changed, 1466 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/include/asm/perf_event.h
 create mode 100644 arch/mips/kernel/perf_event.c
 create mode 100644 arch/mips/kernel/perf_event_mipsxx.c
arch/mips/Kconfig +8 -0
index ebf2c79..ff1bb5d 100644
@@ -1857,6 +1857,14 @@ config NODES_SHIFT
 	default "6"
 	depends on NEED_MULTIPLE_NODES
 
+config HW_PERF_EVENTS
+	bool "Enable hardware performance counter support for perf events"
+	depends on PERF_EVENTS && !MIPS_MT_SMTC && OPROFILE=n && CPU_MIPS32
+	default y
+	help
+	  Enable hardware performance counter support for perf events. If
+	  disabled, perf events will use software events only.
+
 source "mm/Kconfig"
 
 config SMP
arch/mips/include/asm/perf_event.h new file +28 -0
new file mode 100644
index 0000000..bcf54bc
@@ -0,0 +1,28 @@
+/*
+ * linux/arch/mips/include/asm/perf_event.h
+ *
+ * Copyright (C) 2010 MIPS Technologies, Inc. Deng-Cheng Zhu
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef __MIPS_PERF_EVENT_H__
+#define __MIPS_PERF_EVENT_H__
+
+extern int (*perf_irq)(void);
+
+/*
+ * MIPS performance counters do not raise NMI upon overflow, a regular
+ * interrupt will be signaled. Hence we can do the pending perf event
+ * work at the tail of the irq handler.
+ */
+static inline void
+set_perf_event_pending(void)
+{
+}
+
+#endif /* __MIPS_PERF_EVENT_H__ */
+
arch/mips/kernel/Makefile +2 -0
index 7a6ac50..c934ab7 100644
@@ -101,6 +101,8 @@ obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT)	+= 8250-platform.o
 
 obj-$(CONFIG_MIPS_CPUFREQ)	+= cpufreq/
 
+obj-$(CONFIG_HW_PERF_EVENTS)	+= perf_event.o
+
 EXTRA_CFLAGS += -Werror
 
 CPPFLAGS_vmlinux.lds		:= $(KBUILD_CFLAGS)
arch/mips/kernel/perf_event.c new file +557 -0

557 lines not on this page · raw message

arch/mips/kernel/perf_event_mipsxx.c new file +871 -0

871 lines not on this page · raw message

Signature · 1 line
1.7.0.4