Skip to contentSkip to conversation

2.6.16-rc1 perfmon2 patch for review

PATCH In review Stephane Eranian 1 participant 1 message Jan 20, 2006 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 6/6 2.6.16-rc1 perfmon2 patch for review

Hello,

This a split version of the perfmon. Each chunk was split to fit the constraints of lkml on message size. the patch is relative to 2.6.16-rc1.

Chunks [1-3] represent the common part of the perfmon2 patch. This code is common to all supported architectures.

Chunk 4 represents the i386 specific perfmon2 patch. It implements the arch-specific routines for 32-bit P4/Xeon, Pentiun M/P6. It also includes the 32-bit version of the PEBS sampling format.

Chunk 5 represents the x86_64 specific perfmon2 patch. It implements the arch-specific routines for 64-bit Opteron, EM64T. It also includes the 64-bit version of the PEBS sampling format.

Chunk 6 represents the preliminary powerpc specific perfmon2 patch. It implements the arch-specific routines for the 64-bit Power 4.

The Itanium Processors (IA-64) specific patch is not posted because it is too big to be split into smaller chunks. The size comes from the fact that it needs to remove the older implementation. If you are interested, the patch can be downloaded from our project web site at:

http://www.sf.net/projects/perfmon2

The MIPS support is not against the same kernel tree. To avoid confusion, we did not post it directly to lkml.

The patch is submitted for review by platform maintainers.

Thanks.

arch/powerpc/Kconfig +12 -0
diff -urN linux-2.6.16-rc1.orig/arch/powerpc/Kconfig linux-2.6.16-rc1/arch/powerpc/Kconfig
@@ -262,6 +262,18 @@
 	bool
 	depends on 4xx || 8xx || E200
 	default y
+
+menu "Hardware Performance Monitoring support"
+config PERFMON
+	bool "Perfmon2 performance monitoring interface"
+	default y
+	help
+	include the perfmon2 performance monitoring interface
+	in the kernel.  See <http://www.hpl.hp.com/research/linux/perfmon> for
+	more details.  If you're unsure, say Y.
+source "arch/powerpc/perfmon/Kconfig"
+endmenu
+
 endmenu
 
 source "init/Kconfig"
arch/powerpc/Makefile +1 -0
diff -urN linux-2.6.16-rc1.orig/arch/powerpc/Makefile linux-2.6.16-rc1/arch/powerpc/Makefile
@@ -132,6 +132,7 @@
 core-$(CONFIG_PPC32)		+= arch/ppc/kernel/
 core-$(CONFIG_MATH_EMULATION)	+= arch/ppc/math-emu/
 core-$(CONFIG_XMON)		+= arch/powerpc/xmon/
+core-$(CONFIG_PERFMON)		+= arch/powerpc/perfmon/
 core-$(CONFIG_APUS)		+= arch/ppc/amiga/
 drivers-$(CONFIG_8xx)		+= arch/ppc/8xx_io/
 drivers-$(CONFIG_4xx)		+= arch/ppc/4xx_io/
arch/powerpc/kernel/entry_64.S +3 -0
diff -urN linux-2.6.16-rc1.orig/arch/powerpc/kernel/entry_64.S linux-2.6.16-rc1/arch/powerpc/kernel/entry_64.S
@@ -620,6 +620,9 @@
 	b	.ret_from_except_lite
 
 1:	bl	.save_nvgprs
+#ifdef CONFIG_PERFMON
+	bl	.ppc64_pfm_handle_work
+#endif /* CONFIG_PERFMON */
 	li	r3,0
 	addi	r4,r1,STACK_FRAME_OVERHEAD
 	bl	.do_signal
arch/powerpc/kernel/process.c +5 -0
diff -urN linux-2.6.16-rc1.orig/arch/powerpc/kernel/process.c linux-2.6.16-rc1/arch/powerpc/kernel/process.c
@@ -38,6 +38,7 @@
 #include <linux/hardirq.h>
 #include <linux/utsname.h>
 #include <linux/kprobes.h>
+#include <linux/perfmon.h>
 
 #include <asm/pgtable.h>
 #include <asm/uaccess.h>
@@ -330,7 +331,9 @@
 #endif
 
 	local_irq_save(flags);
+	pfm_ctxswout(prev);
 	last = _switch(old_thread, new_thread);
+	pfm_ctxswin(current);
 
 	local_irq_restore(flags);
 
@@ -459,6 +462,7 @@
 {
 	kprobe_flush_task(current);
 	discard_lazy_cpu_state();
+	pfm_exit_thread(current);
 }
 
 void flush_thread(void)
@@ -570,6 +574,7 @@
 	kregs->nip = (unsigned long)ret_from_fork;
 	p->thread.last_syscall = -1;
 #endif
+	pfm_copy_thread(p, childregs);
 
 	return 0;
 }
arch/powerpc/kernel/systbl.S +12 -0
diff -urN linux-2.6.16-rc1.orig/arch/powerpc/kernel/systbl.S linux-2.6.16-rc1/arch/powerpc/kernel/systbl.S
@@ -321,3 +321,15 @@
 SYSCALL(inotify_rm_watch)
 SYSCALL(spu_run)
 SYSCALL(spu_create)
+SYSCALL(pfm_create_context)
+SYSCALL(pfm_write_pmcs)
+SYSCALL(pfm_write_pmds)
+SYSCALL(pfm_read_pmds)
+SYSCALL(pfm_load_context)
+SYSCALL(pfm_start)
+SYSCALL(pfm_stop)
+SYSCALL(pfm_restart)
+SYSCALL(pfm_create_evtsets)
+SYSCALL(pfm_getinfo_evtsets)
+SYSCALL(pfm_delete_evtsets)
+SYSCALL(pfm_unload_context)
arch/powerpc/perfmon/Kconfig +7 -0
diff -urN linux-2.6.16-rc1.orig/arch/powerpc/perfmon/Kconfig linux-2.6.16-rc1/arch/powerpc/perfmon/Kconfig
@@ -0,0 +1,7 @@
+config PERFMON_POWER5
+	tristate "Support for Power5 hardware performance counters"
+	depends on PERFMON
+	default m
+	help
+	Enables support for the Power 5 hardware performance counters
+	If unsure, say M.
arch/powerpc/perfmon/Makefile +2 -0
diff -urN linux-2.6.16-rc1.orig/arch/powerpc/perfmon/Makefile linux-2.6.16-rc1/arch/powerpc/perfmon/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_PERFMON)		+= perfmon.o
+obj-$(CONFIG_PERFMON_POWER5)	+= perfmon_power5.o
arch/powerpc/perfmon/perfmon.c +354 -0

354 lines not on this page · raw message

arch/powerpc/perfmon/perfmon_power5.c +77 -0

77 lines not on this page · raw message

include/asm-powerpc/perfmon.h +258 -0

258 lines not on this page · raw message

include/asm-powerpc/processor.h +1 -0
diff -urN linux-2.6.16-rc1.orig/include/asm-powerpc/processor.h linux-2.6.16-rc1/include/asm-powerpc/processor.h
@@ -193,6 +193,7 @@
 	unsigned long	spefscr;	/* SPE & eFP status */
 	int		used_spe;	/* set if process has used spe */
 #endif /* CONFIG_SPE */
+	void *pfm_context;
 };
 
 #define ARCH_MIN_TASKALIGN 16
include/asm-powerpc/unistd.h +13 -1
diff -urN linux-2.6.16-rc1.orig/include/asm-powerpc/unistd.h linux-2.6.16-rc1/include/asm-powerpc/unistd.h
@@ -298,8 +298,20 @@
 #define __NR_inotify_rm_watch	277
 #define __NR_spu_run		278
 #define __NR_spu_create		279
+#define __NR_pfm_create_context	280
+#define __NR_pfm_write_pmcs	(__NR_pfm_create_context+1)
+#define __NR_pfm_write_pmds	(__NR_pfm_create_context+2)
+#define __NR_pfm_read_pmds	(__NR_pfm_create_context+3)
+#define __NR_pfm_load_context	(__NR_pfm_create_context+4)
+#define __NR_pfm_start		(__NR_pfm_create_context+5)
+#define __NR_pfm_stop		(__NR_pfm_create_context+6)
+#define __NR_pfm_restart	(__NR_pfm_create_context+7)
+#define __NR_pfm_create_evtsets	(__NR_pfm_create_context+8)
+#define __NR_pfm_getinfo_evtsets (__NR_pfm_create_context+9)
+#define __NR_pfm_delete_evtsets (__NR_pfm_create_context+10)
+#define __NR_pfm_unload_context	(__NR_pfm_create_context+11)
 
-#define __NR_syscalls		280
+#define __NR_syscalls		291
 
 #ifdef __KERNEL__
 #define __NR__exit __NR_exit