perfctr-2.7.3 for 2.6.7-rc1-mm1, part 3/6: - x86_64 arch changes Signed-off-by: Andrew Morton --- 25-akpm/arch/x86_64/Kconfig | 2 ++ 25-akpm/arch/x86_64/ia32/ia32entry.S | 6 ++++++ 25-akpm/arch/x86_64/kernel/entry.S | 5 +++++ 25-akpm/arch/x86_64/kernel/i8259.c | 3 +++ 25-akpm/arch/x86_64/kernel/process.c | 8 ++++++++ 25-akpm/include/asm-x86_64/hw_irq.h | 5 +++-- 25-akpm/include/asm-x86_64/ia32_unistd.h | 8 +++++++- 25-akpm/include/asm-x86_64/irq.h | 2 +- 25-akpm/include/asm-x86_64/perfctr.h | 1 + 25-akpm/include/asm-x86_64/processor.h | 2 ++ 25-akpm/include/asm-x86_64/unistd.h | 14 +++++++++++++- 11 files changed, 51 insertions(+), 5 deletions(-) diff -puN arch/x86_64/ia32/ia32entry.S~perfctr-x86_64 arch/x86_64/ia32/ia32entry.S --- 25/arch/x86_64/ia32/ia32entry.S~perfctr-x86_64 2004-10-01 20:15:21.340946288 -0700 +++ 25-akpm/arch/x86_64/ia32/ia32entry.S 2004-10-01 20:15:21.355944008 -0700 @@ -587,6 +587,12 @@ ia32_sys_call_table: .quad compat_sys_mq_getsetattr .quad quiet_ni_syscall /* reserved for kexec */ .quad sys32_waitid + .quad sys_perfctr_info + .quad sys_vperfctr_open + .quad sys_vperfctr_control + .quad sys_vperfctr_unlink + .quad sys_vperfctr_iresume + .quad sys_vperfctr_read /* don't forget to change IA32_NR_syscalls */ ia32_syscall_end: .rept IA32_NR_syscalls-(ia32_syscall_end-ia32_sys_call_table)/8 diff -puN arch/x86_64/Kconfig~perfctr-x86_64 arch/x86_64/Kconfig --- 25/arch/x86_64/Kconfig~perfctr-x86_64 2004-10-01 20:15:21.341946136 -0700 +++ 25-akpm/arch/x86_64/Kconfig 2004-10-01 20:15:21.356943856 -0700 @@ -414,6 +414,8 @@ config UID16 depends on IA32_EMULATION default y +source "drivers/perfctr/Kconfig" + endmenu source drivers/Kconfig diff -puN arch/x86_64/kernel/entry.S~perfctr-x86_64 arch/x86_64/kernel/entry.S --- 25/arch/x86_64/kernel/entry.S~perfctr-x86_64 2004-10-01 20:15:21.343945832 -0700 +++ 25-akpm/arch/x86_64/kernel/entry.S 2004-10-01 20:15:21.356943856 -0700 @@ -560,6 +560,11 @@ ENTRY(spurious_interrupt) apicinterrupt SPURIOUS_APIC_VECTOR,smp_spurious_interrupt #endif +#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_PERFCTR) +ENTRY(perfctr_interrupt) + apicinterrupt LOCAL_PERFCTR_VECTOR,smp_perfctr_interrupt +#endif + /* * Exception entry points. */ diff -puN arch/x86_64/kernel/i8259.c~perfctr-x86_64 arch/x86_64/kernel/i8259.c --- 25/arch/x86_64/kernel/i8259.c~perfctr-x86_64 2004-10-01 20:15:21.344945680 -0700 +++ 25-akpm/arch/x86_64/kernel/i8259.c 2004-10-01 20:15:21.357943704 -0700 @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -560,6 +561,8 @@ void __init init_IRQ(void) set_intr_gate(ERROR_APIC_VECTOR, error_interrupt); #endif + perfctr_vector_init(); + /* * Set the clock to HZ Hz, we already have a valid * vector now: diff -puN arch/x86_64/kernel/process.c~perfctr-x86_64 arch/x86_64/kernel/process.c --- 25/arch/x86_64/kernel/process.c~perfctr-x86_64 2004-10-01 20:15:21.345945528 -0700 +++ 25-akpm/arch/x86_64/kernel/process.c 2004-10-01 20:15:21.358943552 -0700 @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -272,6 +273,7 @@ void exit_thread(void) t->io_bitmap_max = 0; put_cpu(); } + perfctr_exit_thread(&me->thread); } void flush_thread(void) @@ -375,6 +377,8 @@ int copy_thread(int nr, unsigned long cl asm("movl %%es,%0" : "=m" (p->thread.es)); asm("movl %%ds,%0" : "=m" (p->thread.ds)); + perfctr_copy_thread(&p->thread); + 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) { @@ -425,6 +429,8 @@ struct task_struct *__switch_to(struct t int cpu = smp_processor_id(); struct tss_struct *tss = &per_cpu(init_tss, cpu); + perfctr_suspend_thread(prev); + unlazy_fpu(prev_p); /* @@ -524,6 +530,8 @@ struct task_struct *__switch_to(struct t } } + perfctr_resume_thread(next); + return prev_p; } diff -puN include/asm-x86_64/hw_irq.h~perfctr-x86_64 include/asm-x86_64/hw_irq.h --- 25/include/asm-x86_64/hw_irq.h~perfctr-x86_64 2004-10-01 20:15:21.346945376 -0700 +++ 25-akpm/include/asm-x86_64/hw_irq.h 2004-10-01 20:15:21.358943552 -0700 @@ -65,14 +65,15 @@ struct hw_interrupt_type; * 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 /* duplicated in irq.h */ +#define FIRST_SYSTEM_VECTOR 0xee /* duplicated in irq.h */ #ifndef __ASSEMBLY__ diff -puN include/asm-x86_64/ia32_unistd.h~perfctr-x86_64 include/asm-x86_64/ia32_unistd.h --- 25/include/asm-x86_64/ia32_unistd.h~perfctr-x86_64 2004-10-01 20:15:21.348945072 -0700 +++ 25-akpm/include/asm-x86_64/ia32_unistd.h 2004-10-01 20:15:21.359943400 -0700 @@ -290,7 +290,13 @@ #define __NR_ia32_mq_getsetattr (__NR_ia32_mq_open+5) #define __NR_ia32_kexec 283 #define __NR_ia32_waitid 284 +#define __NR_ia32_perfctr_info 285 +#define __NR_ia32_vperfctr_open (__NR_ia32_perfctr_info+1) +#define __NR_ia32_vperfctr_control (__NR_ia32_perfctr_info+2) +#define __NR_ia32_vperfctr_unlink (__NR_ia32_perfctr_info+3) +#define __NR_ia32_vperfctr_iresume (__NR_ia32_perfctr_info+4) +#define __NR_ia32_vperfctr_read (__NR_ia32_perfctr_info+5) -#define IA32_NR_syscalls 285 /* must be > than biggest syscall! */ +#define IA32_NR_syscalls 291 /* must be > than biggest syscall! */ #endif /* _ASM_X86_64_IA32_UNISTD_H_ */ diff -puN include/asm-x86_64/irq.h~perfctr-x86_64 include/asm-x86_64/irq.h --- 25/include/asm-x86_64/irq.h~perfctr-x86_64 2004-10-01 20:15:21.349944920 -0700 +++ 25-akpm/include/asm-x86_64/irq.h 2004-10-01 20:15:21.359943400 -0700 @@ -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 diff -puN /dev/null include/asm-x86_64/perfctr.h --- /dev/null 2003-09-15 06:40:47.000000000 -0700 +++ 25-akpm/include/asm-x86_64/perfctr.h 2004-10-01 20:15:21.359943400 -0700 @@ -0,0 +1 @@ +#include diff -puN include/asm-x86_64/processor.h~perfctr-x86_64 include/asm-x86_64/processor.h --- 25/include/asm-x86_64/processor.h~perfctr-x86_64 2004-10-01 20:15:21.350944768 -0700 +++ 25-akpm/include/asm-x86_64/processor.h 2004-10-01 20:15:21.360943248 -0700 @@ -257,6 +257,8 @@ struct thread_struct { unsigned io_bitmap_max; /* cached TLS descriptors. */ u64 tls_array[GDT_ENTRY_TLS_ENTRIES]; +/* performance counters */ + struct vperfctr *perfctr; } __attribute__((aligned(16))); #define INIT_THREAD {} diff -puN include/asm-x86_64/unistd.h~perfctr-x86_64 include/asm-x86_64/unistd.h --- 25/include/asm-x86_64/unistd.h~perfctr-x86_64 2004-10-01 20:15:21.352944464 -0700 +++ 25-akpm/include/asm-x86_64/unistd.h 2004-10-01 20:15:21.361943096 -0700 @@ -556,8 +556,20 @@ __SYSCALL(__NR_mq_getsetattr, sys_mq_get __SYSCALL(__NR_kexec_load, sys_ni_syscall) #define __NR_waitid 247 __SYSCALL(__NR_waitid, sys_waitid) +#define __NR_perfctr_info 248 +__SYSCALL(__NR_perfctr_info, sys_perfctr_info) +#define __NR_vperfctr_open (__NR_perfctr_info+1) +__SYSCALL(__NR_vperfctr_open, sys_vperfctr_open) +#define __NR_vperfctr_control (__NR_perfctr_info+2) +__SYSCALL(__NR_vperfctr_control, sys_vperfctr_control) +#define __NR_vperfctr_unlink (__NR_perfctr_info+3) +__SYSCALL(__NR_vperfctr_unlink, sys_vperfctr_unlink) +#define __NR_vperfctr_iresume (__NR_perfctr_info+4) +__SYSCALL(__NR_vperfctr_iresume, sys_vperfctr_iresume) +#define __NR_vperfctr_read (__NR_perfctr_info+5) +__SYSCALL(__NR_vperfctr_read, sys_vperfctr_read) -#define __NR_syscall_max __NR_waitid +#define __NR_syscall_max __NR_vperfctr_read #ifndef __NO_STUBS /* user-visible error numbers are in the range -1 - -4095 */ _