2 * Because linux/module.h has tracepoints in the header, and ftrace.h
3 * eventually includes 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>
18 #include <linux/version.h>
22 #ifndef _TRACE_MODULE_DEF
23 #define _TRACE_MODULE_DEF
26 #define show_module_flags(flags) __print_flags(flags, "", \
27 { (1UL << TAINT_PROPRIETARY_MODULE), "P" }, \
28 { (1UL << TAINT_FORCED_MODULE), "F" }, \
29 { (1UL << TAINT_CRAP), "C" })
32 TRACE_EVENT(module_load,
34 TP_PROTO(struct module *mod),
39 __field( unsigned int, taints )
40 __string( name, mod->name )
44 tp_assign(taints, mod->taints)
45 tp_strcpy(name, mod->name)
48 TP_printk("%s %s", __get_str(name), show_module_flags(__entry->taints))
51 TRACE_EVENT(module_free,
53 TP_PROTO(struct module *mod),
58 __string( name, mod->name )
62 tp_strcpy(name, mod->name)
65 TP_printk("%s", __get_str(name))
68 #ifdef CONFIG_MODULE_UNLOAD
69 /* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */
71 DECLARE_EVENT_CLASS(module_refcnt,
73 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
74 TP_PROTO(struct module *mod, unsigned long ip),
78 TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
80 TP_ARGS(mod, ip, refcnt),
84 __field( unsigned long, ip )
85 __field( int, refcnt )
86 __string( name, mod->name )
91 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
92 tp_assign(refcnt, __this_cpu_read(mod->refptr->incs) + __this_cpu_read(mod->refptr->decs))
94 tp_assign(refcnt, refcnt)
96 tp_strcpy(name, mod->name)
99 TP_printk("%s call_site=%pf refcnt=%d",
100 __get_str(name), (void *)__entry->ip, __entry->refcnt)
103 DEFINE_EVENT(module_refcnt, module_get,
105 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
106 TP_PROTO(struct module *mod, unsigned long ip),
110 TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
112 TP_ARGS(mod, ip, refcnt)
116 DEFINE_EVENT(module_refcnt, module_put,
118 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
119 TP_PROTO(struct module *mod, unsigned long ip),
123 TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
125 TP_ARGS(mod, ip, refcnt)
128 #endif /* CONFIG_MODULE_UNLOAD */
130 TRACE_EVENT(module_request,
132 TP_PROTO(char *name, bool wait, unsigned long ip),
134 TP_ARGS(name, wait, ip),
137 __field( unsigned long, ip )
138 __field( bool, wait )
139 __string( name, name )
144 tp_assign(wait, wait)
145 tp_strcpy(name, name)
148 TP_printk("%s wait=%d call_site=%pf",
149 __get_str(name), (int)__entry->wait, (void *)__entry->ip)
152 #endif /* CONFIG_MODULES */
154 #endif /* _TRACE_MODULE_H */
156 /* This part must be outside protection */
157 #include "../../../probes/define_trace.h"