Skip to content

Commit 96d7a13

Browse files
rnavmpe
authored andcommitted
powerpc/ftrace: Simplify function_graph support in ftrace.c
Since we now support DYNAMIC_FTRACE_WITH_ARGS across ppc32 and ppc64 ELFv2, we can simplify function_graph tracer support code in ftrace.c Signed-off-by: Naveen N Rao <naveen@kernel.org> Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/4dc92c4b1ed444dc62b748ae7327acdb9e096864.1687166935.git.naveen@kernel.org
1 parent 7f7797b commit 96d7a13

1 file changed

Lines changed: 7 additions & 57 deletions

File tree

arch/powerpc/kernel/trace/ftrace.c

Lines changed: 7 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -790,44 +790,10 @@ int __init ftrace_dyn_arch_init(void)
790790
#endif
791791

792792
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
793-
794-
extern void ftrace_graph_call(void);
795-
extern void ftrace_graph_stub(void);
796-
797-
static int ftrace_modify_ftrace_graph_caller(bool enable)
798-
{
799-
unsigned long ip = (unsigned long)(&ftrace_graph_call);
800-
unsigned long addr = (unsigned long)(&ftrace_graph_caller);
801-
unsigned long stub = (unsigned long)(&ftrace_graph_stub);
802-
ppc_inst_t old, new;
803-
804-
if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_ARGS))
805-
return 0;
806-
807-
old = ftrace_call_replace(ip, enable ? stub : addr, 0);
808-
new = ftrace_call_replace(ip, enable ? addr : stub, 0);
809-
810-
return ftrace_modify_code(ip, old, new);
811-
}
812-
813-
int ftrace_enable_ftrace_graph_caller(void)
814-
{
815-
return ftrace_modify_ftrace_graph_caller(true);
816-
}
817-
818-
int ftrace_disable_ftrace_graph_caller(void)
819-
{
820-
return ftrace_modify_ftrace_graph_caller(false);
821-
}
822-
823-
/*
824-
* Hook the return address and push it in the stack of return addrs
825-
* in current thread info. Return the address we want to divert to.
826-
*/
827-
static unsigned long
828-
__prepare_ftrace_return(unsigned long parent, unsigned long ip, unsigned long sp)
793+
void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,
794+
struct ftrace_ops *op, struct ftrace_regs *fregs)
829795
{
830-
unsigned long return_hooker;
796+
unsigned long sp = fregs->regs.gpr[1];
831797
int bit;
832798

833799
if (unlikely(ftrace_graph_is_dead()))
@@ -836,31 +802,15 @@ __prepare_ftrace_return(unsigned long parent, unsigned long ip, unsigned long sp
836802
if (unlikely(atomic_read(&current->tracing_graph_pause)))
837803
goto out;
838804

839-
bit = ftrace_test_recursion_trylock(ip, parent);
805+
bit = ftrace_test_recursion_trylock(ip, parent_ip);
840806
if (bit < 0)
841807
goto out;
842808

843-
return_hooker = ppc_function_entry(return_to_handler);
844-
845-
if (!function_graph_enter(parent, ip, 0, (unsigned long *)sp))
846-
parent = return_hooker;
809+
if (!function_graph_enter(parent_ip, ip, 0, (unsigned long *)sp))
810+
parent_ip = ppc_function_entry(return_to_handler);
847811

848812
ftrace_test_recursion_unlock(bit);
849813
out:
850-
return parent;
814+
fregs->regs.link = parent_ip;
851815
}
852-
853-
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS
854-
void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,
855-
struct ftrace_ops *op, struct ftrace_regs *fregs)
856-
{
857-
fregs->regs.link = __prepare_ftrace_return(parent_ip, ip, fregs->regs.gpr[1]);
858-
}
859-
#else
860-
unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip,
861-
unsigned long sp)
862-
{
863-
return __prepare_ftrace_return(parent, ip, sp);
864-
}
865-
#endif
866816
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */

0 commit comments

Comments
 (0)