c63f86602555f59feb90d7e8957cc7707cfb0aaa
[lttng-modules.git] / instrumentation / events / lttng-module / module.h
1 /*
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.
8 */
9 #ifdef CREATE_TRACE_POINTS
10 #undef TRACE_SYSTEM
11 #define TRACE_SYSTEM module
12 #endif
13
14 #if !defined(_TRACE_MODULE_H) || defined(TRACE_HEADER_MULTI_READ)
15 #define _TRACE_MODULE_H
16
17 #include <linux/tracepoint.h>
18 #include <linux/version.h>
19
20 #ifdef CONFIG_MODULES
21
22 #ifndef _TRACE_MODULE_DEF
23 #define _TRACE_MODULE_DEF
24 struct module;
25
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" })
30 #endif
31
32 TRACE_EVENT(module_load,
33
34 TP_PROTO(struct module *mod),
35
36 TP_ARGS(mod),
37
38 TP_STRUCT__entry(
39 __field( unsigned int, taints )
40 __string( name, mod->name )
41 ),
42
43 TP_fast_assign(
44 tp_assign(taints, mod->taints)
45 tp_strcpy(name, mod->name)
46 ),
47
48 TP_printk("%s %s", __get_str(name), show_module_flags(__entry->taints))
49 )
50
51 TRACE_EVENT(module_free,
52
53 TP_PROTO(struct module *mod),
54
55 TP_ARGS(mod),
56
57 TP_STRUCT__entry(
58 __string( name, mod->name )
59 ),
60
61 TP_fast_assign(
62 tp_strcpy(name, mod->name)
63 ),
64
65 TP_printk("%s", __get_str(name))
66 )
67
68 #ifdef CONFIG_MODULE_UNLOAD
69 /* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */
70
71 DECLARE_EVENT_CLASS(module_refcnt,
72
73 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
74 TP_PROTO(struct module *mod, unsigned long ip),
75
76 TP_ARGS(mod, ip),
77 #else
78 TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
79
80 TP_ARGS(mod, ip, refcnt),
81 #endif
82
83 TP_STRUCT__entry(
84 __field( unsigned long, ip )
85 __field( int, refcnt )
86 __string( name, mod->name )
87 ),
88
89 TP_fast_assign(
90 tp_assign(ip, ip)
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))
93 #else
94 tp_assign(refcnt, refcnt)
95 #endif
96 tp_strcpy(name, mod->name)
97 ),
98
99 TP_printk("%s call_site=%pf refcnt=%d",
100 __get_str(name), (void *)__entry->ip, __entry->refcnt)
101 )
102
103 DEFINE_EVENT(module_refcnt, module_get,
104
105 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
106 TP_PROTO(struct module *mod, unsigned long ip),
107
108 TP_ARGS(mod, ip)
109 #else
110 TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
111
112 TP_ARGS(mod, ip, refcnt)
113 #endif
114 )
115
116 DEFINE_EVENT(module_refcnt, module_put,
117
118 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
119 TP_PROTO(struct module *mod, unsigned long ip),
120
121 TP_ARGS(mod, ip)
122 #else
123 TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
124
125 TP_ARGS(mod, ip, refcnt)
126 #endif
127 )
128 #endif /* CONFIG_MODULE_UNLOAD */
129
130 TRACE_EVENT(module_request,
131
132 TP_PROTO(char *name, bool wait, unsigned long ip),
133
134 TP_ARGS(name, wait, ip),
135
136 TP_STRUCT__entry(
137 __field( unsigned long, ip )
138 __field( bool, wait )
139 __string( name, name )
140 ),
141
142 TP_fast_assign(
143 tp_assign(ip, ip)
144 tp_assign(wait, wait)
145 tp_strcpy(name, name)
146 ),
147
148 TP_printk("%s wait=%d call_site=%pf",
149 __get_str(name), (int)__entry->wait, (void *)__entry->ip)
150 )
151
152 #endif /* CONFIG_MODULES */
153
154 #endif /* _TRACE_MODULE_H */
155
156 /* This part must be outside protection */
157 #include "../../../probes/define_trace.h"
This page took 0.031922 seconds and 3 git commands to generate.