xref: /linux/kernel/trace/ftrace_internal.h (revision 3d0fe49454652117522f60bfbefb978ba0e5300b)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_KERNEL_FTRACE_INTERNAL_H
3 #define  _LINUX_KERNEL_FTRACE_INTERNAL_H
4 
5 int __register_ftrace_function(struct ftrace_ops *ops);
6 int __unregister_ftrace_function(struct ftrace_ops *ops);
7 
8 #ifdef CONFIG_FUNCTION_TRACER
9 
10 extern struct mutex ftrace_lock;
11 extern struct ftrace_ops global_ops;
12 
13 #ifdef CONFIG_DYNAMIC_FTRACE
14 
15 int ftrace_startup(struct ftrace_ops *ops, int command);
16 int ftrace_shutdown(struct ftrace_ops *ops, int command);
17 int ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip, void *regs);
18 
19 #else /* !CONFIG_DYNAMIC_FTRACE */
20 
21 /* Keep as macros so we do not need to define the commands */
22 # define ftrace_startup(ops, command)					\
23 	({								\
24 		int ___ret = __register_ftrace_function(ops);		\
25 		if (!___ret)						\
26 			(ops)->flags |= FTRACE_OPS_FL_ENABLED;		\
27 		___ret;							\
28 	})
29 # define ftrace_shutdown(ops, command)					\
30 	({								\
31 		int ___ret = __unregister_ftrace_function(ops);		\
32 		if (!___ret)						\
33 			(ops)->flags &= ~FTRACE_OPS_FL_ENABLED;		\
34 		___ret;							\
35 	})
36 static inline int
37 ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip, void *regs)
38 {
39 	return 1;
40 }
41 #endif /* CONFIG_DYNAMIC_FTRACE */
42 
43 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
44 extern int ftrace_graph_active;
45 void update_function_graph_func(void);
46 #else /* !CONFIG_FUNCTION_GRAPH_TRACER */
47 # define ftrace_graph_active 0
48 static inline void update_function_graph_func(void) { }
49 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
50 
51 #else /* !CONFIG_FUNCTION_TRACER */
52 #endif /* CONFIG_FUNCTION_TRACER */
53 
54 #endif
55