diff mbox series

[01/49] lnet: libcfs: Fix for unconfigured arch_stackwalk

Message ID 1618459361-17909-2-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: sync to OpenSFS as of March 30 2021 | expand

Commit Message

James Simmons April 15, 2021, 4:01 a.m. UTC
From: Shaun Tancheff <shaun.tancheff@hpe.com>

On aarch64 CONFIG_ARCH_STACKWALK is not defined and
save_stack_trace_tsk() is not available.

HPE-bug-id: LUS-9518
WC-bug-id: https://jira.whamcloud.com/browse/LU-14099
Lustre-commit: 58ac9d3f1844701 ("LU-14099 build: Fix for unconfigured arch_stackwalk")
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-on: https://review.whamcloud.com/40503
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 net/lnet/libcfs/debug.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/net/lnet/libcfs/debug.c b/net/lnet/libcfs/debug.c
index ba32a99..e68dd91 100644
--- a/net/lnet/libcfs/debug.c
+++ b/net/lnet/libcfs/debug.c
@@ -451,32 +451,40 @@  void __noreturn lbug_with_loc(struct libcfs_debug_msg_data *msgdata)
 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)
 {
 	static unsigned long entries[MAX_ST_ENTRIES];
+#ifdef CONFIG_ARCH_STACKWALK
 	unsigned int nr_entries;
 
+	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");
-
-	spin_lock(&st_lock);
 	nr_entries = stack_trace_save_tsk(tsk, entries,
 					  MAX_ST_ENTRIES, 0);
-
 	stack_trace_print(entries, nr_entries, 0);
 	spin_unlock(&st_lock);
-}
 #else /* !CONFIG_STACKTRACE */
-static void libcfs_call_trace(struct task_struct *tsk)
-{
-	if (tsk == current)
-		dump_stack();
-	else
-		CWARN("can't show stack: kernel doesn't export show_task\n");
+	struct stack_trace trace;
+
+	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);
+	stack_trace_print(entries, nr_entries, 0);
+	spin_unlock(&st_lock);
+#endif
 }
 #endif /* !CONFIG_STACKTRACE */