Whamcloud - gitweb
LU-12400 libcfs: save_stack_trace_tsk if ARCH_STACKWALK 39/35239/3
authorShaun Tancheff <stancheff@cray.com>
Mon, 15 Jul 2019 17:30:43 +0000 (12:30 -0500)
committerOleg Drokin <green@whamcloud.com>
Sat, 20 Jul 2019 18:38:36 +0000 (18:38 +0000)
Along with CONFIG_ARCH_STACKWALK save_stack_trace_tsk is not
directly available. Try using symbol_get() to acquire it.

Linux-commit: 214d8ca6ee854f696f75e75511fe66b409e656db

Test-Parameters: trivial
Cray-bug-id: LUS-7600
Signed-off-by: Shaun Tancheff <stancheff@cray.com>
Change-Id: I923b718eadc6c58fa2676a6d2fbd48523c615f62
Reviewed-on: https://review.whamcloud.com/35239
Reviewed-by: Chris Horn <hornc@cray.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/libcfs/linux/linux-debug.c

index aa01487..e401066 100644 (file)
@@ -128,8 +128,39 @@ do {                                                                              \
 #define MAX_ST_ENTRIES 100
 static DEFINE_SPINLOCK(st_lock);
 
+/*
+ * Linux v5.1-rc5 214d8ca6ee ("stacktrace: Provide common infrastructure")
+ * CONFIG_ARCH_STACKWALK indicates that save_stack_trace_tsk symbol is not
+ * exported. Use symbol_get() to find if save_stack_trace_tsk is available.
+ */
+#ifdef CONFIG_ARCH_STACKWALK
+typedef unsigned int (stack_trace_save_tsk_t)(struct task_struct *task,
+               unsigned long *store, unsigned int size,
+               unsigned int skipnr);
+static stack_trace_save_tsk_t *task_dump_stack;
+#endif
+
 static void libcfs_call_trace(struct task_struct *tsk)
 {
+#ifdef CONFIG_ARCH_STACKWALK
+       static unsigned long entries[MAX_ST_ENTRIES];
+       unsigned int i, nr_entries;
+
+       if (!task_dump_stack)
+               task_dump_stack = (stack_trace_save_tsk_t *)
+                       symbol_get("stack_trace_save_tsk");
+
+       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 TBD:\n");
+       if (task_dump_stack) {
+               nr_entries = task_dump_stack(tsk, entries, MAX_ST_ENTRIES, 0);
+               for (i = 0; i < nr_entries; i++)
+                       pr_info("[<0>] %pB\n", (void *)entries[i]);
+       }
+       spin_unlock(&st_lock);
+#else
        struct stack_trace trace;
        static unsigned long entries[MAX_ST_ENTRIES];
 
@@ -145,6 +176,7 @@ static void libcfs_call_trace(struct task_struct *tsk)
        save_stack_trace_tsk(tsk, &trace);
        print_stack_trace(&trace, 0);
        spin_unlock(&st_lock);
+#endif
 }
 
 #else /* !CONFIG_STACKTRACE */