Fix: TAINT_UNSAFE_SMP renamed to TAINT_CPU_OUT_OF_SPEC in v3.15
[lttng-modules.git] / include / instrumentation / events / module.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Because linux/module.h has tracepoints in the header, and ftrace.h
4 * eventually includes 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.
9 */
10 #ifdef CREATE_TRACE_POINTS
11 #undef TRACE_SYSTEM
12 #define TRACE_SYSTEM module
13 #endif
14
15 #if !defined(LTTNG_TRACE_MODULE_H) || defined(TRACE_HEADER_MULTI_READ)
16 #define LTTNG_TRACE_MODULE_H
17
18 #include <lttng/tracepoint-event.h>
19 #include <linux/version.h>
20 #include <linux/kernel.h>
21
22 #ifdef CONFIG_MODULES
23
24 #ifndef _TRACE_MODULE_DEF
25 #define _TRACE_MODULE_DEF
26 struct module;
27
28 #endif
29
30 LTTNG_TRACEPOINT_ENUM(taint,
31 TP_ENUM_VALUES(
32 ctf_enum_value("PROPRIETARY_MODULE", 1UL << TAINT_PROPRIETARY_MODULE)
33 ctf_enum_value("FORCED_MODULE", 1UL << TAINT_FORCED_MODULE)
34 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
35 ctf_enum_value("CPU_OUT_OF_SPEC", 1UL << TAINT_CPU_OUT_OF_SPEC)
36 #else
37 ctf_enum_value("UNSAFE_SMP", 1UL << TAINT_UNSAFE_SMP)
38 #endif
39 ctf_enum_value("FORCED_RMMOD", 1UL << TAINT_FORCED_RMMOD)
40 ctf_enum_value("MACHINE_CHECK", 1UL << TAINT_MACHINE_CHECK)
41 ctf_enum_value("BAD_PAGE", 1UL << TAINT_BAD_PAGE)
42 ctf_enum_value("USER", 1UL << TAINT_USER)
43 ctf_enum_value("DIE", 1UL << TAINT_DIE)
44 ctf_enum_value("OVERRIDDEN_ACPI_TABLE", 1UL << TAINT_OVERRIDDEN_ACPI_TABLE)
45 ctf_enum_value("WARN", 1UL << TAINT_WARN)
46 ctf_enum_value("CRAP", 1UL << TAINT_CRAP)
47 ctf_enum_value("FIRMWARE_WORKAROUND", 1UL << TAINT_FIRMWARE_WORKAROUND)
48 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
49 ctf_enum_value("OOT_MODULE", 1UL << TAINT_OOT_MODULE)
50 #endif
51 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
52 ctf_enum_value("UNSIGNED_MODULE", 1UL << TAINT_UNSIGNED_MODULE)
53 #endif
54 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
55 ctf_enum_value("SOFTLOCKUP", 1UL << TAINT_SOFTLOCKUP)
56 #endif
57 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0))
58 ctf_enum_value("LIVEPATCH", 1UL << TAINT_LIVEPATCH)
59 #endif
60 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0))
61 ctf_enum_value("AUX", 1UL << TAINT_AUX)
62 #endif
63 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,17,0))
64 ctf_enum_value("RANDSTRUCT", 1UL << TAINT_RANDSTRUCT)
65 #endif
66 )
67 )
68
69 LTTNG_TRACEPOINT_EVENT(module_load,
70
71 TP_PROTO(struct module *mod),
72
73 TP_ARGS(mod),
74
75 TP_FIELDS(
76 ctf_enum(taint, unsigned int, taints, mod->taints)
77 ctf_string(name, mod->name)
78 )
79 )
80
81 LTTNG_TRACEPOINT_EVENT(module_free,
82
83 TP_PROTO(struct module *mod),
84
85 TP_ARGS(mod),
86
87 TP_FIELDS(
88 ctf_string(name, mod->name)
89 )
90 )
91
92 #ifdef CONFIG_MODULE_UNLOAD
93 /* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */
94
95 LTTNG_TRACEPOINT_EVENT_CLASS(module_refcnt,
96
97 TP_PROTO(struct module *mod, unsigned long ip),
98
99 TP_ARGS(mod, ip),
100
101 TP_FIELDS(
102 ctf_integer_hex(unsigned long, ip, ip)
103 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0))
104 ctf_integer(int, refcnt, atomic_read(&mod->refcnt))
105 #else
106 ctf_integer(int, refcnt, __this_cpu_read(mod->refptr->incs) + __this_cpu_read(mod->refptr->decs))
107 #endif
108 ctf_string(name, mod->name)
109 )
110 )
111
112 LTTNG_TRACEPOINT_EVENT_INSTANCE(module_refcnt, module_get,
113
114 TP_PROTO(struct module *mod, unsigned long ip),
115
116 TP_ARGS(mod, ip)
117 )
118
119 LTTNG_TRACEPOINT_EVENT_INSTANCE(module_refcnt, module_put,
120
121 TP_PROTO(struct module *mod, unsigned long ip),
122
123 TP_ARGS(mod, ip)
124 )
125 #endif /* CONFIG_MODULE_UNLOAD */
126
127 LTTNG_TRACEPOINT_EVENT(module_request,
128
129 TP_PROTO(char *name, bool wait, unsigned long ip),
130
131 TP_ARGS(name, wait, ip),
132
133 TP_FIELDS(
134 ctf_integer_hex(unsigned long, ip, ip)
135 ctf_integer(bool, wait, wait)
136 ctf_string(name, name)
137 )
138 )
139
140 #endif /* CONFIG_MODULES */
141
142 #endif /* LTTNG_TRACE_MODULE_H */
143
144 /* This part must be outside protection */
145 #include <lttng/define_trace.h>
This page took 0.034363 seconds and 4 git commands to generate.