Drop support for kernels < 3.0 from module instrumentation
[lttng-modules.git] / instrumentation / events / lttng-module / module.h
CommitLineData
9f36eaed 1/* SPDX-License-Identifier: GPL-2.0 */
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
6ec43db8 18#include <probes/lttng-tracepoint-event.h>
7c68b363 19#include <linux/version.h>
b283666f
PW
20
21#ifdef CONFIG_MODULES
22
23#ifndef _TRACE_MODULE_DEF
24#define _TRACE_MODULE_DEF
25struct module;
26
b283666f
PW
27#endif
28
3bc29f0a 29LTTNG_TRACEPOINT_EVENT(module_load,
b283666f
PW
30
31 TP_PROTO(struct module *mod),
32
33 TP_ARGS(mod),
34
f127e61e
MD
35 TP_FIELDS(
36 ctf_integer(unsigned int, taints, mod->taints)
37 ctf_string(name, mod->name)
38 )
b283666f
PW
39)
40
3bc29f0a 41LTTNG_TRACEPOINT_EVENT(module_free,
b283666f
PW
42
43 TP_PROTO(struct module *mod),
44
45 TP_ARGS(mod),
46
f127e61e
MD
47 TP_FIELDS(
48 ctf_string(name, mod->name)
49 )
b283666f
PW
50)
51
52#ifdef CONFIG_MODULE_UNLOAD
53/* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */
54
3bc29f0a 55LTTNG_TRACEPOINT_EVENT_CLASS(module_refcnt,
b283666f
PW
56
57 TP_PROTO(struct module *mod, unsigned long ip),
58
59 TP_ARGS(mod, ip),
60
f127e61e
MD
61 TP_FIELDS(
62 ctf_integer(unsigned long, ip, ip)
b4feff86 63#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0))
f127e61e 64 ctf_integer(int, refcnt, atomic_read(&mod->refcnt))
7c68b363 65#else
b5e54ced 66 ctf_integer(int, refcnt, __this_cpu_read(mod->refptr->incs) + __this_cpu_read(mod->refptr->decs))
7c68b363 67#endif
f127e61e
MD
68 ctf_string(name, mod->name)
69 )
b283666f
PW
70)
71
3bc29f0a 72LTTNG_TRACEPOINT_EVENT_INSTANCE(module_refcnt, module_get,
b283666f
PW
73
74 TP_PROTO(struct module *mod, unsigned long ip),
75
76 TP_ARGS(mod, ip)
77)
78
3bc29f0a 79LTTNG_TRACEPOINT_EVENT_INSTANCE(module_refcnt, module_put,
b283666f
PW
80
81 TP_PROTO(struct module *mod, unsigned long ip),
82
83 TP_ARGS(mod, ip)
84)
85#endif /* CONFIG_MODULE_UNLOAD */
86
3bc29f0a 87LTTNG_TRACEPOINT_EVENT(module_request,
b283666f
PW
88
89 TP_PROTO(char *name, bool wait, unsigned long ip),
90
91 TP_ARGS(name, wait, ip),
92
f127e61e
MD
93 TP_FIELDS(
94 ctf_integer(unsigned long, ip, ip)
95 ctf_integer(bool, wait, wait)
96 ctf_string(name, name)
97 )
b283666f
PW
98)
99
100#endif /* CONFIG_MODULES */
101
3bc29f0a 102#endif /* LTTNG_TRACE_MODULE_H */
b283666f
PW
103
104/* This part must be outside protection */
6ec43db8 105#include <probes/define_trace.h>
This page took 0.035634 seconds and 4 git commands to generate.