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

riscv/function_graph: Simplify with function_graph_enter()

The function_graph_enter() function does the work of calling the function
graph hook function and the management of the shadow stack, simplifying the
work done in the architecture dependent prepare_ftrace_return().

Have riscv use the new code, and remove the shadow stack management as well as
having to set up the trace structure.

This is needed to prepare for a fix of a design bug on how the curr_ret_stack
is used.

Cc: Greentime Hu <greentime@andestech.com>
Cc: Alan Kao <alankao@andestech.com>
Cc: stable@kernel.org
Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
Reviewed-by: Palmer Dabbelt <palmer@sifive.com>
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

+2 -12
+2 -12
arch/riscv/kernel/ftrace.c
··· 132 132 { 133 133 unsigned long return_hooker = (unsigned long)&return_to_handler; 134 134 unsigned long old; 135 - struct ftrace_graph_ent trace; 136 135 int err; 137 136 138 137 if (unlikely(atomic_read(&current->tracing_graph_pause))) ··· 143 144 */ 144 145 old = *parent; 145 146 146 - trace.func = self_addr; 147 - trace.depth = current->curr_ret_stack + 1; 148 - 149 - if (!ftrace_graph_entry(&trace)) 150 - return; 151 - 152 - err = ftrace_push_return_trace(old, self_addr, &trace.depth, 153 - frame_pointer, parent); 154 - if (err == -EBUSY) 155 - return; 156 - *parent = return_hooker; 147 + if (function_graph_enter(old, self_addr, frame_pointer, parent)) 148 + *parent = return_hooker; 157 149 } 158 150 159 151 #ifdef CONFIG_DYNAMIC_FTRACE