Update kernel probes to more detailed match to kernel versions
[lttng-modules.git] / instrumentation / events / lttng-module / module.h
CommitLineData
b283666f
PW
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>
7c68b363 18#include <linux/version.h>
b283666f
PW
19
20#ifdef CONFIG_MODULES
21
22#ifndef _TRACE_MODULE_DEF
23#define _TRACE_MODULE_DEF
24struct 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
32TRACE_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(
d3ac4d63
PW
44 tp_assign(taints, mod->taints)
45 tp_strcpy(name, mod->name)
b283666f
PW
46 ),
47
48 TP_printk("%s %s", __get_str(name), show_module_flags(__entry->taints))
49)
50
51TRACE_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(
d3ac4d63 62 tp_strcpy(name, mod->name)
b283666f
PW
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
71DECLARE_EVENT_CLASS(module_refcnt,
72
7c68b363 73#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
b283666f
PW
74 TP_PROTO(struct module *mod, unsigned long ip),
75
76 TP_ARGS(mod, ip),
7c68b363
AG
77#else
78 TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
79
80 TP_ARGS(mod, ip, refcnt),
81#endif
b283666f
PW
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(
d3ac4d63 90 tp_assign(ip, ip)
7c68b363 91#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
d3ac4d63 92 tp_assign(refcnt, __this_cpu_read(mod->refptr->incs) + __this_cpu_read(mod->refptr->decs))
7c68b363
AG
93#else
94 tp_assign(refcnt, refcnt)
95#endif
d3ac4d63 96 tp_strcpy(name, mod->name)
b283666f
PW
97 ),
98
99 TP_printk("%s call_site=%pf refcnt=%d",
100 __get_str(name), (void *)__entry->ip, __entry->refcnt)
101)
102
103DEFINE_EVENT(module_refcnt, module_get,
104
7c68b363 105#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
b283666f
PW
106 TP_PROTO(struct module *mod, unsigned long ip),
107
108 TP_ARGS(mod, ip)
7c68b363
AG
109#else
110 TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
111
112 TP_ARGS(mod, ip, refcnt)
113#endif
b283666f
PW
114)
115
116DEFINE_EVENT(module_refcnt, module_put,
117
7c68b363 118#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
b283666f
PW
119 TP_PROTO(struct module *mod, unsigned long ip),
120
121 TP_ARGS(mod, ip)
7c68b363
AG
122#else
123 TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
124
125 TP_ARGS(mod, ip, refcnt)
126#endif
b283666f
PW
127)
128#endif /* CONFIG_MODULE_UNLOAD */
129
130TRACE_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(
d3ac4d63
PW
143 tp_assign(ip, ip)
144 tp_assign(wait, wait)
145 tp_strcpy(name, name)
b283666f
PW
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.028668 seconds and 4 git commands to generate.