1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Because linux/module.h has tracepoints in the header, and ftrace.h
4 * used to include this file, define_trace.h includes linux/module.h
5 * But we do not want the module.h to override the TRACE_SYSTEM macro
6 * variable that define_trace.h is processing, so we only set it
7 * when module events are being processed, which would happen when
8 * CREATE_TRACE_POINTS is defined.
10 #ifdef CREATE_TRACE_POINTS
12 #define TRACE_SYSTEM module
15 #if !defined(_TRACE_MODULE_H) || defined(TRACE_HEADER_MULTI_READ)
16 #define _TRACE_MODULE_H
18 #include <linux/tracepoint.h>
24 #define show_module_flags(flags) __print_flags(flags, "", \
25 { (1UL << TAINT_PROPRIETARY_MODULE), "P" }, \
26 { (1UL << TAINT_OOT_MODULE), "O" }, \
27 { (1UL << TAINT_FORCED_MODULE), "F" }, \
28 { (1UL << TAINT_CRAP), "C" }, \
29 { (1UL << TAINT_UNSIGNED_MODULE), "E" })
31 TRACE_EVENT(module_load
,
33 TP_PROTO(struct module
*mod
),
38 __field( unsigned int, taints
)
39 __string( name
, mod
->name
)
43 __entry
->taints
= mod
->taints
;
44 __assign_str(name
, mod
->name
);
47 TP_printk("%s %s", __get_str(name
), show_module_flags(__entry
->taints
))
50 TRACE_EVENT(module_free
,
52 TP_PROTO(struct module
*mod
),
57 __string( name
, mod
->name
)
61 __assign_str(name
, mod
->name
);
64 TP_printk("%s", __get_str(name
))
67 #ifdef CONFIG_MODULE_UNLOAD
68 /* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */
70 DECLARE_EVENT_CLASS(module_refcnt
,
72 TP_PROTO(struct module
*mod
, unsigned long ip
),
77 __field( unsigned long, ip
)
78 __field( int, refcnt
)
79 __string( name
, mod
->name
)
84 __entry
->refcnt
= atomic_read(&mod
->refcnt
);
85 __assign_str(name
, mod
->name
);
88 TP_printk("%s call_site=%ps refcnt=%d",
89 __get_str(name
), (void *)__entry
->ip
, __entry
->refcnt
)
92 DEFINE_EVENT(module_refcnt
, module_get
,
94 TP_PROTO(struct module
*mod
, unsigned long ip
),
99 DEFINE_EVENT(module_refcnt
, module_put
,
101 TP_PROTO(struct module
*mod
, unsigned long ip
),
105 #endif /* CONFIG_MODULE_UNLOAD */
107 TRACE_EVENT(module_request
,
109 TP_PROTO(char *name
, bool wait
, unsigned long ip
),
111 TP_ARGS(name
, wait
, ip
),
114 __field( unsigned long, ip
)
115 __field( bool, wait
)
116 __string( name
, name
)
121 __entry
->wait
= wait
;
122 __assign_str(name
, name
);
125 TP_printk("%s wait=%d call_site=%ps",
126 __get_str(name
), (int)__entry
->wait
, (void *)__entry
->ip
)
129 #endif /* CONFIG_MODULES */
131 #endif /* _TRACE_MODULE_H */
133 /* This part must be outside protection */
134 #include <trace/define_trace.h>