x86 performance counters driver 3.0-pre2 for 2.5.44: [4/4] kernel changes
PATCH 1/1 x86 performance counters driver 3.0-pre2 for 2.5.44: [4/4] kernel changes
Here is perfctr-3.0-pre2 for 2.5.44. This is the 2.5-ready version of the Linux/x86 performance-monitoring counters kernel extension. Please consider it for inclusion in 2.5/2.6.
This is part 4 of 4: kernel changes to actually integrate the perfctr driver. The kernel will compile with this patch set applied, if part 1/4 (core) also has been applied; the x86 and per-process patches are only needed of CONFIG_PERFCTR is enabled.
/Mikael
CREDITS | 1 + MAINTAINERS | 6 ++++++ arch/i386/config.in | 2 ++ arch/i386/kernel/entry.S | 11 +++++++++++ arch/i386/kernel/i8259.c | 3 +++ arch/i386/kernel/process.c | 9 +++++++++ arch/i386/mach-generic/irq_vectors.h | 5 +++-- drivers/Makefile | 1 + include/asm-i386/apic.h | 3 +++ include/asm-i386/processor.h | 2 ++ include/asm-i386/unistd.h | 1 + kernel/timer.c | 2 ++ 12 files changed, 44 insertions(+), 2 deletions(-)
CREDITS +1 -0
@@ -2402,6 +2402,7 @@ E: [email protected] W: http://www.csd.uu.se/~mikpe/ D: Miscellaneous fixes +D: Performance-monitoring counters driver (x86) N: Reed H. Petty E: [email protected]
MAINTAINERS +6 -0
@@ -1292,6 +1292,12 @@ L: [email protected] S: Maintained +PERFORMANCE-MONITORING COUNTERS DRIVER (x86) +P: Mikael Pettersson +M: [email protected] +W: http://www.csd.uu.se/~mikpe/linux/perfctr/ +S: Maintained + PNP SUPPORT P: Adam Belay M: [email protected]
arch/i386/config.in +2 -0
@@ -449,6 +449,8 @@ source arch/i386/oprofile/Config.in +source drivers/perfctr/Config.in + mainmenu_option next_comment comment 'Kernel hacking' if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
arch/i386/kernel/entry.S +11 -0
@@ -347,6 +347,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_PERFCTR) +ENTRY(perfctr_interrupt) + pushl $LOCAL_PERFCTR_VECTOR-256 + SAVE_ALL + pushl %esp + call do_perfctr_interrupt + addl $4, %esp + jmp ret_from_intr +#endif + ENTRY(divide_error) pushl $0 # no error code pushl $do_divide_error
@@ -737,6 +747,7 @@ .long sys_free_hugepages .long sys_exit_group .long sys_lookup_dcookie + .long sys_perfctr .rept NR_syscalls-(.-sys_call_table)/4 .long sys_ni_syscall
arch/i386/kernel/i8259.c +3 -0
@@ -22,6 +22,7 @@#include <asm/desc.h> #include <asm/apic.h> #include <asm/arch_hooks.h> +#include <asm/perfctr.h> #include <linux/irq.h>
@@ -389,6 +390,8 @@* the architecture specific gates */ intr_init_hook (); +perfctr_vector_init (); +/* * Set the clock to HZ Hz, we already have a valid * vector now:
arch/i386/kernel/process.c +9 -0
@@ -32,6 +32,7 @@#include <linux/delay.h> #include <linux/reboot.h> #include <linux/init.h> +#include <linux/perfctr.h> #include <linux/mc146818rtc.h> #include <linux/module.h>
@@ -240,6 +241,7 @@kfree (tsk->thread.ts_io_bitmap); tsk->thread.ts_io_bitmap =NULL ; } +perfctr_exit_thread (&tsk->thread); }void flush_thread (void )
@@ -299,6 +301,8 @@unlazy_fpu (tsk);struct_cpy (&p->thread.i387, &tsk->thread.i387); +perfctr_copy_thread (&p->thread); +if (unlikely (NULL != tsk->thread.ts_io_bitmap)) { p->thread.ts_io_bitmap =kmalloc (IO_BITMAP_BYTES ,GFP_KERNEL );if (!p->thread.ts_io_bitmap)
@@ -413,6 +417,8 @@/* never put a printk in __switch_to... printk() calls wake_up*() indirectly */ +perfctr_suspend_thread (prev); +unlazy_fpu (prev_p);/*
@@ -475,6 +481,8 @@*/ tss->bitmap =INVALID_IO_BITMAP_OFFSET ; } + +perfctr_resume_thread (next); } asmlinkage int sys_fork(struct pt_regs regs)
@@ -685,3 +693,4 @@return 0 ; } +cond_syscall (sys_perfctr)
arch/i386/mach-generic/irq_vectors.h +3 -2
@@ -56,14 +56,15 @@* sources per level' errata. */ #define LOCAL_TIMER_VECTOR 0xef +#define LOCAL_PERFCTR_VECTOR 0xee/* -* First APIC vector available to drivers: (vectors 0x30-0xee) +* First APIC vector available to drivers: (vectors 0x30-0xed) * we start at 0x31 to spread out vectors evenly between priority * 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
drivers/Makefile +1 -0
@@ -41,5 +41,6 @@ obj-$(CONFIG_BT) += bluetooth/ obj-$(CONFIG_HOTPLUG_PCI) += hotplug/ obj-$(CONFIG_ISDN_BOOL) += isdn/ +obj-$(CONFIG_PERFCTR) += perfctr/ include $(TOPDIR)/Rules.make
include/asm-i386/apic.h +3 -0
@@ -96,6 +96,9 @@#define NMI_LOCAL_APIC 2#define NMI_INVALID 3 +extern struct pm_dev *nmi_pmdev; +extern unsigned int nmi_perfctr_msr; +#endif /* CONFIG_X86_LOCAL_APIC */ #endif /* __ASM_APIC_H */
include/asm-i386/processor.h +2 -0
@@ -383,6 +383,8 @@unsigned long v86flags, v86mask, saved_esp0;/* IO permissions */ unsigned long *ts_io_bitmap; +/* performance counters */ +struct vperfctr *perfctr; };#define INIT_THREAD { \
include/asm-i386/unistd.h +1 -0
@@ -258,6 +258,7 @@#define __NR_free_hugepages 251#define __NR_exit_group 252#define __NR_lookup_dcookie 253 +#define __NR_perfctr 254/* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */
kernel/timer.c +2 -0
@@ -24,6 +24,7 @@#include <linux/percpu.h> #include <linux/init.h> #include <linux/mm.h> +#include <linux/perfctr.h> #include <asm/uaccess.h>
@@ -643,6 +644,7 @@do_process_times (p, user, system);do_it_virt (p, user);do_it_prof (p); +perfctr_sample_thread (&p->thread); }/*