treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / nds32 / kernel / stacktrace.c
blobd974c0c1c65f34123af8c7d2a63e2fb3e390e9f9
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2005-2017 Andes Technology Corporation
4 #include <linux/sched/debug.h>
5 #include <linux/sched/task_stack.h>
6 #include <linux/stacktrace.h>
7 #include <linux/ftrace.h>
9 void save_stack_trace(struct stack_trace *trace)
11 save_stack_trace_tsk(current, trace);
13 EXPORT_SYMBOL_GPL(save_stack_trace);
15 void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
17 unsigned long *fpn;
18 int skip = trace->skip;
19 int savesched;
20 int graph_idx = 0;
22 if (tsk == current) {
23 __asm__ __volatile__("\tori\t%0, $fp, #0\n":"=r"(fpn));
24 savesched = 1;
25 } else {
26 fpn = (unsigned long *)thread_saved_fp(tsk);
27 savesched = 0;
30 while (!kstack_end(fpn) && !((unsigned long)fpn & 0x3)
31 && (fpn >= (unsigned long *)TASK_SIZE)) {
32 unsigned long lpp, fpp;
34 lpp = fpn[LP_OFFSET];
35 fpp = fpn[FP_OFFSET];
36 if (!__kernel_text_address(lpp))
37 break;
38 else
39 lpp = ftrace_graph_ret_addr(tsk, &graph_idx, lpp, NULL);
41 if (savesched || !in_sched_functions(lpp)) {
42 if (skip) {
43 skip--;
44 } else {
45 trace->entries[trace->nr_entries++] = lpp;
46 if (trace->nr_entries >= trace->max_entries)
47 break;
50 fpn = (unsigned long *)fpp;
53 EXPORT_SYMBOL_GPL(save_stack_trace_tsk);