Skip to contentSkip to conversation

2.6.15-rc1-git6 perfmon new code base package available

PATCH New Stephane Eranian 2 participants 6 messages Nov 18, 2005 – Nov 23, 2005 1 message not in the archive PowerPC

lore
Share & tools
lore
#0 lore raw

Hello,

I have released a new version of the perfmon base package. This release is relative to 2.6.15-rc1-git6. We are now following Linus' GIT snapshots rather than Andrew's -mm tree.

I have also updated the library, libpfm-3.2, to match the kernel level changes.

Kernel-package features:
------------------------

- major update to the EM64T support. It is now up to the level of the 32-bit P4/Xeon support

- support for EM64T PEBS sampling

- EM64T/P4/Xeon ESCR.active_thread now under user's control

- fixed broken PMU context switch code for UP kernels

- implemented PFM_REGFL_NO_EMUL64 (disable counter 64-bit virtualization) flag on EM64T/P4/Xeon to support PEBS sampling.

- restored restriction which mandates that a PMD cannot be read before the user has declared it is using it via pfm_write_pmcs() or reg_smpl_pmds[]. This is in official 2.6 but got dropped by mistake in the new code base.

- added pt_regs as an argument to the sampling format module handler callback

- lots of cleanups and bug fixes

The patch has been tested on Pentium M, Xeon 32-bit, AMD X86-64, Xeon 64-bit and on Itanium2. The code is known to compile for PPC and MIPS but I could not test it.

For MIPS, the patch is still relative to 2.6.14-rc2 from www.linux-mips.org GIT tree as they still maintain a separate tree. To simplify the setup, the entire MIPS patch is included in the -mips file. You do not need to apply the common patch.

For libpfm-3.2, the P4/Xeon (32 and 64 bits) PEBS examples have been updated. Make sure you look at them as there were some important changes on how registers must be setup, especially with the PFM_REGFL_NO_EMUL64 flag and the active_thread settings. PEBS does not work when HyperThreading is enabled. Among the other changes, I have added a few more events for P6 and AMD X86-64. If you want full coverage, please contribute!

Somehow the project's summary page at SourceForge appears broken. Until I find out what is wrong, you can grab the packages directly from the download page at:

	http://sf.net/project/showfiles.php?group_id4822

You must download:
- 2.6.15-rc1-git6
- libpfm-3.2-051118

Enjoy,

Signature · 1 line
-Stephane

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

#2 lore raw

Re: [PATCH 3/5] i386 perfmon2 code for review

Hello,

For some reasons, the original annoucement from 11/18 for this release never made it to this list.

You can download the latest packages from:

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

You need to grab:

	2.6.15-rc1-git6 (kernel code)
	libpfm-3.2-051118 (user library)

For convenience, I am also posting the patch directly to the list. At this point, the patch is for review. Please cc me on your replies because due to the volume of traffic I am not a member of the list.

I have split the patch into 5 parts. The first part is needed on each platform (common code). All the others are specific to a processor architecture. There is an exception for x86-64 which needs the i386 portion due to cross use of header files. The patch is relative to 2.6.15-rc1-git6.

thanks.

This E-mail contains Part 2: i386 code (P6, Pentium M, P4/Xeon 32bits)

arch/i386/Kconfig +16 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/i386/Kconfig linux-2.6.15-rc1-git6/arch/i386/Kconfig
@@ -684,8 +684,24 @@
 	depends on HIGHMEM
 	help
 	  Generate crash dump after being started by kexec.
+
+menu "Hardware Performance Monitoring support"
+
+config PERFMON
+  	bool "Perfmon2 performance monitoring interface"
+	select X86_LOCAL_APIC
+	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/i386/perfmon/Kconfig"
 endmenu
 
+endmenu
+
+
 
 menu "Power management options (ACPI, APM)"
 	depends on !X86_VOYAGER
arch/i386/Makefile +1 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/i386/Makefile linux-2.6.15-rc1-git6/arch/i386/Makefile
@@ -87,6 +87,7 @@
 head-y := arch/i386/kernel/head.o arch/i386/kernel/init_task.o
 
 libs-y 					+= arch/i386/lib/
+core-$(CONFIG_PERFMON)			+= arch/i386/perfmon/
 core-y					+= arch/i386/kernel/ \
 					   arch/i386/mm/ \
 					   arch/i386/$(mcore-y)/ \
arch/i386/kernel/apic.c +3 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/i386/kernel/apic.c linux-2.6.15-rc1-git6/arch/i386/kernel/apic.c
@@ -26,6 +26,7 @@
 #include <linux/kernel_stat.h>
 #include <linux/sysdev.h>
 #include <linux/cpu.h>
+#include <linux/perfmon.h>
 
 #include <asm/atomic.h>
 #include <asm/smp.h>
@@ -1161,6 +1162,8 @@
 #endif
 	}
 
+	pfm_handle_switch_timeout();
+
 	/*
 	 * We take the 'long' return path, and there every subsystem
 	 * grabs the apropriate locks (kernel lock/ irq lock).
arch/i386/kernel/entry.S +10 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/i386/kernel/entry.S linux-2.6.15-rc1-git6/arch/i386/kernel/entry.S
@@ -430,6 +430,16 @@
 /* The include is where all of the SMP etc. interrupts come from */
 #include "entry_arch.h"
 
+#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_PERFMON)
+ENTRY(pmu_interrupt)
+  	pushl $LOCAL_PERFMON_VECTOR-256
+  	SAVE_ALL
+  	pushl %esp
+ 	call pfm_intr_handler
+  	addl $4, %esp
+  	jmp ret_from_intr
+#endif
+
 ENTRY(divide_error)
 	pushl $0			# no error code
 	pushl $do_divide_error
arch/i386/kernel/i8259.c +4 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/i386/kernel/i8259.c linux-2.6.15-rc1-git6/arch/i386/kernel/i8259.c
@@ -11,6 +11,7 @@
 #include <linux/kernel_stat.h>
 #include <linux/sysdev.h>
 #include <linux/bitops.h>
+#include <linux/perfmon.h>
 
 #include <asm/8253pit.h>
 #include <asm/atomic.h>
@@ -403,6 +404,7 @@
 	/* all the set up before the call gates are initialised */
 	pre_intr_init_hook();
 
+
 	/*
 	 * Cover the whole vector space, no vector can escape
 	 * us. (some of these will be overridden and become
@@ -427,6 +429,8 @@
 	 */
 	setup_pit_timer();
 
+ 	pfm_vector_init();
+
 	/*
 	 * External FPU? Set up irq13 if so, for
 	 * original braindamaged IBM FERR coupling.
arch/i386/kernel/process.c +6 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/i386/kernel/process.c linux-2.6.15-rc1-git6/arch/i386/kernel/process.c
@@ -33,6 +33,7 @@
 #include <linux/delay.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
+#include <linux/perfmon.h>
 #include <linux/mc146818rtc.h>
 #include <linux/module.h>
 #include <linux/kallsyms.h>
@@ -387,6 +388,7 @@
 		tss->io_bitmap_base = INVALID_IO_BITMAP_OFFSET;
 		put_cpu();
 	}
+	pfm_exit_thread(tsk);
 }
 
 void flush_thread(void)
@@ -466,6 +468,8 @@
 	savesegment(fs,p->thread.fs);
 	savesegment(gs,p->thread.gs);
 
+ 	pfm_copy_thread(p, childregs);
+
 	tsk = current;
 	if (unlikely(NULL != tsk->thread.io_bitmap_ptr)) {
 		p->thread.io_bitmap_ptr = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL);
@@ -727,6 +731,8 @@
 
 	disable_tsc(prev_p, next_p);
 
+ 	pfm_ctxswin(next_p);
+
 	return prev_p;
 }
 
arch/i386/kernel/signal.c +6 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/i386/kernel/signal.c linux-2.6.15-rc1-git6/arch/i386/kernel/signal.c
@@ -21,6 +21,7 @@
 #include <linux/suspend.h>
 #include <linux/ptrace.h>
 #include <linux/elf.h>
+#include <linux/perfmon.h>
 #include <asm/processor.h>
 #include <asm/ucontext.h>
 #include <asm/uaccess.h>
@@ -667,6 +668,11 @@
 		regs->eflags |= TF_MASK;
 		clear_thread_flag(TIF_SINGLESTEP);
 	}
+	/*
+	 * must be done before signals
+	 */
+	pfm_handle_work();
+
 	/* deal with pending signal delivery */
 	if (thread_info_flags & _TIF_SIGPENDING)
 		do_signal(regs,oldset);
arch/i386/kernel/syscall_table.S +12 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/i386/kernel/syscall_table.S linux-2.6.15-rc1-git6/arch/i386/kernel/syscall_table.S
@@ -294,3 +294,15 @@
 	.long sys_inotify_init
 	.long sys_inotify_add_watch
 	.long sys_inotify_rm_watch
+  	.long sys_pfm_create_context
+   	.long sys_pfm_write_pmcs	/* 295 */
+   	.long sys_pfm_write_pmds
+   	.long sys_pfm_read_pmds
+   	.long sys_pfm_load_context
+   	.long sys_pfm_start
+   	.long sys_pfm_stop		/* 300 */
+   	.long sys_pfm_restart
+   	.long sys_pfm_create_evtsets
+   	.long sys_pfm_getinfo_evtsets
+   	.long sys_pfm_delete_evtsets
+	.long sys_pfm_unload_context	/* 305 */
arch/i386/perfmon/Kconfig +24 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/i386/perfmon/Kconfig linux-2.6.15-rc1-git6/arch/i386/perfmon/Kconfig
@@ -0,0 +1,24 @@
+config PERFMON_P6
+	tristate "Support for P6/Pentium M hardware performance counters"
+	depends on PERFMON
+	default m
+	help
+	Enables support for the P6/Pentium M style hardware performance counters"
+	If unsure, say M.
+
+config PERFMON_P4
+	tristate "Support for 32-bit P4/Xeon hardware performance counters"
+	depends on PERFMON
+	default m
+	help
+	Enables support for the 32-bit P4/Xeon style hardware performance counters"
+	If unsure, say M.
+
+config PERFMON_P4_PEBS
+         tristate "Support for Intel P4 PEBS sampling format"
+	 depends on PERFMON_P4
+         default m
+         help
+         Enables support for Precise Event-Based Sampling (PEBS) on the Intel P4
+	 processors which support it.  Does not work with P6 processors.
+         If unsure, say m.
arch/i386/perfmon/Makefile +8 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/i386/perfmon/Makefile linux-2.6.15-rc1-git6/arch/i386/perfmon/Makefile
@@ -0,0 +1,8 @@
+#
+# Copyright (c) 2005 Hewlett-Packard Development Company, L.P.
+# Contributed by Stephane Eranian <[email protected]>
+#
+obj-$(CONFIG_PERFMON)		+= perfmon.o
+obj-$(CONFIG_PERFMON_P6)	+= perfmon_p6.o
+obj-$(CONFIG_PERFMON_P4)	+= perfmon_p4.o
+obj-$(CONFIG_PERFMON_P4_PEBS)	+= perfmon_p4_pebs_smpl.o
arch/i386/perfmon/perfmon.c +860 -0

860 lines not on this page · raw message

arch/i386/perfmon/perfmon_p4.c +442 -0

442 lines not on this page · raw message

arch/i386/perfmon/perfmon_p4_pebs_smpl.c +216 -0

216 lines not on this page · raw message

arch/i386/perfmon/perfmon_p6.c +176 -0

176 lines not on this page · raw message

include/asm-i386/mach-default/irq_vectors.h +2 -1
diff -urN linux-2.6.15-rc1-git6.orig/include/asm-i386/mach-default/irq_vectors.h linux-2.6.15-rc1-git6/include/asm-i386/mach-default/irq_vectors.h
@@ -56,6 +56,7 @@
  * sources per level' errata.
  */
 #define LOCAL_TIMER_VECTOR	0xef
+#define LOCAL_PERFMON_VECTOR	0xee
 
 /*
  * First APIC vector available to drivers: (vectors 0x30-0xee)
@@ -63,7 +64,7 @@
  * levels. (0x80 is the syscall vector)
  */
 #define FIRST_DEVICE_VECTOR	0x31
-#define FIRST_SYSTEM_VECTOR	0xef
+#define FIRST_SYSTEM_VECTOR	0xee
 
 #define TIMER_IRQ 0
 
include/asm-i386/perfmon.h +256 -0

256 lines not on this page · raw message

include/asm-i386/perfmon_p4_pebs_smpl.h +96 -0

96 lines not on this page · raw message

include/asm-i386/processor.h +2 -0
diff -urN linux-2.6.15-rc1-git6.orig/include/asm-i386/processor.h linux-2.6.15-rc1-git6/include/asm-i386/processor.h
@@ -423,6 +423,7 @@
 	 */
 	unsigned long io_bitmap_max;
 	struct thread_struct *io_bitmap_owner;
+
 	/*
 	 * pads the TSS to be cacheline-aligned (size is 0x100)
 	 */
@@ -460,6 +461,7 @@
  	unsigned long	iopl;
 /* max allowed port in the bitmap, in bytes: */
 	unsigned long	io_bitmap_max;
+ 	void *pfm_context;
 };
 
 #define INIT_THREAD  {							\
include/asm-i386/system.h +1 -0
diff -urN linux-2.6.15-rc1-git6.orig/include/asm-i386/system.h linux-2.6.15-rc1-git6/include/asm-i386/system.h
@@ -14,6 +14,7 @@
 
 #define switch_to(prev,next,last) do {					\
 	unsigned long esi,edi;						\
+	pfm_ctxswout(prev);						\
 	asm volatile("pushl %%ebp\n\t"					\
 		     "movl %%esp,%0\n\t"	/* save ESP */		\
 		     "movl %5,%%esp\n\t"	/* restore ESP */	\
include/asm-i386/unistd.h +14 -2
diff -urN linux-2.6.15-rc1-git6.orig/include/asm-i386/unistd.h linux-2.6.15-rc1-git6/include/asm-i386/unistd.h
@@ -299,8 +299,20 @@
 #define __NR_inotify_init	291
 #define __NR_inotify_add_watch	292
 #define __NR_inotify_rm_watch	293
-
-#define NR_syscalls 294
+#define __NR_pfm_create_context	294
+#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 305
 
 /*
  * user-visible error numbers are in the range -1 - -128: see
#3 lore raw

Re: [PATCH 4/5] x86-64 perfmon2 code for review

Hello,

For some reasons, the original annoucement from 11/18 for this release never made it to this list.

You can download the latest packages from:

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

You need to grab:

	2.6.15-rc1-git6 (kernel code)
	libpfm-3.2-051118 (user library)

For convenience, I am also posting the patch directly to the list. At this point, the patch is for review. Please cc me on your replies because due to the volume of traffic I am not a member of the list.

I have split the patch into 5 parts. The first part is needed on each platform (common code). All the others are specific to a processor architecture. There is an exception for x86-64 which needs the i386 portion due to cross use of header files. The patch is relative to 2.6.15-rc1-git6.

thanks.

This E-mail contains Part 4: x86-64 code (AMD X86-64, EM64T, need part 3)

arch/x86_64/Kconfig +15 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/x86_64/Kconfig linux-2.6.15-rc1-git6/arch/x86_64/Kconfig
@@ -446,6 +446,21 @@
 
 source kernel/Kconfig.hz
 
+menu "Hardware Performance Monitoring support"
+
+config PERFMON
+ 	bool "Perfmon2 performance monitoring interface"
+	select X86_LOCAL_APIC
+	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/x86_64/perfmon/Kconfig"
+
+endmenu
+
 endmenu
 
 #
arch/x86_64/Makefile +1 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/x86_64/Makefile linux-2.6.15-rc1-git6/arch/x86_64/Makefile
@@ -58,6 +58,7 @@
 					   arch/x86_64/crypto/
 core-$(CONFIG_IA32_EMULATION)		+= arch/x86_64/ia32/
 drivers-$(CONFIG_PCI)			+= arch/x86_64/pci/
+drivers-$(CONFIG_PERFMON)		+= arch/x86_64/perfmon/
 drivers-$(CONFIG_OPROFILE)		+= arch/x86_64/oprofile/
 
 boot := arch/x86_64/boot
arch/x86_64/kernel/apic.c +2 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/x86_64/kernel/apic.c linux-2.6.15-rc1-git6/arch/x86_64/kernel/apic.c
@@ -25,6 +25,7 @@
 #include <linux/mc146818rtc.h>
 #include <linux/kernel_stat.h>
 #include <linux/sysdev.h>
+#include <linux/perfmon.h>
 
 #include <asm/atomic.h>
 #include <asm/smp.h>
@@ -860,6 +861,7 @@
 	int cpu = smp_processor_id();
 
 	profile_tick(CPU_PROFILING, regs);
+	pfm_handle_switch_timeout();
 	if (--per_cpu(prof_counter, cpu) <= 0) {
 		/*
 		 * The multiplier may have changed since the last time we got
arch/x86_64/kernel/entry.S +5 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/x86_64/kernel/entry.S linux-2.6.15-rc1-git6/arch/x86_64/kernel/entry.S
@@ -646,6 +646,11 @@
 
 ENTRY(spurious_interrupt)
 	apicinterrupt SPURIOUS_APIC_VECTOR,smp_spurious_interrupt
+
+#ifdef CONFIG_PERFMON
+ENTRY(pmu_interrupt)
+	apicinterrupt LOCAL_PERFMON_VECTOR, pfm_intr_handler
+#endif
 #endif
 				
 /*
arch/x86_64/kernel/i8259.c +3 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/x86_64/kernel/i8259.c linux-2.6.15-rc1-git6/arch/x86_64/kernel/i8259.c
@@ -13,6 +13,7 @@
 #include <linux/kernel_stat.h>
 #include <linux/sysdev.h>
 #include <linux/bitops.h>
+#include <linux/perfmon.h>
 
 #include <asm/acpi.h>
 #include <asm/atomic.h>
@@ -590,6 +591,8 @@
 	/* IPI vectors for APIC spurious and error interrupts */
 	set_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt);
 	set_intr_gate(ERROR_APIC_VECTOR, error_interrupt);
+
+ 	pfm_vector_init();
 #endif
 
 	/*
arch/x86_64/kernel/process.c +7 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/x86_64/kernel/process.c linux-2.6.15-rc1-git6/arch/x86_64/kernel/process.c
@@ -36,6 +36,7 @@
 #include <linux/utsname.h>
 #include <linux/random.h>
 #include <linux/kprobes.h>
+#include <linux/perfmon.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
@@ -344,6 +345,7 @@
 		t->io_bitmap_max = 0;
 		put_cpu();
 	}
+	pfm_exit_thread(me);
 }
 
 void flush_thread(void)
@@ -452,6 +454,8 @@
 	asm("mov %%es,%0" : "=m" (p->thread.es));
 	asm("mov %%ds,%0" : "=m" (p->thread.ds));
 
+	pfm_copy_thread(p, childregs);
+
 	if (unlikely(me->thread.io_bitmap_ptr != NULL)) { 
 		p->thread.io_bitmap_ptr = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL);
 		if (!p->thread.io_bitmap_ptr) {
@@ -475,6 +479,8 @@
 		if (err) 
 			goto out;
 	}
+
+
 	err = 0;
 out:
 	if (err && p->thread.io_bitmap_ptr) {
@@ -603,6 +609,7 @@
 			memset(tss->io_bitmap, 0xff, prev->io_bitmap_max);
 		}
 	}
+	pfm_ctxswin(next_p);
 
 	return prev_p;
 }
arch/x86_64/kernel/signal.c +5 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/x86_64/kernel/signal.c linux-2.6.15-rc1-git6/arch/x86_64/kernel/signal.c
@@ -24,6 +24,7 @@
 #include <linux/stddef.h>
 #include <linux/personality.h>
 #include <linux/compiler.h>
+#include <linux/perfmon.h>
 #include <asm/ucontext.h>
 #include <asm/uaccess.h>
 #include <asm/i387.h>
@@ -496,6 +497,10 @@
 		regs->eflags |= TF_MASK;
 		clear_thread_flag(TIF_SINGLESTEP);
 	}
+	/*
+	 * must be done before signals
+	 */
+	pfm_handle_work();
 
 	/* deal with pending signal delivery */
 	if (thread_info_flags & _TIF_SIGPENDING)
arch/x86_64/perfmon/Kconfig +27 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/x86_64/perfmon/Kconfig linux-2.6.15-rc1-git6/arch/x86_64/perfmon/Kconfig
@@ -0,0 +1,27 @@
+
+config X86_64_PERFMON_GENERIC
+         tristate "Support AMD X86-64 generic hardware performance counters"
+	 depends on PERFMON
+         default m
+         help
+         Enables support for the generic AMD X86-64 hardware performance
+	 counters. Does not work with Intel EM64T processors.
+         If unsure, say m.
+
+config X86_64_PERFMON_EM64T
+         tristate "Support Intel EM64T hardware performance counters"
+	 depends on PERFMON
+         default m
+         help
+         Enables support for the Intel EM64T hardware performance
+	 counters. Does not work with AMD X86-64 processors.
+         If unsure, say m.
+	 
+config X86_64_PERFMON_EM64T_PEBS
+         tristate "Support for Intel EM64T PEBS sampling format"
+	 depends on X86_64_PERFMON_EM64T
+         default m
+         help
+         Enables support for Precise Event-Based Sampling (PEBS) on the Intel EM64T
+	 processors which support it.  Does not work with AMD X86-64 processors.
+         If unsure, say m.
arch/x86_64/perfmon/Makefile +8 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/x86_64/perfmon/Makefile linux-2.6.15-rc1-git6/arch/x86_64/perfmon/Makefile
@@ -0,0 +1,8 @@
+#
+# Copyright (c) 2005 Hewlett-Packard Development Company, L.P.
+# Contributed by Stephane Eranian <[email protected]>
+#
+obj-$(CONFIG_PERFMON)			+= perfmon.o
+obj-$(CONFIG_X86_64_PERFMON_GENERIC)	+= perfmon_x86_64.o
+obj-$(CONFIG_X86_64_PERFMON_EM64T)	+= perfmon_em64t.o
+obj-$(CONFIG_X86_64_PERFMON_EM64T_PEBS)	+= perfmon_em64t_pebs_smpl.o
arch/x86_64/perfmon/perfmon.c +853 -0

853 lines not on this page · raw message

arch/x86_64/perfmon/perfmon_em64t.c +441 -0

441 lines not on this page · raw message

arch/x86_64/perfmon/perfmon_em64t_pebs_smpl.c +216 -0

216 lines not on this page · raw message

arch/x86_64/perfmon/perfmon_x86_64.c +164 -0

164 lines not on this page · raw message

include/asm-x86_64/hw_irq.h +2 -1
diff -urN linux-2.6.15-rc1-git6.orig/include/asm-x86_64/hw_irq.h linux-2.6.15-rc1-git6/include/asm-x86_64/hw_irq.h
@@ -67,6 +67,7 @@
  * sources per level' errata.
  */
 #define LOCAL_TIMER_VECTOR	0xef
+#define LOCAL_PERFMON_VECTOR	0xee
 
 /*
  * First APIC vector available to drivers: (vectors 0x30-0xee)
@@ -74,7 +75,7 @@
  * levels. (0x80 is the syscall vector)
  */
 #define FIRST_DEVICE_VECTOR	0x31
-#define FIRST_SYSTEM_VECTOR	0xef   /* duplicated in irq.h */
+#define FIRST_SYSTEM_VECTOR	0xee   /* duplicated in irq.h */
 
 
 #ifndef __ASSEMBLY__
include/asm-x86_64/irq.h +1 -1
diff -urN linux-2.6.15-rc1-git6.orig/include/asm-x86_64/irq.h linux-2.6.15-rc1-git6/include/asm-x86_64/irq.h
@@ -29,7 +29,7 @@
  */
 #define NR_VECTORS 256
 
-#define FIRST_SYSTEM_VECTOR	0xef   /* duplicated in hw_irq.h */
+#define FIRST_SYSTEM_VECTOR	0xee   /* duplicated in hw_irq.h */
 
 #ifdef CONFIG_PCI_MSI
 #define NR_IRQS FIRST_SYSTEM_VECTOR
include/asm-x86_64/perfmon.h +265 -0

265 lines not on this page · raw message

include/asm-x86_64/perfmon_em64t_pebs_smpl.h +99 -0

99 lines not on this page · raw message

include/asm-x86_64/processor.h +1 -0
diff -urN linux-2.6.15-rc1-git6.orig/include/asm-x86_64/processor.h linux-2.6.15-rc1-git6/include/asm-x86_64/processor.h
@@ -252,6 +252,7 @@
 	int		ioperm;
 	unsigned long	*io_bitmap_ptr;
 	unsigned io_bitmap_max;
+	void *pfm_context;
 /* cached TLS descriptors. */
 	u64 tls_array[GDT_ENTRY_TLS_ENTRIES];
 } __attribute__((aligned(16)));
include/asm-x86_64/system.h +1 -0
diff -urN linux-2.6.15-rc1-git6.orig/include/asm-x86_64/system.h linux-2.6.15-rc1-git6/include/asm-x86_64/system.h
@@ -27,6 +27,7 @@
 	,"rcx","rbx","rdx","r8","r9","r10","r11","r12","r13","r14","r15"
 
 #define switch_to(prev,next,last) \
+	pfm_ctxswout(prev);							  \
 	asm volatile(SAVE_CONTEXT						    \
 		     "movq %%rsp,%P[threadrsp](%[prev])\n\t" /* save RSP */	  \
 		     "movq %P[threadrsp](%[next]),%%rsp\n\t" /* restore RSP */	  \
include/asm-x86_64/unistd.h +25 -1
diff -urN linux-2.6.15-rc1-git6.orig/include/asm-x86_64/unistd.h linux-2.6.15-rc1-git6/include/asm-x86_64/unistd.h
@@ -571,8 +571,32 @@
 __SYSCALL(__NR_inotify_add_watch, sys_inotify_add_watch)
 #define __NR_inotify_rm_watch	255
 __SYSCALL(__NR_inotify_rm_watch, sys_inotify_rm_watch)
+#define __NR_pfm_create_context	256
+__SYSCALL(__NR_pfm_create_context, sys_pfm_create_context)
+#define __NR_pfm_write_pmcs	(__NR_pfm_create_context+1)
+__SYSCALL(__NR_pfm_write_pmcs, sys_pfm_write_pmcs)
+#define __NR_pfm_write_pmds	(__NR_pfm_create_context+2)
+__SYSCALL(__NR_pfm_write_pmds, sys_pfm_write_pmds)
+#define __NR_pfm_read_pmds	(__NR_pfm_create_context+3)
+__SYSCALL(__NR_pfm_read_pmds, sys_pfm_read_pmds)
+#define __NR_pfm_load_context	(__NR_pfm_create_context+4)
+__SYSCALL(__NR_pfm_load_context, sys_pfm_load_context)
+#define __NR_pfm_start		(__NR_pfm_create_context+5)
+__SYSCALL(__NR_pfm_start, sys_pfm_start)
+#define __NR_pfm_stop		(__NR_pfm_create_context+6)
+__SYSCALL(__NR_pfm_stop, sys_pfm_stop)
+#define __NR_pfm_restart	(__NR_pfm_create_context+7)
+__SYSCALL(__NR_pfm_restart, sys_pfm_restart)
+#define __NR_pfm_create_evtsets	(__NR_pfm_create_context+8)
+__SYSCALL(__NR_pfm_create_evtsets, sys_pfm_create_evtsets)
+#define __NR_pfm_getinfo_evtsets (__NR_pfm_create_context+9)
+__SYSCALL(__NR_pfm_getinfo_evtsets, sys_pfm_getinfo_evtsets)
+#define __NR_pfm_delete_evtsets (__NR_pfm_create_context+10)
+__SYSCALL(__NR_pfm_delete_evtsets, sys_pfm_delete_evtsets)
+#define __NR_pfm_unload_context	(__NR_pfm_create_context+11)
+__SYSCALL(__NR_pfm_unload_context, sys_pfm_unload_context)
 
-#define __NR_syscall_max __NR_inotify_rm_watch
+#define __NR_syscall_max __NR_pfm_unload_context
 #ifndef __NO_STUBS
 
 /* user-visible error numbers are in the range -1 - -4095 */
#4 lore raw

Re: [PATCH 5/5] powerpc perfmon2 code for review

Hello,

For some reasons, the original annoucement from 11/18 for this release never made it to this list.

You can download the latest packages from:

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

You need to grab:

	2.6.15-rc1-git6 (kernel code)
	libpfm-3.2-051118 (user library)

For convenience, I am also posting the patch directly to the list. At this point, the patch is for review. Please cc me on your replies because due to the volume of traffic I am not a member of the list.

I have split the patch into 5 parts. The first part is needed on each platform (common code). All the others are specific to a processor architecture. There is an exception for x86-64 which needs the i386 portion due to cross use of header files. The patch is relative to 2.6.15-rc1-git6.

thanks.

This E-mail contains Part 5: powerpc code (PPC64)

arch/powerpc/Kconfig +12 -0
diff -urN linux-2.6.15-rc1-git6.orig/arch/powerpc/Kconfig linux-2.6.15-rc1-git6/arch/powerpc/Kconfig
@@ -237,6 +237,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.15-rc1-git6.orig/arch/powerpc/Makefile linux-2.6.15-rc1-git6/arch/powerpc/Makefile
@@ -132,6 +132,7 @@
 				   arch/powerpc/platforms/
 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.15-rc1-git6.orig/arch/powerpc/kernel/entry_64.S linux-2.6.15-rc1-git6/arch/powerpc/kernel/entry_64.S
@@ -603,6 +603,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.15-rc1-git6.orig/arch/powerpc/kernel/process.c linux-2.6.15-rc1-git6/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>
@@ -306,7 +307,9 @@
 #endif
 
 	local_irq_save(flags);
+	pfm_ctxswout(prev);
 	last = _switch(old_thread, new_thread);
+	pfm_ctxswin(current);
 
 	local_irq_restore(flags);
 
@@ -447,6 +450,7 @@
 		last_task_used_spe = NULL;
 #endif
 #endif /* CONFIG_SMP */
+	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.15-rc1-git6.orig/arch/powerpc/kernel/systbl.S linux-2.6.15-rc1-git6/arch/powerpc/kernel/systbl.S
@@ -319,3 +319,15 @@
 SYSCALL(inotify_init)
 SYSCALL(inotify_add_watch)
 SYSCALL(inotify_rm_watch)
+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.15-rc1-git6.orig/arch/powerpc/perfmon/Kconfig linux-2.6.15-rc1-git6/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.15-rc1-git6.orig/arch/powerpc/perfmon/Makefile linux-2.6.15-rc1-git6/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 +347 -0

347 lines not on this page · raw message

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

103 lines not on this page · raw message

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

257 lines not on this page · raw message

include/asm-powerpc/processor.h +1 -0
diff -urN linux-2.6.15-rc1-git6.orig/include/asm-powerpc/processor.h linux-2.6.15-rc1-git6/include/asm-powerpc/processor.h
@@ -194,6 +194,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 -0
diff -urN linux-2.6.15-rc1-git6.orig/include/asm-powerpc/unistd.h linux-2.6.15-rc1-git6/include/asm-powerpc/unistd.h
@@ -297,6 +297,19 @@
 #define __NR_inotify_add_watch	276
 #define __NR_inotify_rm_watch	277
 
+#define __NR_pfm_create_context	278
+#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		278
 
 #ifdef __KERNEL__
#5 lore raw

Re: [PATCH 3/5] i386 perfmon2 code for review

In reply to Stephane Eranian
Quoted 16 lines · Stephane Eranian

diff -urN linux-2.6.15-rc1-git6.orig/arch/i386/kernel/i8259.c linux-2.6.15-rc1-git6/arch/i386/kernel/i8259.c
--- linux-2.6.15-rc1-git6.orig/arch/i386/kernel/i8259.c 2005-11-18 05:16:42.000000000 -0800
+++ linux-2.6.15-rc1-git6/arch/i386/kernel/i8259.c 2005-11-18
05:47:51.000000000 -0800

arch/i386/kernel/i8259.c +1 -0
@@ -11,6 +11,7 @@
 #include <linux/kernel_stat.h>
 #include <linux/sysdev.h>
 #include <linux/bitops.h>
+#include <linux/perfmon.h>
 
 #include <asm/8253pit.h>
 #include <asm/atomic.h>

arch/i386/kernel/i8259.c line 409

Quoted 6 lines
arch/i386/kernel/i8259.c +1 -0
@@ -403,6 +404,7 @@
        /* all the set up before the call gates are initialised */
        pre_intr_init_hook();
 
+
        /*
         * Cover the whole vector space, no vector can escape

Please don't make random whitespace changes.

-- Dave

#6 lore raw

PATCH 1/5 common perfmon2 code for review

In reply to a message not in the archive

Hello again,

Due to the message size limit on this list. Part 1 and 2 got blocked. Unfortunately the common code patch cannot easily be split into chunks of less than 100KB, The core file which is entirely new is 120KB by itself.

As a consequence, I strongly suggest that people interested in reviewing the code go the web site below to download the kernel patch.

Thanks.

Quoted 25 lines · Stephane Eranian

For some reasons, the original annoucement from 11/18 for this release never made it to this list.

You can download the latest packages from:

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

You need to grab:

	2.6.15-rc1-git6 (kernel code)
	libpfm-3.2-051118 (user library)

For convenience, I am also posting the patch directly to the list. At this point, the patch is for review. Please cc me on your replies because due to the volume of traffic I am not a member of the list.

I have split the patch into 5 parts. The first part is needed on each platform (common code). All the others are specific to a processor architecture. There is an exception for x86-64 which needs the i386 portion due to cross use of header files. The patch is relative to 2.6.15-rc1-git6.

thanks.