Commit | Line | Data |
---|---|---|
b7cdc182 | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
b283666f PW |
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 | ||
3bc29f0a MD |
15 | #if !defined(LTTNG_TRACE_MODULE_H) || defined(TRACE_HEADER_MULTI_READ) |
16 | #define LTTNG_TRACE_MODULE_H | |
b283666f | 17 | |
3b4aafcb | 18 | #include <lttng/tracepoint-event.h> |
5f4c791e | 19 | #include <lttng/kernel-version.h> |
5f1c794b | 20 | #include <linux/kernel.h> |
b283666f PW |
21 | |
22 | #ifdef CONFIG_MODULES | |
23 | ||
24 | #ifndef _TRACE_MODULE_DEF | |
25 | #define _TRACE_MODULE_DEF | |
26 | struct module; | |
27 | ||
b283666f PW |
28 | #endif |
29 | ||
5f1c794b FD |
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) | |
5f4c791e | 34 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,15,0)) |
5f1c794b | 35 | ctf_enum_value("CPU_OUT_OF_SPEC", 1UL << TAINT_CPU_OUT_OF_SPEC) |
0e561dbf MJ |
36 | #else |
37 | ctf_enum_value("UNSAFE_SMP", 1UL << TAINT_UNSAFE_SMP) | |
38 | #endif | |
5f1c794b FD |
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) | |
5f4c791e | 48 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,2,0)) |
5f1c794b FD |
49 | ctf_enum_value("OOT_MODULE", 1UL << TAINT_OOT_MODULE) |
50 | #endif | |
5f4c791e | 51 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,15,0)) |
5f1c794b FD |
52 | ctf_enum_value("UNSIGNED_MODULE", 1UL << TAINT_UNSIGNED_MODULE) |
53 | #endif | |
5f4c791e | 54 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,17,0)) |
5f1c794b FD |
55 | ctf_enum_value("SOFTLOCKUP", 1UL << TAINT_SOFTLOCKUP) |
56 | #endif | |
5f4c791e | 57 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,0,0)) |
5f1c794b FD |
58 | ctf_enum_value("LIVEPATCH", 1UL << TAINT_LIVEPATCH) |
59 | #endif | |
5f4c791e | 60 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,15,0)) |
5f1c794b FD |
61 | ctf_enum_value("AUX", 1UL << TAINT_AUX) |
62 | #endif | |
5f4c791e | 63 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,17,0)) |
5f1c794b FD |
64 | ctf_enum_value("RANDSTRUCT", 1UL << TAINT_RANDSTRUCT) |
65 | #endif | |
66 | ) | |
67 | ) | |
68 | ||
3bc29f0a | 69 | LTTNG_TRACEPOINT_EVENT(module_load, |
b283666f PW |
70 | |
71 | TP_PROTO(struct module *mod), | |
72 | ||
73 | TP_ARGS(mod), | |
74 | ||
f127e61e | 75 | TP_FIELDS( |
5f1c794b | 76 | ctf_enum(taint, unsigned int, taints, mod->taints) |
f127e61e MD |
77 | ctf_string(name, mod->name) |
78 | ) | |
b283666f PW |
79 | ) |
80 | ||
3bc29f0a | 81 | LTTNG_TRACEPOINT_EVENT(module_free, |
b283666f PW |
82 | |
83 | TP_PROTO(struct module *mod), | |
84 | ||
85 | TP_ARGS(mod), | |
86 | ||
f127e61e MD |
87 | TP_FIELDS( |
88 | ctf_string(name, mod->name) | |
89 | ) | |
b283666f PW |
90 | ) |
91 | ||
92 | #ifdef CONFIG_MODULE_UNLOAD | |
93 | /* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */ | |
94 | ||
3bc29f0a | 95 | LTTNG_TRACEPOINT_EVENT_CLASS(module_refcnt, |
b283666f PW |
96 | |
97 | TP_PROTO(struct module *mod, unsigned long ip), | |
98 | ||
99 | TP_ARGS(mod, ip), | |
100 | ||
f127e61e | 101 | TP_FIELDS( |
2c054599 | 102 | ctf_integer_hex(unsigned long, ip, ip) |
5f4c791e | 103 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,19,0)) |
f127e61e | 104 | ctf_integer(int, refcnt, atomic_read(&mod->refcnt)) |
7c68b363 | 105 | #else |
b5e54ced | 106 | ctf_integer(int, refcnt, __this_cpu_read(mod->refptr->incs) + __this_cpu_read(mod->refptr->decs)) |
7c68b363 | 107 | #endif |
f127e61e MD |
108 | ctf_string(name, mod->name) |
109 | ) | |
b283666f PW |
110 | ) |
111 | ||
3bc29f0a | 112 | LTTNG_TRACEPOINT_EVENT_INSTANCE(module_refcnt, module_get, |
b283666f PW |
113 | |
114 | TP_PROTO(struct module *mod, unsigned long ip), | |
115 | ||
116 | TP_ARGS(mod, ip) | |
117 | ) | |
118 | ||
3bc29f0a | 119 | LTTNG_TRACEPOINT_EVENT_INSTANCE(module_refcnt, module_put, |
b283666f PW |
120 | |
121 | TP_PROTO(struct module *mod, unsigned long ip), | |
122 | ||
123 | TP_ARGS(mod, ip) | |
124 | ) | |
125 | #endif /* CONFIG_MODULE_UNLOAD */ | |
126 | ||
3bc29f0a | 127 | LTTNG_TRACEPOINT_EVENT(module_request, |
b283666f PW |
128 | |
129 | TP_PROTO(char *name, bool wait, unsigned long ip), | |
130 | ||
131 | TP_ARGS(name, wait, ip), | |
132 | ||
f127e61e | 133 | TP_FIELDS( |
2c054599 | 134 | ctf_integer_hex(unsigned long, ip, ip) |
f127e61e MD |
135 | ctf_integer(bool, wait, wait) |
136 | ctf_string(name, name) | |
137 | ) | |
b283666f PW |
138 | ) |
139 | ||
140 | #endif /* CONFIG_MODULES */ | |
141 | ||
3bc29f0a | 142 | #endif /* LTTNG_TRACE_MODULE_H */ |
b283666f PW |
143 | |
144 | /* This part must be outside protection */ | |
3b4aafcb | 145 | #include <lttng/define_trace.h> |