module.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Because linux/module.h has tracepoints in the header, and ftrace.h
  3. * used to include this file, define_trace.h includes linux/module.h
  4. * But we do not want the module.h to override the TRACE_SYSTEM macro
  5. * variable that define_trace.h is processing, so we only set it
  6. * when module events are being processed, which would happen when
  7. * CREATE_TRACE_POINTS is defined.
  8. */
  9. #ifdef CREATE_TRACE_POINTS
  10. #undef TRACE_SYSTEM
  11. #define TRACE_SYSTEM module
  12. #endif
  13. #if !defined(_TRACE_MODULE_H) || defined(TRACE_HEADER_MULTI_READ)
  14. #define _TRACE_MODULE_H
  15. #include <linux/tracepoint.h>
  16. #ifdef CONFIG_MODULES
  17. struct module;
  18. #define show_module_flags(flags) __print_flags(flags, "", \
  19. { (1UL << TAINT_PROPRIETARY_MODULE), "P" }, \
  20. { (1UL << TAINT_OOT_MODULE), "O" }, \
  21. { (1UL << TAINT_FORCED_MODULE), "F" }, \
  22. { (1UL << TAINT_CRAP), "C" }, \
  23. { (1UL << TAINT_UNSIGNED_MODULE), "E" })
  24. TRACE_EVENT(module_load,
  25. TP_PROTO(struct module *mod),
  26. TP_ARGS(mod),
  27. TP_STRUCT__entry(
  28. __field( unsigned int, taints )
  29. __string( name, mod->name )
  30. ),
  31. TP_fast_assign(
  32. __entry->taints = mod->taints;
  33. __assign_str(name, mod->name);
  34. ),
  35. TP_printk("%s %s", __get_str(name), show_module_flags(__entry->taints))
  36. );
  37. TRACE_EVENT(module_free,
  38. TP_PROTO(struct module *mod),
  39. TP_ARGS(mod),
  40. TP_STRUCT__entry(
  41. __string( name, mod->name )
  42. ),
  43. TP_fast_assign(
  44. __assign_str(name, mod->name);
  45. ),
  46. TP_printk("%s", __get_str(name))
  47. );
  48. #ifdef CONFIG_MODULE_UNLOAD
  49. /* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */
  50. DECLARE_EVENT_CLASS(module_refcnt,
  51. TP_PROTO(struct module *mod, unsigned long ip),
  52. TP_ARGS(mod, ip),
  53. TP_STRUCT__entry(
  54. __field( unsigned long, ip )
  55. __field( int, refcnt )
  56. __string( name, mod->name )
  57. ),
  58. TP_fast_assign(
  59. __entry->ip = ip;
  60. __entry->refcnt = atomic_read(&mod->refcnt);
  61. __assign_str(name, mod->name);
  62. ),
  63. TP_printk("%s call_site=%ps refcnt=%d",
  64. __get_str(name), (void *)__entry->ip, __entry->refcnt)
  65. );
  66. DEFINE_EVENT(module_refcnt, module_get,
  67. TP_PROTO(struct module *mod, unsigned long ip),
  68. TP_ARGS(mod, ip)
  69. );
  70. DEFINE_EVENT(module_refcnt, module_put,
  71. TP_PROTO(struct module *mod, unsigned long ip),
  72. TP_ARGS(mod, ip)
  73. );
  74. #endif /* CONFIG_MODULE_UNLOAD */
  75. TRACE_EVENT(module_request,
  76. TP_PROTO(char *name, bool wait, unsigned long ip),
  77. TP_ARGS(name, wait, ip),
  78. TP_STRUCT__entry(
  79. __field( unsigned long, ip )
  80. __field( bool, wait )
  81. __string( name, name )
  82. ),
  83. TP_fast_assign(
  84. __entry->ip = ip;
  85. __entry->wait = wait;
  86. __assign_str(name, name);
  87. ),
  88. TP_printk("%s wait=%d call_site=%ps",
  89. __get_str(name), (int)__entry->wait, (void *)__entry->ip)
  90. );
  91. #endif /* CONFIG_MODULES */
  92. #endif /* _TRACE_MODULE_H */
  93. /* This part must be outside protection */
  94. #include <trace/define_trace.h>