From: Yang Sheng Date: Tue, 7 Aug 2018 16:24:19 +0000 (+0800) Subject: LU-11062 libcfs: use save_stack_trace for stack dump X-Git-Tag: 2.11.54~3 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=afedf9343686504c89f2e28cf6133540166f2347 LU-11062 libcfs: use save_stack_trace for stack dump The stacktrace_ops has been removed recently. So we have to use save_stack_trace_tsk for stack trace dump. Signed-off-by: Yang Sheng Change-Id: Icb3d0dbd62c35fdd9b8de925aec9358a2208814f Reviewed-on: https://review.whamcloud.com/32952 Reviewed-by: Andreas Dilger Tested-by: Jenkins Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/libcfs/libcfs/linux/linux-debug.c b/libcfs/libcfs/linux/linux-debug.c index 2778c62..46fbc29 100644 --- a/libcfs/libcfs/linux/linux-debug.c +++ b/libcfs/libcfs/linux/linux-debug.c @@ -45,6 +45,8 @@ #endif #include #include +#include +#include # define DEBUG_SUBSYSTEM S_LNET @@ -92,25 +94,51 @@ void libcfs_run_debug_log_upcall(char *file) /* coverity[+kill] */ void lbug_with_loc(struct libcfs_debug_msg_data *msgdata) { - libcfs_catastrophe = 1; - libcfs_debug_msg(msgdata, "LBUG\n"); + libcfs_catastrophe = 1; + libcfs_debug_msg(msgdata, "LBUG\n"); - if (in_interrupt()) { - panic("LBUG in interrupt.\n"); - /* not reached */ - } + if (in_interrupt()) { + panic("LBUG in interrupt.\n"); + /* not reached */ + } - libcfs_debug_dumpstack(NULL); - if (!libcfs_panic_on_lbug) - libcfs_debug_dumplog(); - if (libcfs_panic_on_lbug) - panic("LBUG"); + libcfs_debug_dumpstack(NULL); + if (libcfs_panic_on_lbug) + panic("LBUG"); + else + libcfs_debug_dumplog(); set_current_state(TASK_UNINTERRUPTIBLE); - while (1) - schedule(); + while (1) + schedule(); } EXPORT_SYMBOL(lbug_with_loc); +#ifdef CONFIG_STACKTRACE + +#define MAX_ST_ENTRIES 100 +static DEFINE_SPINLOCK(st_lock); + +static void libcfs_call_trace(struct task_struct *tsk) +{ + struct stack_trace trace; + static unsigned long entries[MAX_ST_ENTRIES]; + + trace.nr_entries = 0; + trace.max_entries = MAX_ST_ENTRIES; + trace.entries = entries; + trace.skip = 0; + + spin_lock(&st_lock); + pr_info("Pid: %d, comm: %.20s %s %s\n", tsk->pid, tsk->comm, + init_utsname()->release, init_utsname()->version); + pr_info("Call Trace:\n"); + save_stack_trace_tsk(tsk, &trace); + print_stack_trace(&trace, 0); + spin_unlock(&st_lock); +} + +#else /* !CONFIG_STACKTRACE */ + #ifdef CONFIG_X86 #include #include @@ -198,6 +226,8 @@ static void libcfs_call_trace(struct task_struct *tsk) #endif /* CONFIG_X86 */ +#endif /* CONFIG_STACKTRACE */ + void libcfs_debug_dumpstack(struct task_struct *tsk) { libcfs_call_trace(tsk ?: current);