1#ifndef _LINUX_TRACEPOINT_H
2#define _LINUX_TRACEPOINT_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#include <linux/types.h>
18#include <linux/rcupdate.h>
19
20struct module;
21struct tracepoint;
22
23struct tracepoint {
24 const char *name;
25 int state;
26 void **funcs;
27} __attribute__((aligned(32)));
28
29
30
31
32
33
34#define TP_PROTO(args...) args
35#define TP_ARGS(args...) args
36
37#ifdef CONFIG_TRACEPOINTS
38
39
40
41
42
43#define __DO_TRACE(tp, proto, args) \
44 do { \
45 void **it_func; \
46 \
47 rcu_read_lock_sched_notrace(); \
48 it_func = rcu_dereference((tp)->funcs); \
49 if (it_func) { \
50 do { \
51 ((void(*)(proto))(*it_func))(args); \
52 } while (*(++it_func)); \
53 } \
54 rcu_read_unlock_sched_notrace(); \
55 } while (0)
56
57
58
59
60
61
62#define DECLARE_TRACE(name, proto, args) \
63 extern struct tracepoint __tracepoint_##name; \
64 static inline void trace_##name(proto) \
65 { \
66 if (unlikely(__tracepoint_##name.state)) \
67 __DO_TRACE(&__tracepoint_##name, \
68 TP_PROTO(proto), TP_ARGS(args)); \
69 } \
70 static inline int register_trace_##name(void (*probe)(proto)) \
71 { \
72 return tracepoint_probe_register(#name, (void *)probe); \
73 } \
74 static inline int unregister_trace_##name(void (*probe)(proto)) \
75 { \
76 return tracepoint_probe_unregister(#name, (void *)probe);\
77 }
78
79#define DEFINE_TRACE(name) \
80 static const char __tpstrtab_##name[] \
81 __attribute__((section("__tracepoints_strings"))) = #name; \
82 struct tracepoint __tracepoint_##name \
83 __attribute__((section("__tracepoints"), aligned(32))) = \
84 { __tpstrtab_##name, 0, NULL }
85
86#define EXPORT_TRACEPOINT_SYMBOL_GPL(name) \
87 EXPORT_SYMBOL_GPL(__tracepoint_##name)
88#define EXPORT_TRACEPOINT_SYMBOL(name) \
89 EXPORT_SYMBOL(__tracepoint_##name)
90
91extern void tracepoint_update_probe_range(struct tracepoint *begin,
92 struct tracepoint *end);
93
94#else
95#define DECLARE_TRACE(name, proto, args) \
96 static inline void _do_trace_##name(struct tracepoint *tp, proto) \
97 { } \
98 static inline void trace_##name(proto) \
99 { } \
100 static inline int register_trace_##name(void (*probe)(proto)) \
101 { \
102 return -ENOSYS; \
103 } \
104 static inline int unregister_trace_##name(void (*probe)(proto)) \
105 { \
106 return -ENOSYS; \
107 }
108
109#define DEFINE_TRACE(name)
110#define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
111#define EXPORT_TRACEPOINT_SYMBOL(name)
112
113static inline void tracepoint_update_probe_range(struct tracepoint *begin,
114 struct tracepoint *end)
115{ }
116#endif
117
118
119
120
121
122extern int tracepoint_probe_register(const char *name, void *probe);
123
124
125
126
127
128extern int tracepoint_probe_unregister(const char *name, void *probe);
129
130extern int tracepoint_probe_register_noupdate(const char *name, void *probe);
131extern int tracepoint_probe_unregister_noupdate(const char *name, void *probe);
132extern void tracepoint_probe_update_all(void);
133
134struct tracepoint_iter {
135 struct module *module;
136 struct tracepoint *tracepoint;
137};
138
139extern void tracepoint_iter_start(struct tracepoint_iter *iter);
140extern void tracepoint_iter_next(struct tracepoint_iter *iter);
141extern void tracepoint_iter_stop(struct tracepoint_iter *iter);
142extern void tracepoint_iter_reset(struct tracepoint_iter *iter);
143extern int tracepoint_get_iter_range(struct tracepoint **tracepoint,
144 struct tracepoint *begin, struct tracepoint *end);
145
146
147
148
149
150
151static inline void tracepoint_synchronize_unregister(void)
152{
153 synchronize_sched();
154}
155
156#define PARAMS(args...) args
157#define TRACE_FORMAT(name, proto, args, fmt) \
158 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263#define TRACE_EVENT(name, proto, args, struct, assign, print) \
264 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
265
266#endif
267