]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
c94fbe1d SR |
2 | /* |
3 | * Because linux/module.h has tracepoints in the header, and ftrace.h | |
de477254 | 4 | * used to include this file, define_trace.h includes linux/module.h |
c94fbe1d SR |
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 | |
7ead8b83 LZ |
11 | #undef TRACE_SYSTEM |
12 | #define TRACE_SYSTEM module | |
c94fbe1d | 13 | #endif |
7ead8b83 LZ |
14 | |
15 | #if !defined(_TRACE_MODULE_H) || defined(TRACE_HEADER_MULTI_READ) | |
16 | #define _TRACE_MODULE_H | |
17 | ||
18 | #include <linux/tracepoint.h> | |
19 | ||
20 | #ifdef CONFIG_MODULES | |
21 | ||
22 | struct module; | |
23 | ||
24 | #define show_module_flags(flags) __print_flags(flags, "", \ | |
25 | { (1UL << TAINT_PROPRIETARY_MODULE), "P" }, \ | |
66cc69e3 | 26 | { (1UL << TAINT_OOT_MODULE), "O" }, \ |
7ead8b83 | 27 | { (1UL << TAINT_FORCED_MODULE), "F" }, \ |
66cc69e3 | 28 | { (1UL << TAINT_CRAP), "C" }, \ |
132e9a68 | 29 | { (1UL << TAINT_UNSIGNED_MODULE), "E" }) |
7ead8b83 LZ |
30 | |
31 | TRACE_EVENT(module_load, | |
32 | ||
33 | TP_PROTO(struct module *mod), | |
34 | ||
35 | TP_ARGS(mod), | |
36 | ||
37 | TP_STRUCT__entry( | |
38 | __field( unsigned int, taints ) | |
39 | __string( name, mod->name ) | |
40 | ), | |
41 | ||
42 | TP_fast_assign( | |
43 | __entry->taints = mod->taints; | |
44 | __assign_str(name, mod->name); | |
45 | ), | |
46 | ||
47 | TP_printk("%s %s", __get_str(name), show_module_flags(__entry->taints)) | |
48 | ); | |
49 | ||
50 | TRACE_EVENT(module_free, | |
51 | ||
52 | TP_PROTO(struct module *mod), | |
53 | ||
54 | TP_ARGS(mod), | |
55 | ||
56 | TP_STRUCT__entry( | |
57 | __string( name, mod->name ) | |
58 | ), | |
59 | ||
60 | TP_fast_assign( | |
61 | __assign_str(name, mod->name); | |
62 | ), | |
63 | ||
64 | TP_printk("%s", __get_str(name)) | |
65 | ); | |
66 | ||
eb0c5377 SR |
67 | #ifdef CONFIG_MODULE_UNLOAD |
68 | /* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */ | |
69 | ||
925684d6 | 70 | DECLARE_EVENT_CLASS(module_refcnt, |
7ead8b83 | 71 | |
ae832d1e | 72 | TP_PROTO(struct module *mod, unsigned long ip), |
7ead8b83 | 73 | |
ae832d1e | 74 | TP_ARGS(mod, ip), |
7ead8b83 LZ |
75 | |
76 | TP_STRUCT__entry( | |
77 | __field( unsigned long, ip ) | |
78 | __field( int, refcnt ) | |
79 | __string( name, mod->name ) | |
80 | ), | |
81 | ||
82 | TP_fast_assign( | |
83 | __entry->ip = ip; | |
2f35c41f | 84 | __entry->refcnt = atomic_read(&mod->refcnt); |
7ead8b83 LZ |
85 | __assign_str(name, mod->name); |
86 | ), | |
87 | ||
bbedb179 | 88 | TP_printk("%s call_site=%ps refcnt=%d", |
7ead8b83 LZ |
89 | __get_str(name), (void *)__entry->ip, __entry->refcnt) |
90 | ); | |
91 | ||
925684d6 | 92 | DEFINE_EVENT(module_refcnt, module_get, |
7ead8b83 | 93 | |
ae832d1e | 94 | TP_PROTO(struct module *mod, unsigned long ip), |
7ead8b83 | 95 | |
ae832d1e | 96 | TP_ARGS(mod, ip) |
925684d6 | 97 | ); |
7ead8b83 | 98 | |
925684d6 | 99 | DEFINE_EVENT(module_refcnt, module_put, |
7ead8b83 | 100 | |
ae832d1e | 101 | TP_PROTO(struct module *mod, unsigned long ip), |
7ead8b83 | 102 | |
ae832d1e | 103 | TP_ARGS(mod, ip) |
7ead8b83 | 104 | ); |
eb0c5377 | 105 | #endif /* CONFIG_MODULE_UNLOAD */ |
7ead8b83 LZ |
106 | |
107 | TRACE_EVENT(module_request, | |
108 | ||
109 | TP_PROTO(char *name, bool wait, unsigned long ip), | |
110 | ||
111 | TP_ARGS(name, wait, ip), | |
112 | ||
113 | TP_STRUCT__entry( | |
7ead8b83 | 114 | __field( unsigned long, ip ) |
b5e3008e | 115 | __field( bool, wait ) |
7ead8b83 LZ |
116 | __string( name, name ) |
117 | ), | |
118 | ||
119 | TP_fast_assign( | |
7ead8b83 | 120 | __entry->ip = ip; |
b5e3008e | 121 | __entry->wait = wait; |
7ead8b83 LZ |
122 | __assign_str(name, name); |
123 | ), | |
124 | ||
bbedb179 | 125 | TP_printk("%s wait=%d call_site=%ps", |
7ead8b83 LZ |
126 | __get_str(name), (int)__entry->wait, (void *)__entry->ip) |
127 | ); | |
128 | ||
129 | #endif /* CONFIG_MODULES */ | |
130 | ||
131 | #endif /* _TRACE_MODULE_H */ | |
132 | ||
133 | /* This part must be outside protection */ | |
134 | #include <trace/define_trace.h> |