Skip to content

Commit e999995

Browse files
Chengming Zhouctmarinas
authored andcommitted
ftrace: cleanup ftrace_graph_caller enable and disable
The ftrace_[enable,disable]_ftrace_graph_caller() are used to do special hooks for graph tracer, which are not needed on some ARCHs that use graph_ops:func function to install return_hooker. So introduce the weak version in ftrace core code to cleanup in x86. Signed-off-by: Chengming Zhou <[email protected]> Acked-by: Steven Rostedt (Google) <[email protected]> Acked-by: Mark Rutland <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent b2d229d commit e999995

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

arch/x86/kernel/ftrace.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -579,9 +579,7 @@ void arch_ftrace_trampoline_free(struct ftrace_ops *ops)
579579

580580
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
581581

582-
#ifdef CONFIG_DYNAMIC_FTRACE
583-
584-
#ifndef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS
582+
#if defined(CONFIG_DYNAMIC_FTRACE) && !defined(CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS)
585583
extern void ftrace_graph_call(void);
586584
static const char *ftrace_jmp_replace(unsigned long ip, unsigned long addr)
587585
{
@@ -610,18 +608,7 @@ int ftrace_disable_ftrace_graph_caller(void)
610608

611609
return ftrace_mod_jmp(ip, &ftrace_stub);
612610
}
613-
#else /* !CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS */
614-
int ftrace_enable_ftrace_graph_caller(void)
615-
{
616-
return 0;
617-
}
618-
619-
int ftrace_disable_ftrace_graph_caller(void)
620-
{
621-
return 0;
622-
}
623-
#endif /* CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS */
624-
#endif /* !CONFIG_DYNAMIC_FTRACE */
611+
#endif /* CONFIG_DYNAMIC_FTRACE && !CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS */
625612

626613
/*
627614
* Hook the return address and push it in the stack of return addrs

kernel/trace/fgraph.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,24 @@ int ftrace_graph_active;
3030
/* Both enabled by default (can be cleared by function_graph tracer flags */
3131
static bool fgraph_sleep_time = true;
3232

33+
/*
34+
* archs can override this function if they must do something
35+
* to enable hook for graph tracer.
36+
*/
37+
int __weak ftrace_enable_ftrace_graph_caller(void)
38+
{
39+
return 0;
40+
}
41+
42+
/*
43+
* archs can override this function if they must do something
44+
* to disable hook for graph tracer.
45+
*/
46+
int __weak ftrace_disable_ftrace_graph_caller(void)
47+
{
48+
return 0;
49+
}
50+
3351
/**
3452
* ftrace_graph_stop - set to permanently disable function graph tracing
3553
*

0 commit comments

Comments
 (0)