Migrate tracepoint instrumentation to TP_FIELDS
[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
3bc29f0a
MD
14#if !defined(LTTNG_TRACE_MODULE_H) || defined(TRACE_HEADER_MULTI_READ)
15#define LTTNG_TRACE_MODULE_H
b283666f 16
3bc29f0a 17#include "../../../probes/lttng-tracepoint-event.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
3bc29f0a 28LTTNG_TRACEPOINT_EVENT(module_load,
b283666f
PW
29
30 TP_PROTO(struct module *mod),
31
32 TP_ARGS(mod),
33
f127e61e
MD
34 TP_FIELDS(
35 ctf_integer(unsigned int, taints, mod->taints)
36 ctf_string(name, mod->name)
37 )
b283666f
PW
38)
39
3bc29f0a 40LTTNG_TRACEPOINT_EVENT(module_free,
b283666f
PW
41
42 TP_PROTO(struct module *mod),
43
44 TP_ARGS(mod),
45
f127e61e
MD
46 TP_FIELDS(
47 ctf_string(name, mod->name)
48 )
b283666f
PW
49)
50
51#ifdef CONFIG_MODULE_UNLOAD
52/* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */
53
3bc29f0a 54LTTNG_TRACEPOINT_EVENT_CLASS(module_refcnt,
b283666f 55
7c68b363 56#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
b283666f
PW
57 TP_PROTO(struct module *mod, unsigned long ip),
58
59 TP_ARGS(mod, ip),
7c68b363
AG
60#else
61 TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
62
63 TP_ARGS(mod, ip, refcnt),
64#endif
b283666f 65
f127e61e
MD
66 TP_FIELDS(
67 ctf_integer(unsigned long, ip, ip)
b4feff86 68#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0))
f127e61e 69 ctf_integer(int, refcnt, atomic_read(&mod->refcnt))
b4feff86 70#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
f127e61e 71 ctf_integer(int, refcnt, __this_cpu_read(mod->refptr->incs) + __this_cpu_read(mod->refptr->decs))
7c68b363 72#else
f127e61e 73 ctf_integer(int, refcnt, refcnt)
7c68b363 74#endif
f127e61e
MD
75 ctf_string(name, mod->name)
76 )
b283666f
PW
77)
78
3bc29f0a 79LTTNG_TRACEPOINT_EVENT_INSTANCE(module_refcnt, module_get,
b283666f 80
7c68b363 81#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
b283666f
PW
82 TP_PROTO(struct module *mod, unsigned long ip),
83
84 TP_ARGS(mod, ip)
7c68b363
AG
85#else
86 TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
87
88 TP_ARGS(mod, ip, refcnt)
89#endif
b283666f
PW
90)
91
3bc29f0a 92LTTNG_TRACEPOINT_EVENT_INSTANCE(module_refcnt, module_put,
b283666f 93
7c68b363 94#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
b283666f
PW
95 TP_PROTO(struct module *mod, unsigned long ip),
96
97 TP_ARGS(mod, ip)
7c68b363
AG
98#else
99 TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
100
101 TP_ARGS(mod, ip, refcnt)
102#endif
b283666f
PW
103)
104#endif /* CONFIG_MODULE_UNLOAD */
105
3bc29f0a 106LTTNG_TRACEPOINT_EVENT(module_request,
b283666f
PW
107
108 TP_PROTO(char *name, bool wait, unsigned long ip),
109
110 TP_ARGS(name, wait, ip),
111
f127e61e
MD
112 TP_FIELDS(
113 ctf_integer(unsigned long, ip, ip)
114 ctf_integer(bool, wait, wait)
115 ctf_string(name, name)
116 )
b283666f
PW
117)
118
119#endif /* CONFIG_MODULES */
120
3bc29f0a 121#endif /* LTTNG_TRACE_MODULE_H */
b283666f
PW
122
123/* This part must be outside protection */
124#include "../../../probes/define_trace.h"
This page took 0.031231 seconds and 4 git commands to generate.