From: Mikael Pettersson - 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-11-30 01:23:32.732790968 -0800 +++ 25-akpm/arch/x86_64/ia32/ia32entry.S 2004-11-30 01:23:32.748788536 -0800 @@ -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-11-30 01:23:32.733790816 -0800 +++ 25-akpm/arch/x86_64/Kconfig 2004-11-30 01:23:32.749788384 -0800 @@ -437,6 +437,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-11-30 01:23:32.735790512 -0800 +++ 25-akpm/arch/x86_64/kernel/entry.S 2004-11-30 01:23:32.749788384 -0800 @@ -563,6 +563,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-11-30 01:23:32.736790360 -0800 +++ 25-akpm/arch/x86_64/kernel/i8259.c 2004-11-30 01:23:32.750788232 -0800 @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -562,6 +563,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-11-30 01:23:32.738790056 -0800 +++ 25-akpm/arch/x86_64/kernel/process.c 2004-11-30 01:23:32.751788080 -0800 @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -276,6 +277,7 @@ void exit_thread(void) t->io_bitmap_max = 0; put_cpu(); } + perfctr_exit_thread(&me->thread); } void flush_thread(void) @@ -378,6 +380,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) { @@ -428,6 +432,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); /* @@ -527,6 +533,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-11-30 01:23:32.739789904 -0800 +++ 25-akpm/include/asm-x86_64/hw_irq.h 2004-11-30 01:23:32.751788080 -0800 @@ -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-11-30 01:23:32.741789600 -0800 +++ 25-akpm/include/asm-x86_64/ia32_unistd.h 2004-11-30 01:23:32.752787928 -0800 @@ -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-11-30 01:23:32.742789448 -0800 +++ 25-akpm/include/asm-x86_64/irq.h 2004-11-30 01:23:32.752787928 -0800 @@ -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-11-30 01:23:32.752787928 -0800 @@ -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-11-30 01:23:32.743789296 -0800 +++ 25-akpm/include/asm-x86_64/processor.h 2004-11-30 01:23:32.753787776 -0800 @@ -258,6 +258,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-11-30 01:23:32.745788992 -0800 +++ 25-akpm/include/asm-x86_64/unistd.h 2004-11-30 01:23:32.754787624 -0800 @@ -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 */ _