ftrace_internal.h 1.5 KB

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