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 (*regfunc)(void);
27 void (*unregfunc)(void);
28 void **funcs;
29} __attribute__((aligned(32)));
30
31
32
33
34
35
36#ifndef DECLARE_TRACE
37
38#define TP_PROTO(args...) args
39#define TP_ARGS(args...) args
40
41#ifdef CONFIG_TRACEPOINTS
42
43
44
45
46
47#define __DO_TRACE(tp, proto, args) \
48 do { \
49 void **it_func; \
50 \
51 rcu_read_lock_sched_notrace(); \
52 it_func = rcu_dereference_sched((tp)->funcs); \
53 if (it_func) { \
54 do { \
55 ((void(*)(proto))(*it_func))(args); \
56 } while (*(++it_func)); \
57 } \
58 rcu_read_unlock_sched_notrace(); \
59 } while (0)
60
61
62
63
64
65
66#define DECLARE_TRACE(name, proto, args) \
67 extern struct tracepoint __tracepoint_##name; \
68 static inline void trace_##name(proto) \
69 { \
70 if (unlikely(__tracepoint_##name.state)) \
71 __DO_TRACE(&__tracepoint_##name, \
72 TP_PROTO(proto), TP_ARGS(args)); \
73 } \
74 static inline int register_trace_##name(void (*probe)(proto)) \
75 { \
76 return tracepoint_probe_register(#name, (void *)probe); \
77 } \
78 static inline int unregister_trace_##name(void (*probe)(proto)) \
79 { \
80 return tracepoint_probe_unregister(#name, (void *)probe);\
81 }
82
83
84#define DEFINE_TRACE_FN(name, reg, unreg) \
85 static const char __tpstrtab_##name[] \
86 __attribute__((section("__tracepoints_strings"))) = #name; \
87 struct tracepoint __tracepoint_##name \
88 __attribute__((section("__tracepoints"), aligned(32))) = \
89 { __tpstrtab_##name, 0, reg, unreg, NULL }
90
91#define DEFINE_TRACE(name) \
92 DEFINE_TRACE_FN(name, NULL, NULL);
93
94#define EXPORT_TRACEPOINT_SYMBOL_GPL(name) \
95 EXPORT_SYMBOL_GPL(__tracepoint_##name)
96#define EXPORT_TRACEPOINT_SYMBOL(name) \
97 EXPORT_SYMBOL(__tracepoint_##name)
98
99extern void tracepoint_update_probe_range(struct tracepoint *begin,
100 struct tracepoint *end);
101
102#else
103#define DECLARE_TRACE(name, proto, args) \
104 static inline void _do_trace_##name(struct tracepoint *tp, proto) \
105 { } \
106 static inline void trace_##name(proto) \
107 { } \
108 static inline int register_trace_##name(void (*probe)(proto)) \
109 { \
110 return -ENOSYS; \
111 } \
112 static inline int unregister_trace_##name(void (*probe)(proto)) \
113 { \
114 return -ENOSYS; \
115 }
116
117#define DEFINE_TRACE_FN(name, reg, unreg)
118#define DEFINE_TRACE(name)
119#define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
120#define EXPORT_TRACEPOINT_SYMBOL(name)
121
122static inline void tracepoint_update_probe_range(struct tracepoint *begin,
123 struct tracepoint *end)
124{ }
125#endif
126#endif
127
128
129
130
131
132extern int tracepoint_probe_register(const char *name, void *probe);
133
134
135
136
137
138extern int tracepoint_probe_unregister(const char *name, void *probe);
139
140extern int tracepoint_probe_register_noupdate(const char *name, void *probe);
141extern int tracepoint_probe_unregister_noupdate(const char *name, void *probe);
142extern void tracepoint_probe_update_all(void);
143
144struct tracepoint_iter {
145 struct module *module;
146 struct tracepoint *tracepoint;
147};
148
149extern void tracepoint_iter_start(struct tracepoint_iter *iter);
150extern void tracepoint_iter_next(struct tracepoint_iter *iter);
151extern void tracepoint_iter_stop(struct tracepoint_iter *iter);
152extern void tracepoint_iter_reset(struct tracepoint_iter *iter);
153extern int tracepoint_get_iter_range(struct tracepoint **tracepoint,
154 struct tracepoint *begin, struct tracepoint *end);
155
156
157
158
159
160
161static inline void tracepoint_synchronize_unregister(void)
162{
163 synchronize_sched();
164}
165
166#define PARAMS(args...) args
167
168#endif
169
170
171
172
173
174
175
176
177#ifndef TRACE_EVENT
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283#define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print)
284#define DEFINE_EVENT(template, name, proto, args) \
285 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
286#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
287 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
288
289#define TRACE_EVENT(name, proto, args, struct, assign, print) \
290 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
291#define TRACE_EVENT_FN(name, proto, args, struct, \
292 assign, print, reg, unreg) \
293 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
294
295#endif
296