2.6.16-rc1 perfmon2 patch for review
PATCH 4/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/i386/Kconfig +15 -0
@@ -711,6 +711,21 @@ Say N. +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
arch/i386/Makefile +1 -0
@@ -84,6 +84,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
@@ -27,6 +27,7 @@#include <linux/sysdev.h> #include <linux/cpu.h> #include <linux/module.h> +#include <linux/perfmon.h> #include <asm/atomic.h> #include <asm/smp.h>
@@ -1149,6 +1150,8 @@update_process_times (user_mode_vm (regs));#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
@@ -432,6 +432,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 +3 -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>
@@ -427,6 +428,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
@@ -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>
@@ -386,6 +387,7 @@ tss->io_bitmap_base =INVALID_IO_BITMAP_OFFSET ;put_cpu (); } +pfm_exit_thread (tsk); }void flush_thread (void )
@@ -437,6 +439,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 );
@@ -695,6 +699,8 @@disable_tsc (prev_p, next_p); +pfm_ctxswin (next_p); +return prev_p; }
arch/i386/kernel/signal.c +6 -0
@@ -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
@@ -294,3 +294,15 @@ .long sys_inotify_add_watch .long sys_inotify_rm_watch .long sys_migrate_pages + .long sys_pfm_create_context /* 295 */ + .long sys_pfm_write_pmcs + .long sys_pfm_write_pmds + .long sys_pfm_read_pmds + .long sys_pfm_load_context + .long sys_pfm_start /* 300 */ + .long sys_pfm_stop + .long sys_pfm_restart + .long sys_pfm_create_evtsets + .long sys_pfm_getinfo_evtsets + .long sys_pfm_delete_evtsets /* 305 */ + .long sys_pfm_unload_context
arch/i386/perfmon/Kconfig +34 -0
@@ -0,0 +1,34 @@ +config PERFMON_P6 + tristate "Support for P6 hardware performance counters" + depends on PERFMON + default m + help + Enables support for the P6-style hardware performance counters. + Not to be used for Pentium M processors. + If unsure, say M. + +config PERFMON_PM + tristate "Support for Pentium M hardware performance counters" + depends on PERFMON + default m + help + Enables support for the Pentium M processor performance counters. + Not to be used with P6-style processors. + 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 +9 -0
@@ -0,0 +1,9 @@ +# +# Copyright (c) 2005-2006 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_PM) += perfmon_pm.o +obj-$(CONFIG_PERFMON_P4) += perfmon_p4.o +obj-$(CONFIG_PERFMON_P4_PEBS) += perfmon_p4_pebs_smpl.o
arch/i386/perfmon/perfmon.c +1076 -0
1,076 lines not on this page · raw message
arch/i386/perfmon/perfmon_p4.c +390 -0
390 lines not on this page · raw message
arch/i386/perfmon/perfmon_p4_pebs_smpl.c +224 -0
224 lines not on this page · raw message
arch/i386/perfmon/perfmon_p6.c +147 -0
147 lines not on this page · raw message
arch/i386/perfmon/perfmon_pm.c +150 -0
150 lines not on this page · raw message
include/asm-i386/mach-default/irq_vectors.h +2 -1
@@ -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 +262 -0
262 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
@@ -427,6 +427,7 @@*/ unsigned long io_bitmap_max;struct thread_struct *io_bitmap_owner; +/* * pads the TSS to be cacheline-aligned (size is 0x100) */
@@ -464,6 +465,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
@@ -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 +13 -1
@@ -300,8 +300,20 @@#define __NR_inotify_add_watch 292#define __NR_inotify_rm_watch 293#define __NR_migrate_pages 294 +#define __NR_pfm_create_context 295 +#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 295 +#define NR_syscalls 306/* * user-visible error numbers are in the range -1 - -128: see