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.
9 #ifdef CREATE_TRACE_POINTS
11 #define TRACE_SYSTEM module
14 #if !defined(_TRACE_MODULE_H) || defined(TRACE_HEADER_MULTI_READ)
15 #define _TRACE_MODULE_H
17 #include <linux/tracepoint.h>
23 #define show_module_flags(flags) __print_flags(flags, "", \
24 { (1UL << TAINT_PROPRIETARY_MODULE), "P" }, \
25 { (1UL << TAINT_OOT_MODULE), "O" }, \
26 { (1UL << TAINT_FORCED_MODULE), "F" }, \
27 { (1UL << TAINT_CRAP), "C" }, \
28 { (1UL << TAINT_UNSIGNED_MODULE), "E" })
30 TRACE_EVENT(module_load
,
32 TP_PROTO(struct module
*mod
),
37 __field( unsigned int, taints
)
38 __string( name
, mod
->name
)
42 __entry
->taints
= mod
->taints
;
43 __assign_str(name
, mod
->name
);
46 TP_printk("%s %s", __get_str(name
), show_module_flags(__entry
->taints
))
49 TRACE_EVENT(module_free
,
51 TP_PROTO(struct module
*mod
),
56 __string( name
, mod
->name
)
60 __assign_str(name
, mod
->name
);
63 TP_printk("%s", __get_str(name
))
66 #ifdef CONFIG_MODULE_UNLOAD
67 /* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */
69 DECLARE_EVENT_CLASS(module_refcnt
,
71 TP_PROTO(struct module
*mod
, unsigned long ip
),
76 __field( unsigned long, ip
)
77 __field( int, refcnt
)
78 __string( name
, mod
->name
)
83 __entry
->refcnt
= atomic_read(&mod
->refcnt
);
84 __assign_str(name
, mod
->name
);
87 TP_printk("%s call_site=%ps refcnt=%d",
88 __get_str(name
), (void *)__entry
->ip
, __entry
->refcnt
)
91 DEFINE_EVENT(module_refcnt
, module_get
,
93 TP_PROTO(struct module
*mod
, unsigned long ip
),
98 DEFINE_EVENT(module_refcnt
, module_put
,
100 TP_PROTO(struct module
*mod
, unsigned long ip
),
104 #endif /* CONFIG_MODULE_UNLOAD */
106 TRACE_EVENT(module_request
,
108 TP_PROTO(char *name
, bool wait
, unsigned long ip
),
110 TP_ARGS(name
, wait
, ip
),
113 __field( unsigned long, ip
)
114 __field( bool, wait
)
115 __string( name
, name
)
120 __entry
->wait
= wait
;
121 __assign_str(name
, name
);
124 TP_printk("%s wait=%d call_site=%ps",
125 __get_str(name
), (int)__entry
->wait
, (void *)__entry
->ip
)
128 #endif /* CONFIG_MODULES */
130 #endif /* _TRACE_MODULE_H */
132 /* This part must be outside protection */
133 #include <trace/define_trace.h>