Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARC: Make arc_unwind_core accessible externally

The arc unwinder can also be used for perf callchains.

Signed-off-by: Mischa Jonker <mjonker@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

+51 -1
+37
arch/arc/include/asm/stacktrace.h
··· 1 + /* 2 + * Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com) 3 + * Copyright (C) 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) 4 + * 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License version 2 as 7 + * published by the Free Software Foundation. 8 + */ 9 + 10 + #ifndef __ASM_STACKTRACE_H 11 + #define __ASM_STACKTRACE_H 12 + 13 + #include <linux/sched.h> 14 + 15 + /** 16 + * arc_unwind_core - Unwind the kernel mode stack for an execution context 17 + * @tsk: NULL for current task, specific task otherwise 18 + * @regs: pt_regs used to seed the unwinder {SP, FP, BLINK, PC} 19 + * If NULL, use pt_regs of @tsk (if !NULL) otherwise 20 + * use the current values of {SP, FP, BLINK, PC} 21 + * @consumer_fn: Callback invoked for each frame unwound 22 + * Returns 0 to continue unwinding, -1 to stop 23 + * @arg: Arg to callback 24 + * 25 + * Returns the address of first function in stack 26 + * 27 + * Semantics: 28 + * - synchronous unwinding (e.g. dump_stack): @tsk NULL, @regs NULL 29 + * - Asynchronous unwinding of sleeping task: @tsk !NULL, @regs NULL 30 + * - Asynchronous unwinding of intr/excp etc: @tsk !NULL, @regs !NULL 31 + */ 32 + notrace noinline unsigned int arc_unwind_core( 33 + struct task_struct *tsk, struct pt_regs *regs, 34 + int (*consumer_fn) (unsigned int, void *), 35 + void *arg); 36 + 37 + #endif /* __ASM_STACKTRACE_H */
+14 -1
arch/arc/kernel/stacktrace.c
··· 43 43 struct pt_regs *regs, 44 44 struct unwind_frame_info *frame_info) 45 45 { 46 + /* 47 + * synchronous unwinding (e.g. dump_stack) 48 + * - uses current values of SP and friends 49 + */ 46 50 if (tsk == NULL && regs == NULL) { 47 51 unsigned long fp, sp, blink, ret; 48 52 frame_info->task = current; ··· 65 61 frame_info->regs.r63 = ret; 66 62 frame_info->call_frame = 0; 67 63 } else if (regs == NULL) { 64 + /* 65 + * Asynchronous unwinding of sleeping task 66 + * - Gets SP etc from task's pt_regs (saved bottom of kernel 67 + * mode stack of task) 68 + */ 68 69 69 70 frame_info->task = tsk; 70 71 ··· 92 83 frame_info->call_frame = 0; 93 84 94 85 } else { 86 + /* 87 + * Asynchronous unwinding of intr/exception 88 + * - Just uses the pt_regs passed 89 + */ 95 90 frame_info->task = tsk; 96 91 97 92 frame_info->regs.r27 = regs->fp; ··· 108 95 109 96 #endif 110 97 111 - static noinline unsigned int 98 + notrace noinline unsigned int 112 99 arc_unwind_core(struct task_struct *tsk, struct pt_regs *regs, 113 100 int (*consumer_fn) (unsigned int, void *), void *arg) 114 101 {