module_load: change `taints` field to `ctf_enum`
[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 ctf_enum_value("CPU_OUT_OF_SPEC", 1UL << TAINT_CPU_OUT_OF_SPEC)
35 ctf_enum_value("FORCED_RMMOD", 1UL << TAINT_FORCED_RMMOD)
36 ctf_enum_value("MACHINE_CHECK", 1UL << TAINT_MACHINE_CHECK)
37 ctf_enum_value("BAD_PAGE", 1UL << TAINT_BAD_PAGE)
38 ctf_enum_value("USER", 1UL << TAINT_USER)
39 ctf_enum_value("DIE", 1UL << TAINT_DIE)
40 ctf_enum_value("OVERRIDDEN_ACPI_TABLE", 1UL << TAINT_OVERRIDDEN_ACPI_TABLE)
41 ctf_enum_value("WARN", 1UL << TAINT_WARN)
42 ctf_enum_value("CRAP", 1UL << TAINT_CRAP)
43 ctf_enum_value("FIRMWARE_WORKAROUND", 1UL << TAINT_FIRMWARE_WORKAROUND)
44 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
45 ctf_enum_value("OOT_MODULE", 1UL << TAINT_OOT_MODULE)
46 #endif
47 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
48 ctf_enum_value("UNSIGNED_MODULE", 1UL << TAINT_UNSIGNED_MODULE)
49 #endif
50 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
51 ctf_enum_value("SOFTLOCKUP", 1UL << TAINT_SOFTLOCKUP)
52 #endif
53 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0))
54 ctf_enum_value("LIVEPATCH", 1UL << TAINT_LIVEPATCH)
55 #endif
56 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0))
57 ctf_enum_value("AUX", 1UL << TAINT_AUX)
58 #endif
59 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,17,0))
60 ctf_enum_value("RANDSTRUCT", 1UL << TAINT_RANDSTRUCT)
61 #endif
62 )
63 )
64
65 LTTNG_TRACEPOINT_EVENT(module_load,
66
67 TP_PROTO(struct module *mod),
68
69 TP_ARGS(mod),
70
71 TP_FIELDS(
72 ctf_enum(taint, unsigned int, taints, mod->taints)
73 ctf_string(name, mod->name)
74 )
75 )
76
77 LTTNG_TRACEPOINT_EVENT(module_free,
78
79 TP_PROTO(struct module *mod),
80
81 TP_ARGS(mod),
82
83 TP_FIELDS(
84 ctf_string(name, mod->name)
85 )
86 )
87
88 #ifdef CONFIG_MODULE_UNLOAD
89 /* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */
90
91 LTTNG_TRACEPOINT_EVENT_CLASS(module_refcnt,
92
93 TP_PROTO(struct module *mod, unsigned long ip),
94
95 TP_ARGS(mod, ip),
96
97 TP_FIELDS(
98 ctf_integer_hex(unsigned long, ip, ip)
99 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0))
100 ctf_integer(int, refcnt, atomic_read(&mod->refcnt))
101 #else
102 ctf_integer(int, refcnt, __this_cpu_read(mod->refptr->incs) + __this_cpu_read(mod->refptr->decs))
103 #endif
104 ctf_string(name, mod->name)
105 )
106 )
107
108 LTTNG_TRACEPOINT_EVENT_INSTANCE(module_refcnt, module_get,
109
110 TP_PROTO(struct module *mod, unsigned long ip),
111
112 TP_ARGS(mod, ip)
113 )
114
115 LTTNG_TRACEPOINT_EVENT_INSTANCE(module_refcnt, module_put,
116
117 TP_PROTO(struct module *mod, unsigned long ip),
118
119 TP_ARGS(mod, ip)
120 )
121 #endif /* CONFIG_MODULE_UNLOAD */
122
123 LTTNG_TRACEPOINT_EVENT(module_request,
124
125 TP_PROTO(char *name, bool wait, unsigned long ip),
126
127 TP_ARGS(name, wait, ip),
128
129 TP_FIELDS(
130 ctf_integer_hex(unsigned long, ip, ip)
131 ctf_integer(bool, wait, wait)
132 ctf_string(name, name)
133 )
134 )
135
136 #endif /* CONFIG_MODULES */
137
138 #endif /* LTTNG_TRACE_MODULE_H */
139
140 /* This part must be outside protection */
141 #include <lttng/define_trace.h>
This page took 0.032416 seconds and 4 git commands to generate.