Whamcloud - gitweb
b_2075
authoryoufeng <youfeng>
Fri, 7 Nov 2003 03:56:29 +0000 (03:56 +0000)
committeryoufeng <youfeng>
Fri, 7 Nov 2003 03:56:29 +0000 (03:56 +0000)
print out the call stack

lnet/include/linux/kp30.h
lnet/libcfs/debug.c
lustre/kernel_patches/patches/kernel_text_address-2.4.20-rh.patch [new file with mode: 0644]
lustre/kernel_patches/patches/kernel_text_address-2.4.20-vanilla.patch [new file with mode: 0644]
lustre/kernel_patches/series/rh-2.4.20
lustre/portals/include/linux/kp30.h
lustre/portals/libcfs/debug.c

index dfca5fb..eaa7075 100644 (file)
@@ -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);
index 8b02d26..092baae 100644 (file)
@@ -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 (file)
index 0000000..bc7253d
--- /dev/null
@@ -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 <linux/irq.h>
+ #include <linux/module.h>
+-#ifdef CONFIG_MCL_COREDUMP
+-#include <linux/crash.h>
+-#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 (file)
index 0000000..99004c1
--- /dev/null
@@ -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
index c9174d6..81a323c 100644 (file)
@@ -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 
index dfca5fb..eaa7075 100644 (file)
@@ -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);
index 8b02d26..092baae 100644 (file)
@@ -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);