From: youfeng Date: Fri, 7 Nov 2003 03:56:29 +0000 (+0000) Subject: b_2075 X-Git-Tag: v1_7_0_51~2^7~295 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=b577608cacd5b272ff936aee2275c90cf314b14c;p=fs%2Flustre-release.git b_2075 print out the call stack --- diff --git a/lnet/include/linux/kp30.h b/lnet/include/linux/kp30.h index dfca5fb..eaa7075 100644 --- a/lnet/include/linux/kp30.h +++ b/lnet/include/linux/kp30.h @@ -78,6 +78,8 @@ extern unsigned int portal_cerror; # define THREAD_SIZE 8192 #endif +#define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5) + #ifdef __KERNEL__ # ifdef __ia64__ # define CDEBUG_STACK (THREAD_SIZE - \ @@ -596,6 +598,9 @@ extern struct prof_ent prof_ents[MAX_PROFS]; #endif /* PORTALS_PROFILING */ /* debug.c */ +extern spinlock_t stack_backtrace_lock; + +char *portals_debug_dumpstack(void); char *portals_nid2str(int nal, ptl_nid_t nid, char *str); void portals_run_upcall(char **argv); void portals_run_lbug_upcall(char * file, const char *fn, const int line); diff --git a/lnet/libcfs/debug.c b/lnet/libcfs/debug.c index 8b02d26..092baae 100644 --- a/lnet/libcfs/debug.c +++ b/lnet/libcfs/debug.c @@ -941,9 +941,94 @@ char *portals_nid2str(int nal, ptl_nid_t nid, char *str) return str; } +char stack_backtrace[LUSTRE_TRACE_SIZE]; +spinlock_t stack_backtrace_lock = SPIN_LOCK_UNLOCKED; + +#if defined(__arch_um__) +# warning in arch_um + +extern int is_kernel_text_address(unsigned long addr); + +char *portals_debug_dumpstack(void) +{ + int size; + unsigned long addr; + char *buf = stack_backtrace; + char *pbuf = buf; + unsigned long *stack = (unsigned long *)&buf; + + size = sprintf(pbuf, " Call Trace: "); + pbuf += size; + while (((long) stack & (THREAD_SIZE-1)) != 0) { + addr = *stack++; + if (is_kernel_text_address(addr)) { + size = sprintf(pbuf, "[<%08lx>] ", addr); + pbuf += size; + if (buf + LUSTRE_TRACE_SIZE <= pbuf + 12) + break; + } + } + + return buf; +} + +#elif defined(CONFIG_X86) +# warning in __i386__ + +extern int is_kernel_text_address(unsigned long addr); +extern int lookup_symbol(unsigned long address, char *buf, int buflen); + +char *portals_debug_dumpstack(void) +{ + unsigned long esp = current->thread.esp; + unsigned long *stack = (unsigned long *)&esp; + int size; + unsigned long addr; + char *buf = stack_backtrace; + char *pbuf = buf; + static char buffer[512]; + + /* User space on another CPU? */ + if ((esp ^ (unsigned long)current) & (PAGE_MASK<<1)){ + memset(buf, 0x0, LUSTRE_TRACE_SIZE); + goto out; + } + + size = sprintf(pbuf, " Call Trace: "); + pbuf += size; + while (((long) stack & (THREAD_SIZE-1)) != 0) { + addr = *stack++; + if (is_kernel_text_address(addr)) { + lookup_symbol(addr, buffer, 512); + if (buf + LUSTRE_TRACE_SIZE + /* fix length + sizeof('\0') */ + <= pbuf + strlen(buffer) + 28 + 1) + break; + size = sprintf(pbuf, "([<%08lx>] %s (0x%x)) ", + addr, buffer, stack-1); + pbuf += size; + } + } +out: + return buf; +} + +#else /* !__arch_um__ && !__i386__ */ + +char *portals_debug_dumpstack(void) +{ + char *buf = stack_backtrace; + memset(buf, 0x0, LUSTRE_TRACE_SIZE); + return buf; +} + +#endif /* __arch_um__ */ + EXPORT_SYMBOL(portals_debug_dumplog); EXPORT_SYMBOL(portals_debug_msg); EXPORT_SYMBOL(portals_debug_set_level); EXPORT_SYMBOL(portals_run_upcall); EXPORT_SYMBOL(portals_run_lbug_upcall); EXPORT_SYMBOL(portals_nid2str); +EXPORT_SYMBOL(portals_debug_dumpstack); +EXPORT_SYMBOL(stack_backtrace_lock); diff --git a/lustre/kernel_patches/patches/kernel_text_address-2.4.20-rh.patch b/lustre/kernel_patches/patches/kernel_text_address-2.4.20-rh.patch new file mode 100644 index 0000000..bc7253d --- /dev/null +++ b/lustre/kernel_patches/patches/kernel_text_address-2.4.20-rh.patch @@ -0,0 +1,92 @@ +Index: linux-2.4.20-20.9/kernel/kksymoops.c +=================================================================== +--- linux-2.4.20-20.9.orig/kernel/kksymoops.c 2003-08-18 23:16:51.000000000 +0800 ++++ linux-2.4.20-20.9/kernel/kksymoops.c 2003-11-06 18:38:12.000000000 +0800 +@@ -80,3 +80,5 @@ + printk("%s\n",modlist); + #endif + } ++ ++EXPORT_SYMBOL(lookup_symbol); +Index: linux-2.4.20-20.9/kernel/Makefile +=================================================================== +--- linux-2.4.20-20.9.orig/kernel/Makefile 2003-11-06 18:35:56.000000000 +0800 ++++ linux-2.4.20-20.9/kernel/Makefile 2003-11-06 18:42:57.000000000 +0800 +@@ -9,7 +9,7 @@ + + O_TARGET := kernel.o + +-export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o printk.o cpufreq.o profile.o ++export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o printk.o cpufreq.o profile.o kksymoops.o + + obj-y = sched.o dma.o fork.o exec_domain.o panic.o printk.o lowlat.o profile.o \ + module.o exit.o itimer.o info.o time.o softirq.o resource.o \ +Index: linux-2.4.20-20.9/arch/i386/kernel/traps.c +=================================================================== +--- linux-2.4.20-20.9.orig/arch/i386/kernel/traps.c 2003-11-06 18:35:56.000000000 +0800 ++++ linux-2.4.20-20.9/arch/i386/kernel/traps.c 2003-11-06 18:43:26.000000000 +0800 +@@ -52,10 +52,6 @@ + #include + #include + +-#ifdef CONFIG_MCL_COREDUMP +-#include +-#endif +- + asmlinkage int system_call(void); + asmlinkage void lcall7(void); + asmlinkage void lcall27(void); +@@ -313,11 +309,7 @@ + netdump_func(regs); + bust_spinlocks(0); + spin_unlock_irq(&die_lock); +-#ifdef CONFIG_MCL_COREDUMP +- if(panic_on_oops) +- panic("die"); +-#endif +- do_exit(SIGSEGV);/* NOTREACHED */ ++ do_exit(SIGSEGV); + } + + static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err) +@@ -1027,9 +1019,39 @@ + #endif + } + ++#ifdef CONFIG_MODULES ++extern struct module *module_list; ++extern struct module kernel_module; ++#endif ++ ++int is_kernel_text_address(unsigned long addr) ++{ ++ int retval = 0; ++#ifdef CONFIG_MODULES ++ struct module *mod; ++#endif ++ if (addr >= (unsigned long) &_stext && ++ addr <= (unsigned long) &_etext); ++ return 1; ++ ++#ifdef CONFIG_MODULES ++ for (mod = module_list; mod != &kernel_module; mod = mod->next) { ++ /* mod_bound tests for addr being inside the vmalloc'ed ++ * module area. Of course it'd be better to test only ++ * for the .text subset... */ ++ if (mod_bound(addr, 0, mod)) { ++ retval = 1; ++ break; ++ } ++ } ++#endif ++ ++ return retval; ++} ++ + EXPORT_SYMBOL_GPL(netdump_func); + EXPORT_SYMBOL_GPL(netdump_mode); + #if CONFIG_X86_LOCAL_APIC + EXPORT_SYMBOL_GPL(nmi_watchdog); + #endif +- ++EXPORT_SYMBOL_GPL(is_kernel_text_address); diff --git a/lustre/kernel_patches/patches/kernel_text_address-2.4.20-vanilla.patch b/lustre/kernel_patches/patches/kernel_text_address-2.4.20-vanilla.patch new file mode 100644 index 0000000..99004c1 --- /dev/null +++ b/lustre/kernel_patches/patches/kernel_text_address-2.4.20-vanilla.patch @@ -0,0 +1,57 @@ +Index: linux-2.4.20/arch/um/kernel/Makefile +=================================================================== +--- linux-2.4.20.orig/arch/um/kernel/Makefile 2003-10-30 11:31:21.000000000 +0800 ++++ linux-2.4.20/arch/um/kernel/Makefile 2003-10-30 11:35:28.000000000 +0800 +@@ -37,7 +37,8 @@ + export-objs-$(CONFIG_GPROF) += gprof_syms.o + export-objs-$(CONFIG_GCOV) += gmon_syms.o + +-export-objs = ksyms.o process_kern.o signal_kern.o user_syms.o $(export-objs-y) ++export-objs = ksyms.o process_kern.o signal_kern.o user_syms.o sysrq.o \ ++ $(export-objs-y) + + CFLAGS_user_syms.o = -D__AUTOCONF_INCLUDED__ $(DMODULES-y) $(DMODVERSIONS-y) \ + -I/usr/include -I../include +Index: linux-2.4.20/arch/um/kernel/sysrq.c +=================================================================== +--- linux-2.4.20.orig/arch/um/kernel/sysrq.c 2003-10-30 11:31:22.000000000 +0800 ++++ linux-2.4.20/arch/um/kernel/sysrq.c 2003-10-30 11:37:36.000000000 +0800 +@@ -86,6 +86,40 @@ + show_trace((unsigned long *)esp); + } + ++#ifdef CONFIG_MODULES ++extern struct module *module_list; ++extern struct module kernel_module; ++#endif ++ ++int is_kernel_text_address(unsigned long addr) ++{ ++ int retval = 0; ++#ifdef CONFIG_MODULES ++ struct module *mod; ++#endif ++ if (addr >= (unsigned long) &_stext && ++ addr <= (unsigned long) &_etext); ++ return 1; ++ ++#ifdef CONFIG_MODULES ++ for (mod = module_list; mod != &kernel_module; mod = mod->next) { ++ /* mod_bound tests for addr being inside the vmalloc'ed ++ * module area. Of course it'd be better to test only ++ * for the .text subset... */ ++ if (mod_bound(addr, 0, mod)) { ++ retval = 1; ++ break; ++ } ++ } ++#endif ++ ++ return retval; ++} ++ ++EXPORT_SYMBOL(is_kernel_text_address); ++ + /* + * Overrides for Emacs so that we follow Linus's tabbing style. + * Emacs will notice this stuff at the end of the file and automatically diff --git a/lustre/kernel_patches/series/rh-2.4.20 b/lustre/kernel_patches/series/rh-2.4.20 index c9174d6..81a323c 100644 --- a/lustre/kernel_patches/series/rh-2.4.20 +++ b/lustre/kernel_patches/series/rh-2.4.20 @@ -39,3 +39,4 @@ ext3-ea-in-inode-2.4.20.patch listman-2.4.20.patch ext3-trusted_ea-2.4.20.patch netconsole-2.4.20-rh.patch +kernel_text_address-2.4.20-rh.patch diff --git a/lustre/portals/include/linux/kp30.h b/lustre/portals/include/linux/kp30.h index dfca5fb..eaa7075 100644 --- a/lustre/portals/include/linux/kp30.h +++ b/lustre/portals/include/linux/kp30.h @@ -78,6 +78,8 @@ extern unsigned int portal_cerror; # define THREAD_SIZE 8192 #endif +#define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5) + #ifdef __KERNEL__ # ifdef __ia64__ # define CDEBUG_STACK (THREAD_SIZE - \ @@ -596,6 +598,9 @@ extern struct prof_ent prof_ents[MAX_PROFS]; #endif /* PORTALS_PROFILING */ /* debug.c */ +extern spinlock_t stack_backtrace_lock; + +char *portals_debug_dumpstack(void); char *portals_nid2str(int nal, ptl_nid_t nid, char *str); void portals_run_upcall(char **argv); void portals_run_lbug_upcall(char * file, const char *fn, const int line); diff --git a/lustre/portals/libcfs/debug.c b/lustre/portals/libcfs/debug.c index 8b02d26..092baae 100644 --- a/lustre/portals/libcfs/debug.c +++ b/lustre/portals/libcfs/debug.c @@ -941,9 +941,94 @@ char *portals_nid2str(int nal, ptl_nid_t nid, char *str) return str; } +char stack_backtrace[LUSTRE_TRACE_SIZE]; +spinlock_t stack_backtrace_lock = SPIN_LOCK_UNLOCKED; + +#if defined(__arch_um__) +# warning in arch_um + +extern int is_kernel_text_address(unsigned long addr); + +char *portals_debug_dumpstack(void) +{ + int size; + unsigned long addr; + char *buf = stack_backtrace; + char *pbuf = buf; + unsigned long *stack = (unsigned long *)&buf; + + size = sprintf(pbuf, " Call Trace: "); + pbuf += size; + while (((long) stack & (THREAD_SIZE-1)) != 0) { + addr = *stack++; + if (is_kernel_text_address(addr)) { + size = sprintf(pbuf, "[<%08lx>] ", addr); + pbuf += size; + if (buf + LUSTRE_TRACE_SIZE <= pbuf + 12) + break; + } + } + + return buf; +} + +#elif defined(CONFIG_X86) +# warning in __i386__ + +extern int is_kernel_text_address(unsigned long addr); +extern int lookup_symbol(unsigned long address, char *buf, int buflen); + +char *portals_debug_dumpstack(void) +{ + unsigned long esp = current->thread.esp; + unsigned long *stack = (unsigned long *)&esp; + int size; + unsigned long addr; + char *buf = stack_backtrace; + char *pbuf = buf; + static char buffer[512]; + + /* User space on another CPU? */ + if ((esp ^ (unsigned long)current) & (PAGE_MASK<<1)){ + memset(buf, 0x0, LUSTRE_TRACE_SIZE); + goto out; + } + + size = sprintf(pbuf, " Call Trace: "); + pbuf += size; + while (((long) stack & (THREAD_SIZE-1)) != 0) { + addr = *stack++; + if (is_kernel_text_address(addr)) { + lookup_symbol(addr, buffer, 512); + if (buf + LUSTRE_TRACE_SIZE + /* fix length + sizeof('\0') */ + <= pbuf + strlen(buffer) + 28 + 1) + break; + size = sprintf(pbuf, "([<%08lx>] %s (0x%x)) ", + addr, buffer, stack-1); + pbuf += size; + } + } +out: + return buf; +} + +#else /* !__arch_um__ && !__i386__ */ + +char *portals_debug_dumpstack(void) +{ + char *buf = stack_backtrace; + memset(buf, 0x0, LUSTRE_TRACE_SIZE); + return buf; +} + +#endif /* __arch_um__ */ + EXPORT_SYMBOL(portals_debug_dumplog); EXPORT_SYMBOL(portals_debug_msg); EXPORT_SYMBOL(portals_debug_set_level); EXPORT_SYMBOL(portals_run_upcall); EXPORT_SYMBOL(portals_run_lbug_upcall); EXPORT_SYMBOL(portals_nid2str); +EXPORT_SYMBOL(portals_debug_dumpstack); +EXPORT_SYMBOL(stack_backtrace_lock);