ftrace_internal.h 2.0 KB

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