fix: tracepoint: Optimize using static_call() (v5.10)
[lttng-modules.git] / wrapper / tracepoint.h
CommitLineData
9f36eaed
MJ
1/* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
2 *
3a523f5b
MD
3 * wrapper/tracepoint.h
4 *
5 * wrapper around DECLARE_EVENT_CLASS.
6 *
7 * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3a523f5b
MD
8 */
9
9f36eaed
MJ
10#ifndef _LTTNG_WRAPPER_TRACEPOINT_H
11#define _LTTNG_WRAPPER_TRACEPOINT_H
12
3a523f5b
MD
13#include <linux/version.h>
14#include <linux/tracepoint.h>
dd8d5afb 15#include <linux/module.h>
3a523f5b
MD
16
17#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
18
19#define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print)
20
21#endif
22
c6b31b34
MJ
23#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,10,0))
24#define LTTNG_DEFINE_TRACE(name, proto, args) \
25 DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
26#else
27#define LTTNG_DEFINE_TRACE(name, proto, args) \
28 DEFINE_TRACE(name)
29#endif
30
3a523f5b
MD
31#ifndef HAVE_KABI_2635_TRACEPOINT
32
33#define kabi_2635_tracepoint_probe_register tracepoint_probe_register
34#define kabi_2635_tracepoint_probe_unregister tracepoint_probe_unregister
3a523f5b
MD
35
36#endif /* HAVE_KABI_2635_TRACEPOINT */
37
20591cf7
MD
38#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
39
5a2f5e92 40#include <lttng-tracepoint.h>
20591cf7
MD
41
42#define lttng_wrapper_tracepoint_probe_register lttng_tracepoint_probe_register
43#define lttng_wrapper_tracepoint_probe_unregister lttng_tracepoint_probe_unregister
44
45#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
46
47#define lttng_wrapper_tracepoint_probe_register kabi_2635_tracepoint_probe_register
48#define lttng_wrapper_tracepoint_probe_unregister kabi_2635_tracepoint_probe_unregister
49
50static inline
51int lttng_tracepoint_init(void)
52{
53 return 0;
54}
55
56static inline
57void lttng_tracepoint_exit(void)
58{
59}
60
61#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
62
7dd4e3c5 63#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG))
dd8d5afb
MD
64
65#include <linux/kallsyms.h>
5a2f5e92 66#include <wrapper/kallsyms.h>
dd8d5afb
MD
67
68static inline
69int wrapper_tracepoint_module_notify(struct notifier_block *nb,
70 unsigned long val, struct module *mod)
71{
72 int (*tracepoint_module_notify_sym)(struct notifier_block *nb,
73 unsigned long val, struct module *mod);
74
75 tracepoint_module_notify_sym =
76 (void *) kallsyms_lookup_funcptr("tracepoint_module_notify");
77 if (tracepoint_module_notify_sym) {
78 return tracepoint_module_notify_sym(nb, val, mod);
79 } else {
e36de50d 80 printk_once(KERN_WARNING "LTTng: tracepoint_module_notify symbol lookup failed. It probably means you kernel don't need this work-around. Please consider upgrading LTTng modules to make this warning go away.\n");
dd8d5afb
MD
81 return -ENOSYS;
82 }
83}
84
9e52289b
MJ
85/*
86 * No canary for 'tracepoint_module_notify()', it's only defined in 'kernel/tracepoint.c'.
87 *
88 * static inline
89 * int __canary__tracepoint_module_notify(struct notifier_block *nb,
90 * unsigned long val, struct module *mod)
91 * {
92 * return tracepoint_module_notify(nb, val, mod);
93 * }
94 */
95
7dd4e3c5 96#endif /* #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG)) */
0147ae64 97
7dd4e3c5 98#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE))
0147ae64 99
dd8d5afb
MD
100static inline
101int wrapper_lttng_fixup_sig(struct module *mod)
102{
103 int ret = 0;
104
105 /*
106 * This is for module.c confusing force loaded modules with
107 * unsigned modules.
108 */
109 if (!THIS_MODULE->sig_ok &&
110 THIS_MODULE->taints & (1U << TAINT_FORCED_MODULE)) {
111 THIS_MODULE->taints &= ~(1U << TAINT_FORCED_MODULE);
112 ret = wrapper_tracepoint_module_notify(NULL,
113 MODULE_STATE_COMING, mod);
114 THIS_MODULE->taints |= (1U << TAINT_FORCED_MODULE);
115 }
116 return ret;
117}
118
7dd4e3c5 119#else /* #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) */
dd8d5afb
MD
120
121static inline
122int wrapper_lttng_fixup_sig(struct module *mod)
123{
124 return 0;
125}
126
7dd4e3c5 127#endif /* #else #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) */
dd8d5afb 128
dd49a655
MD
129#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0))
130static inline struct tracepoint *lttng_tracepoint_ptr_deref(tracepoint_ptr_t *p)
131{
132 return tracepoint_ptr_deref(p);
133}
134#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)) */
80265be2 135static inline struct tracepoint *lttng_tracepoint_ptr_deref(struct tracepoint * const *p)
dd49a655
MD
136{
137 return *p;
138}
139#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)) */
140
3a523f5b 141#endif /* _LTTNG_WRAPPER_TRACEPOINT_H */
This page took 0.043583 seconds and 4 git commands to generate.