Fix: module instrumentation: update to 3.15 kernel
[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
b283666f
PW
26#endif
27
28TRACE_EVENT(module_load,
29
30 TP_PROTO(struct module *mod),
31
32 TP_ARGS(mod),
33
34 TP_STRUCT__entry(
35 __field( unsigned int, taints )
36 __string( name, mod->name )
37 ),
38
39 TP_fast_assign(
d3ac4d63
PW
40 tp_assign(taints, mod->taints)
41 tp_strcpy(name, mod->name)
b283666f
PW
42 ),
43
44 TP_printk("%s %s", __get_str(name), show_module_flags(__entry->taints))
45)
46
47TRACE_EVENT(module_free,
48
49 TP_PROTO(struct module *mod),
50
51 TP_ARGS(mod),
52
53 TP_STRUCT__entry(
54 __string( name, mod->name )
55 ),
56
57 TP_fast_assign(
d3ac4d63 58 tp_strcpy(name, mod->name)
b283666f
PW
59 ),
60
61 TP_printk("%s", __get_str(name))
62)
63
64#ifdef CONFIG_MODULE_UNLOAD
65/* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */
66
67DECLARE_EVENT_CLASS(module_refcnt,
68
7c68b363 69#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
b283666f
PW
70 TP_PROTO(struct module *mod, unsigned long ip),
71
72 TP_ARGS(mod, ip),
7c68b363
AG
73#else
74 TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
75
76 TP_ARGS(mod, ip, refcnt),
77#endif
b283666f
PW
78
79 TP_STRUCT__entry(
80 __field( unsigned long, ip )
81 __field( int, refcnt )
82 __string( name, mod->name )
83 ),
84
85 TP_fast_assign(
d3ac4d63 86 tp_assign(ip, ip)
7c68b363 87#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
d3ac4d63 88 tp_assign(refcnt, __this_cpu_read(mod->refptr->incs) + __this_cpu_read(mod->refptr->decs))
7c68b363
AG
89#else
90 tp_assign(refcnt, refcnt)
91#endif
d3ac4d63 92 tp_strcpy(name, mod->name)
b283666f
PW
93 ),
94
95 TP_printk("%s call_site=%pf refcnt=%d",
96 __get_str(name), (void *)__entry->ip, __entry->refcnt)
97)
98
99DEFINE_EVENT(module_refcnt, module_get,
100
7c68b363 101#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
b283666f
PW
102 TP_PROTO(struct module *mod, unsigned long ip),
103
104 TP_ARGS(mod, ip)
7c68b363
AG
105#else
106 TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
107
108 TP_ARGS(mod, ip, refcnt)
109#endif
b283666f
PW
110)
111
112DEFINE_EVENT(module_refcnt, module_put,
113
7c68b363 114#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
b283666f
PW
115 TP_PROTO(struct module *mod, unsigned long ip),
116
117 TP_ARGS(mod, ip)
7c68b363
AG
118#else
119 TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
120
121 TP_ARGS(mod, ip, refcnt)
122#endif
b283666f
PW
123)
124#endif /* CONFIG_MODULE_UNLOAD */
125
126TRACE_EVENT(module_request,
127
128 TP_PROTO(char *name, bool wait, unsigned long ip),
129
130 TP_ARGS(name, wait, ip),
131
132 TP_STRUCT__entry(
133 __field( unsigned long, ip )
134 __field( bool, wait )
135 __string( name, name )
136 ),
137
138 TP_fast_assign(
d3ac4d63
PW
139 tp_assign(ip, ip)
140 tp_assign(wait, wait)
141 tp_strcpy(name, name)
b283666f
PW
142 ),
143
144 TP_printk("%s wait=%d call_site=%pf",
145 __get_str(name), (int)__entry->wait, (void *)__entry->ip)
146)
147
148#endif /* CONFIG_MODULES */
149
150#endif /* _TRACE_MODULE_H */
151
152/* This part must be outside protection */
153#include "../../../probes/define_trace.h"
This page took 0.032459 seconds and 4 git commands to generate.