Patch from Nikita Danilov this patch moves functions from identical per-architecture arch/*/kernel/profile.c into generic kernel/profile.c. Also, identical {x86,parisc,ppc64,sparc64}_profile_hook()'s are all replaced by the single kernel/profile.c:profile_hook(), which is #defined to noop in include/linux/profile.h if CONFIG_PROFILING is not set. dev/null | 217 ----------------------------------------- i386/kernel/Makefile | 1 i386/kernel/i386_ksyms.c | 2 parisc/kernel/Makefile | 1 parisc/kernel/parisc_ksyms.c | 5 parisc/kernel/time.c | 6 - ppc64/kernel/Makefile | 1 ppc64/kernel/ppc_ksyms.c | 5 ppc64/kernel/time.c | 5 sparc64/kernel/Makefile | 1 sparc64/kernel/sparc64_ksyms.c | 5 sparc64/kernel/time.c | 5 x86_64/kernel/Makefile | 2 x86_64/kernel/x8664_ksyms.c | 2 asm-i386/hw_irq.h | 26 ---- asm-parisc/irq.h | 17 --- asm-ppc64/hw_irq.h | 21 --- asm-sparc64/irq.h | 21 --- asm-x86_64/hw_irq.h | 26 ---- linux/profile.h | 20 +++ profile.c | 33 ++++++ 21 files changed, 58 insertions(+), 364 deletions(-) diff -puN arch/i386/kernel/i386_ksyms.c~profiling-cleanup arch/i386/kernel/i386_ksyms.c --- 25/arch/i386/kernel/i386_ksyms.c~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/arch/i386/kernel/i386_ksyms.c 2003-02-15 13:32:39.000000000 -0800 @@ -196,8 +196,6 @@ EXPORT_SYMBOL(get_wchan); EXPORT_SYMBOL(rtc_lock); -EXPORT_SYMBOL_GPL(register_profile_notifier); -EXPORT_SYMBOL_GPL(unregister_profile_notifier); EXPORT_SYMBOL_GPL(set_nmi_callback); EXPORT_SYMBOL_GPL(unset_nmi_callback); diff -puN arch/i386/kernel/Makefile~profiling-cleanup arch/i386/kernel/Makefile --- 25/arch/i386/kernel/Makefile~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/arch/i386/kernel/Makefile 2003-02-15 13:32:39.000000000 -0800 @@ -25,7 +25,6 @@ obj-$(CONFIG_X86_LOCAL_APIC) += apic.o n obj-$(CONFIG_X86_IO_APIC) += io_apic.o obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend.o suspend_asm.o obj-$(CONFIG_X86_NUMAQ) += numaq.o -obj-$(CONFIG_PROFILING) += profile.o obj-$(CONFIG_EDD) += edd.o obj-$(CONFIG_MODULES) += module.o obj-y += sysenter.o diff -puN -L arch/i386/kernel/profile.c arch/i386/kernel/profile.c~profiling-cleanup /dev/null --- 25/arch/i386/kernel/profile.c +++ /dev/null 2002-08-30 16:31:37.000000000 -0700 @@ -1,45 +0,0 @@ -/* - * linux/arch/i386/kernel/profile.c - * - * (C) 2002 John Levon - * - */ - -#include -#include -#include -#include -#include - -static struct notifier_block * profile_listeners; -static rwlock_t profile_lock = RW_LOCK_UNLOCKED; - -int register_profile_notifier(struct notifier_block * nb) -{ - int err; - write_lock_irq(&profile_lock); - err = notifier_chain_register(&profile_listeners, nb); - write_unlock_irq(&profile_lock); - return err; -} - - -int unregister_profile_notifier(struct notifier_block * nb) -{ - int err; - write_lock_irq(&profile_lock); - err = notifier_chain_unregister(&profile_listeners, nb); - write_unlock_irq(&profile_lock); - return err; -} - - -void x86_profile_hook(struct pt_regs * regs) -{ - /* we would not even need this lock if - * we had a global cli() on register/unregister - */ - read_lock(&profile_lock); - notifier_call_chain(&profile_listeners, 0, regs); - read_unlock(&profile_lock); -} diff -puN arch/parisc/kernel/Makefile~profiling-cleanup arch/parisc/kernel/Makefile --- 25/arch/parisc/kernel/Makefile~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/arch/parisc/kernel/Makefile 2003-02-15 13:32:39.000000000 -0800 @@ -16,7 +16,6 @@ obj-y := cache.o pacache.o setup.o processor.o pdc_chassis.o obj-$(CONFIG_SMP) += smp.o -obj-$(CONFIG_PROFILING) += profile.o obj-$(CONFIG_PA11) += pci-dma.o obj-$(CONFIG_PCI) += pci.o obj-$(CONFIG_MODULES) += module.o diff -puN arch/parisc/kernel/parisc_ksyms.c~profiling-cleanup arch/parisc/kernel/parisc_ksyms.c --- 25/arch/parisc/kernel/parisc_ksyms.c~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/arch/parisc/kernel/parisc_ksyms.c 2003-02-15 13:32:39.000000000 -0800 @@ -207,10 +207,5 @@ extern void $$dyncall(void); EXPORT_SYMBOL_NOVERS($$dyncall); #endif -#ifdef CONFIG_PROFILING -EXPORT_SYMBOL_GPL(register_profile_notifier); -EXPORT_SYMBOL_GPL(unregister_profile_notifier); -#endif - #include EXPORT_SYMBOL_NOVERS(vmalloc_start); diff -puN -L arch/parisc/kernel/profile.c arch/parisc/kernel/profile.c~profiling-cleanup /dev/null --- 25/arch/parisc/kernel/profile.c +++ /dev/null 2002-08-30 16:31:37.000000000 -0700 @@ -1,43 +0,0 @@ -/* arch/parisc/kernel/profile.c - * - * Almost entirely copied from ppc64 which is: - * (C) 2002 John Levon - */ - -#include -#include -#include -#include - -static struct notifier_block *profile_listeners; -static rwlock_t profile_lock = RW_LOCK_UNLOCKED; - -int register_profile_notifier(struct notifier_block *nb) -{ - int err; - - write_lock_irq(&profile_lock); - err = notifier_chain_register(&profile_listeners, nb); - write_unlock_irq(&profile_lock); - - return err; -} - -int unregister_profile_notifier(struct notifier_block *nb) -{ - int err; - - write_lock_irq(&profile_lock); - err = notifier_chain_unregister(&profile_listeners, nb); - write_unlock_irq(&profile_lock); - - return err; -} - -void parisc_profile_hook(struct pt_regs *regs) -{ - read_lock(&profile_lock); - notifier_call_chain(&profile_listeners, 0, regs); - read_unlock(&profile_lock); -} - diff -puN arch/parisc/kernel/time.c~profiling-cleanup arch/parisc/kernel/time.c --- 25/arch/parisc/kernel/time.c~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/arch/parisc/kernel/time.c 2003-02-15 13:32:39.000000000 -0800 @@ -51,11 +51,7 @@ parisc_do_profile(struct pt_regs *regs) extern unsigned long prof_cpu_mask; extern char _stext; -#ifdef CONFIG_PROFILING - extern void parisc_profile_hook(struct pt_regs *); - - parisc_profile_hook(regs); -#endif + profile_hook(regs); if (user_mode(regs)) return; diff -puN arch/ppc64/kernel/Makefile~profiling-cleanup arch/ppc64/kernel/Makefile --- 25/arch/ppc64/kernel/Makefile~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/arch/ppc64/kernel/Makefile 2003-02-15 13:32:39.000000000 -0800 @@ -27,7 +27,6 @@ obj-y += open_pic.o xics.o pSeries_h obj-$(CONFIG_RTAS_FLASH) += rtas_flash.o obj-$(CONFIG_SMP) += smp.o -obj-$(CONFIG_PROFILING) += profile.o obj-$(CONFIG_MODULES) += module.o ppc_ksyms.o obj-$(CONFIG_PPC_RTAS) += rtas-proc.o obj-$(CONFIG_SCANLOG) += scanlog.o diff -puN arch/ppc64/kernel/ppc_ksyms.c~profiling-cleanup arch/ppc64/kernel/ppc_ksyms.c --- 25/arch/ppc64/kernel/ppc_ksyms.c~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/arch/ppc64/kernel/ppc_ksyms.c 2003-02-15 13:32:39.000000000 -0800 @@ -232,8 +232,3 @@ EXPORT_SYMBOL(debugger_fault_handler); #endif EXPORT_SYMBOL(tb_ticks_per_usec); - -#ifdef CONFIG_PROFILING -EXPORT_SYMBOL_GPL(register_profile_notifier); -EXPORT_SYMBOL_GPL(unregister_profile_notifier); -#endif diff -puN -L arch/ppc64/kernel/profile.c arch/ppc64/kernel/profile.c~profiling-cleanup /dev/null --- 25/arch/ppc64/kernel/profile.c +++ /dev/null 2002-08-30 16:31:37.000000000 -0700 @@ -1,42 +0,0 @@ -/* - * linux/arch/i386/kernel/profile.c - * - * (C) 2002 John Levon - * - */ - -#include -#include -#include -#include -#include - -static struct notifier_block * profile_listeners; -static rwlock_t profile_lock = RW_LOCK_UNLOCKED; - -int register_profile_notifier(struct notifier_block * nb) -{ - int err; - write_lock_irq(&profile_lock); - err = notifier_chain_register(&profile_listeners, nb); - write_unlock_irq(&profile_lock); - return err; -} - - -int unregister_profile_notifier(struct notifier_block * nb) -{ - int err; - write_lock_irq(&profile_lock); - err = notifier_chain_unregister(&profile_listeners, nb); - write_unlock_irq(&profile_lock); - return err; -} - - -void ppc64_profile_hook(struct pt_regs * regs) -{ - read_lock(&profile_lock); - notifier_call_chain(&profile_listeners, 0, regs); - read_unlock(&profile_lock); -} diff -puN arch/ppc64/kernel/time.c~profiling-cleanup arch/ppc64/kernel/time.c --- 25/arch/ppc64/kernel/time.c~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/arch/ppc64/kernel/time.c 2003-02-15 13:32:39.000000000 -0800 @@ -110,11 +110,8 @@ static inline void ppc64_do_profile(stru unsigned long nip; extern unsigned long prof_cpu_mask; extern char _stext; -#ifdef CONFIG_PROFILING - extern void ppc64_profile_hook(struct pt_regs *); - ppc64_profile_hook(regs); -#endif + profile_hook(regs); if (user_mode(regs)) return; diff -puN arch/sparc64/kernel/Makefile~profiling-cleanup arch/sparc64/kernel/Makefile --- 25/arch/sparc64/kernel/Makefile~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/arch/sparc64/kernel/Makefile 2003-02-15 13:32:39.000000000 -0800 @@ -15,7 +15,6 @@ obj-y := process.o setup.o cpu.o idprom obj-$(CONFIG_PCI) += ebus.o isa.o pci_common.o pci_iommu.o \ pci_psycho.o pci_sabre.o pci_schizo.o obj-$(CONFIG_SMP) += smp.o trampoline.o -obj-$(CONFIG_PROFILING) += profile.o obj-$(CONFIG_SPARC32_COMPAT) += sys32.o sys_sparc32.o signal32.o ioctl32.o obj-$(CONFIG_BINFMT_ELF32) += binfmt_elf32.o obj-$(CONFIG_BINFMT_AOUT32) += binfmt_aout32.o diff -puN -L arch/sparc64/kernel/profile.c arch/sparc64/kernel/profile.c~profiling-cleanup /dev/null --- 25/arch/sparc64/kernel/profile.c +++ /dev/null 2002-08-30 16:31:37.000000000 -0700 @@ -1,42 +0,0 @@ -/* arch/sparc64/kernel/profile.c - * - * Almost entirely copied from ppc64 which is: - * (C) 2002 John Levon - */ - -#include -#include -#include -#include - -static struct notifier_block *profile_listeners; -static rwlock_t profile_lock = RW_LOCK_UNLOCKED; - -int register_profile_notifier(struct notifier_block *nb) -{ - int err; - - write_lock_irq(&profile_lock); - err = notifier_chain_register(&profile_listeners, nb); - write_unlock_irq(&profile_lock); - - return err; -} - -int unregister_profile_notifier(struct notifier_block *nb) -{ - int err; - - write_lock_irq(&profile_lock); - err = notifier_chain_unregister(&profile_listeners, nb); - write_unlock_irq(&profile_lock); - - return err; -} - -void sparc64_profile_hook(struct pt_regs *regs) -{ - read_lock(&profile_lock); - notifier_call_chain(&profile_listeners, 0, regs); - read_unlock(&profile_lock); -} diff -puN arch/sparc64/kernel/sparc64_ksyms.c~profiling-cleanup arch/sparc64/kernel/sparc64_ksyms.c --- 25/arch/sparc64/kernel/sparc64_ksyms.c~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/arch/sparc64/kernel/sparc64_ksyms.c 2003-02-15 13:32:39.000000000 -0800 @@ -374,8 +374,3 @@ EXPORT_SYMBOL(do_BUG); /* for ns8703 */ EXPORT_SYMBOL(ns87303_lock); - -#ifdef CONFIG_PROFILING -EXPORT_SYMBOL_GPL(register_profile_notifier); -EXPORT_SYMBOL_GPL(unregister_profile_notifier); -#endif diff -puN arch/sparc64/kernel/time.c~profiling-cleanup arch/sparc64/kernel/time.c --- 25/arch/sparc64/kernel/time.c~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/arch/sparc64/kernel/time.c 2003-02-15 13:32:39.000000000 -0800 @@ -88,11 +88,8 @@ void sparc64_do_profile(struct pt_regs * { unsigned long pc = regs->tpc; unsigned long o7 = regs->u_regs[UREG_RETPC]; -#ifdef CONFIG_PROFILING - extern void sparc64_profile_hook(struct pt_regs *); - sparc64_profile_hook(regs); -#endif + profile_hook(regs); if (user_mode(regs)) return; diff -puN arch/x86_64/kernel/Makefile~profiling-cleanup arch/x86_64/kernel/Makefile --- 25/arch/x86_64/kernel/Makefile~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/arch/x86_64/kernel/Makefile 2003-02-15 13:32:39.000000000 -0800 @@ -22,8 +22,6 @@ obj-$(CONFIG_EARLY_PRINTK) += early_p obj-$(CONFIG_GART_IOMMU) += pci-gart.o aperture.o obj-$(CONFIG_DUMMY_IOMMU) += pci-nommu.o obj-$(CONFIG_MODULES) += module.o -obj-$(CONFIG_PROFILING) += profile.o - $(obj)/bootflag.c: @ln -sf ../../i386/kernel/bootflag.c $(obj)/bootflag.c diff -puN -L arch/x86_64/kernel/profile.c arch/x86_64/kernel/profile.c~profiling-cleanup /dev/null --- 25/arch/x86_64/kernel/profile.c +++ /dev/null 2002-08-30 16:31:37.000000000 -0700 @@ -1,45 +0,0 @@ -/* - * linux/arch/x86_64/kernel/profile.c - * - * (C) 2002 John Levon - * - */ - -#include -#include -#include -#include -#include - -static struct notifier_block * profile_listeners; -static rwlock_t profile_lock = RW_LOCK_UNLOCKED; - -int register_profile_notifier(struct notifier_block * nb) -{ - int err; - write_lock_irq(&profile_lock); - err = notifier_chain_register(&profile_listeners, nb); - write_unlock_irq(&profile_lock); - return err; -} - - -int unregister_profile_notifier(struct notifier_block * nb) -{ - int err; - write_lock_irq(&profile_lock); - err = notifier_chain_unregister(&profile_listeners, nb); - write_unlock_irq(&profile_lock); - return err; -} - - -void x86_profile_hook(struct pt_regs * regs) -{ - /* we would not even need this lock if - * we had a global cli() on register/unregister - */ - read_lock(&profile_lock); - notifier_call_chain(&profile_listeners, 0, regs); - read_unlock(&profile_lock); -} diff -puN arch/x86_64/kernel/x8664_ksyms.c~profiling-cleanup arch/x86_64/kernel/x8664_ksyms.c --- 25/arch/x86_64/kernel/x8664_ksyms.c~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/arch/x86_64/kernel/x8664_ksyms.c 2003-02-15 13:32:39.000000000 -0800 @@ -132,8 +132,6 @@ EXPORT_SYMBOL(get_wchan); EXPORT_SYMBOL(rtc_lock); -EXPORT_SYMBOL_GPL(register_profile_notifier); -EXPORT_SYMBOL_GPL(unregister_profile_notifier); EXPORT_SYMBOL_GPL(set_nmi_callback); EXPORT_SYMBOL_GPL(unset_nmi_callback); diff -puN include/asm-i386/hw_irq.h~profiling-cleanup include/asm-i386/hw_irq.h --- 25/include/asm-i386/hw_irq.h~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/include/asm-i386/hw_irq.h 2003-02-15 13:32:39.000000000 -0800 @@ -76,11 +76,8 @@ static inline void x86_do_profile(struct { unsigned long eip; extern unsigned long prof_cpu_mask; -#ifdef CONFIG_PROFILING - extern void x86_profile_hook(struct pt_regs *); - x86_profile_hook(regs); -#endif + profile_hook(regs); if (user_mode(regs)) return; @@ -109,27 +106,6 @@ static inline void x86_do_profile(struct atomic_inc((atomic_t *)&prof_buffer[eip]); } -struct notifier_block; - -#ifdef CONFIG_PROFILING - -int register_profile_notifier(struct notifier_block * nb); -int unregister_profile_notifier(struct notifier_block * nb); - -#else - -static inline int register_profile_notifier(struct notifier_block * nb) -{ - return -ENOSYS; -} - -static inline int unregister_profile_notifier(struct notifier_block * nb) -{ - return -ENOSYS; -} - -#endif /* CONFIG_PROFILING */ - #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_SMP) static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) { diff -puN include/asm-parisc/irq.h~profiling-cleanup include/asm-parisc/irq.h --- 25/include/asm-parisc/irq.h~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/include/asm-parisc/irq.h 2003-02-15 13:32:39.000000000 -0800 @@ -95,21 +95,4 @@ extern unsigned long txn_alloc_addr(int) /* soft power switch support (power.c) */ extern struct tasklet_struct power_tasklet; -struct notifier_block; - -#ifdef CONFIG_PROFILING -int register_profile_notifier(struct notifier_block *nb); -int unregister_profile_notifier(struct notifier_block *nb); -#else -static inline int register_profile_notifier(struct notifier_block *nb) -{ - return -ENOSYS; -} - -static inline int unregister_profile_notifier(struct notifier_block *nb) -{ - return -ENOSYS; -} -#endif - #endif /* _ASM_PARISC_IRQ_H */ diff -puN include/asm-ppc64/hw_irq.h~profiling-cleanup include/asm-ppc64/hw_irq.h --- 25/include/asm-ppc64/hw_irq.h~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/include/asm-ppc64/hw_irq.h 2003-02-15 13:32:39.000000000 -0800 @@ -81,26 +81,5 @@ static inline void __do_save_and_cli(uns struct hw_interrupt_type; static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {} -struct notifier_block; - -#ifdef CONFIG_PROFILING - -int register_profile_notifier(struct notifier_block * nb); -int unregister_profile_notifier(struct notifier_block * nb); - -#else - -static inline int register_profile_notifier(struct notifier_block * nb) -{ - return -ENOSYS; -} - -static inline int unregister_profile_notifier(struct notifier_block * nb) -{ - return -ENOSYS; -} - -#endif /* CONFIG_PROFILING */ - #endif /* _PPC64_HW_IRQ_H */ #endif /* __KERNEL__ */ diff -puN include/asm-sparc64/irq.h~profiling-cleanup include/asm-sparc64/irq.h --- 25/include/asm-sparc64/irq.h~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/include/asm-sparc64/irq.h 2003-02-15 13:32:39.000000000 -0800 @@ -157,25 +157,4 @@ static __inline__ unsigned long get_soft return retval; } -struct notifier_block; - -#ifdef CONFIG_PROFILING - -int register_profile_notifier(struct notifier_block *nb); -int unregister_profile_notifier(struct notifier_block *nb); - -#else - -static inline int register_profile_notifier(struct notifier_block *nb) -{ - return -ENOSYS; -} - -static inline int unregister_profile_notifier(struct notifier_block *nb) -{ - return -ENOSYS; -} - -#endif /* CONFIG_PROFILING */ - #endif diff -puN include/asm-x86_64/hw_irq.h~profiling-cleanup include/asm-x86_64/hw_irq.h --- 25/include/asm-x86_64/hw_irq.h~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/include/asm-x86_64/hw_irq.h 2003-02-15 13:32:39.000000000 -0800 @@ -135,11 +135,9 @@ static inline void x86_do_profile (struc unsigned long rip; extern unsigned long prof_cpu_mask; extern char _stext; -#ifdef CONFIG_PROFILING - extern void x86_profile_hook(struct pt_regs *); - x86_profile_hook(regs); -#endif + profile_hook(regs); + if (user_mode(regs)) return; if (!prof_buffer) @@ -166,26 +164,6 @@ static inline void x86_do_profile (struc atomic_inc((atomic_t *)&prof_buffer[rip]); } -struct notifier_block; - -#ifdef CONFIG_PROFILING - -int register_profile_notifier(struct notifier_block * nb); -int unregister_profile_notifier(struct notifier_block * nb); - -#else - -static inline int register_profile_notifier(struct notifier_block * nb) -{ - return -ENOSYS; -} - -static inline int unregister_profile_notifier(struct notifier_block * nb) -{ - return -ENOSYS; -} - -#endif /* CONFIG_PROFILING */ #ifdef CONFIG_SMP /*more of this file should probably be ifdefed SMP */ static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) { if (IO_APIC_IRQ(i)) diff -puN include/linux/profile.h~profiling-cleanup include/linux/profile.h --- 25/include/linux/profile.h~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/include/linux/profile.h 2003-02-15 13:32:39.000000000 -0800 @@ -45,6 +45,12 @@ int profile_event_register(enum profile_ int profile_event_unregister(enum profile_type, struct notifier_block * n); +int register_profile_notifier(struct notifier_block * nb); +int unregister_profile_notifier(struct notifier_block * nb); + +/* profiling hook activated on each timer interrupt */ +void profile_hook(struct pt_regs * regs); + #else static inline int profile_event_register(enum profile_type t, struct notifier_block * n) @@ -60,7 +66,19 @@ static inline int profile_event_unregist #define profile_exit_task(a) do { } while (0) #define profile_exec_unmap(a) do { } while (0) #define profile_exit_mmap(a) do { } while (0) - + +static inline int register_profile_notifier(struct notifier_block * nb) +{ + return -ENOSYS; +} + +static inline int unregister_profile_notifier(struct notifier_block * nb) +{ + return -ENOSYS; +} + +#define profile_hook(regs) do { } while (0) + #endif /* CONFIG_PROFILING */ #endif /* __KERNEL__ */ diff -puN kernel/profile.c~profiling-cleanup kernel/profile.c --- 25/kernel/profile.c~profiling-cleanup 2003-02-15 13:32:39.000000000 -0800 +++ 25-akpm/kernel/profile.c 2003-02-15 13:32:39.000000000 -0800 @@ -119,6 +119,39 @@ int profile_event_unregister(enum profil return err; } +static struct notifier_block * profile_listeners; +static rwlock_t profile_lock = RW_LOCK_UNLOCKED; + +int register_profile_notifier(struct notifier_block * nb) +{ + int err; + write_lock_irq(&profile_lock); + err = notifier_chain_register(&profile_listeners, nb); + write_unlock_irq(&profile_lock); + return err; +} + + +int unregister_profile_notifier(struct notifier_block * nb) +{ + int err; + write_lock_irq(&profile_lock); + err = notifier_chain_unregister(&profile_listeners, nb); + write_unlock_irq(&profile_lock); + return err; +} + + +void profile_hook(struct pt_regs * regs) +{ + read_lock(&profile_lock); + notifier_call_chain(&profile_listeners, 0, regs); + read_unlock(&profile_lock); +} + +EXPORT_SYMBOL_GPL(register_profile_notifier); +EXPORT_SYMBOL_GPL(unregister_profile_notifier); + #endif /* CONFIG_PROFILING */ EXPORT_SYMBOL_GPL(profile_event_register); _