1 #ifndef _LINUX_TRACEPOINT_H
2 #define _LINUX_TRACEPOINT_H
5 * Copyright (C) 2008 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
6 * Copyright (C) 2009 Pierre-Marc Fournier
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * Heavily inspired from the Linux Kernel Markers.
24 * Ported to userspace by Pierre-Marc Fournier.
27 //#include <linux/immediate.h>
28 //#include <linux/types.h>
29 //#include <linux/rcupdate.h>
34 #include "immediate.h"
35 #include "kernelcompat.h"
41 const char *name
; /* Tracepoint name */
42 DEFINE_IMV(char, state
); /* State. */
44 } __attribute__((aligned(32))); /*
45 * Aligned on 32 bytes because it is
46 * globally visible and gcc happily
47 * align these on the structure size.
48 * Keep in sync with vmlinux.lds.h.
51 #define TPPROTO(args...) args
52 #define TPARGS(args...) args
54 #define CONFIG_TRACEPOINTS
55 #ifdef CONFIG_TRACEPOINTS
58 * it_func[0] is never NULL because there is at least one element in the array
59 * when the array itself is non NULL.
61 #define __DO_TRACE(tp, proto, args) \
65 rcu_read_lock(); /*ust rcu_read_lock_sched_notrace(); */ \
66 it_func = rcu_dereference((tp)->funcs); \
69 ((void(*)(proto))(*it_func))(args); \
70 } while (*(++it_func)); \
72 rcu_read_unlock(); /*ust rcu_read_unlock_sched_notrace(); */ \
75 #define __CHECK_TRACE(name, generic, proto, args) \
78 if (unlikely(imv_read(__tracepoint_##name.state))) \
79 __DO_TRACE(&__tracepoint_##name, \
80 TPPROTO(proto), TPARGS(args)); \
82 if (unlikely(_imv_read(__tracepoint_##name.state))) \
83 __DO_TRACE(&__tracepoint_##name, \
84 TPPROTO(proto), TPARGS(args)); \
89 * Make sure the alignment of the structure in the __tracepoints section will
90 * not add unwanted padding between the beginning of the section and the
91 * structure. Force alignment to the same alignment as the section start.
93 * The "generic" argument, passed to the declared __trace_##name inline
94 * function controls which tracepoint enabling mechanism must be used.
95 * If generic is true, a variable read is used.
96 * If generic is false, immediate values are used.
98 #define DECLARE_TRACE(name, proto, args) \
99 extern struct tracepoint __tracepoint_##name; \
100 static inline void trace_##name(proto) \
102 __CHECK_TRACE(name, 0, TPPROTO(proto), TPARGS(args)); \
104 static inline void _trace_##name(proto) \
106 __CHECK_TRACE(name, 1, TPPROTO(proto), TPARGS(args)); \
108 static inline int register_trace_##name(void (*probe)(proto)) \
110 return tracepoint_probe_register(#name, (void *)probe); \
112 static inline int unregister_trace_##name(void (*probe)(proto)) \
114 return tracepoint_probe_unregister(#name, (void *)probe);\
117 #define DEFINE_TRACE(name) \
118 static const char __tpstrtab_##name[] \
119 __attribute__((section("__tracepoints_strings"))) = #name; \
120 struct tracepoint __tracepoint_##name \
121 __attribute__((section("__tracepoints"), aligned(32))) = \
122 { __tpstrtab_##name, 0, NULL }
124 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name) \
125 EXPORT_SYMBOL_GPL(__tracepoint_##name)
126 #define EXPORT_TRACEPOINT_SYMBOL(name) \
127 EXPORT_SYMBOL(__tracepoint_##name)
129 extern void tracepoint_update_probe_range(struct tracepoint
*begin
,
130 struct tracepoint
*end
);
132 #else /* !CONFIG_TRACEPOINTS */
133 #define DECLARE_TRACE(name, proto, args) \
134 static inline void trace_##name(proto) \
136 static inline void _trace_##name(proto) \
138 static inline int register_trace_##name(void (*probe)(proto)) \
142 static inline int unregister_trace_##name(void (*probe)(proto)) \
147 #define DEFINE_TRACE(name)
148 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
149 #define EXPORT_TRACEPOINT_SYMBOL(name)
151 static inline void tracepoint_update_probe_range(struct tracepoint
*begin
,
152 struct tracepoint
*end
)
154 #endif /* CONFIG_TRACEPOINTS */
157 * Connect a probe to a tracepoint.
158 * Internal API, should not be used directly.
160 extern int tracepoint_probe_register(const char *name
, void *probe
);
163 * Disconnect a probe from a tracepoint.
164 * Internal API, should not be used directly.
166 extern int tracepoint_probe_unregister(const char *name
, void *probe
);
168 extern int tracepoint_probe_register_noupdate(const char *name
, void *probe
);
169 extern int tracepoint_probe_unregister_noupdate(const char *name
, void *probe
);
170 extern void tracepoint_probe_update_all(void);
172 struct tracepoint_iter
{
173 //ust// struct module *module;
174 struct tracepoint_lib
*lib
;
175 struct tracepoint
*tracepoint
;
178 extern void tracepoint_iter_start(struct tracepoint_iter
*iter
);
179 extern void tracepoint_iter_next(struct tracepoint_iter
*iter
);
180 extern void tracepoint_iter_stop(struct tracepoint_iter
*iter
);
181 extern void tracepoint_iter_reset(struct tracepoint_iter
*iter
);
182 extern int tracepoint_get_iter_range(struct tracepoint
**tracepoint
,
183 struct tracepoint
*begin
, struct tracepoint
*end
);
186 * tracepoint_synchronize_unregister must be called between the last tracepoint
187 * probe unregistration and the end of module exit to make sure there is no
188 * caller executing a probe when it is freed.
190 static inline void tracepoint_synchronize_unregister(void)
195 struct tracepoint_lib
{
196 struct tracepoint
*tracepoints_start
;
197 int tracepoints_count
;
198 struct list_head list
;
201 extern int tracepoint_register_lib(struct tracepoint
*tracepoints_start
,
202 int tracepoints_count
);
204 #define TRACEPOINT_LIB \
205 extern struct tracepoint __start___tracepoints[] __attribute__((visibility("hidden"))); \
206 extern struct tracepoint __stop___tracepoints[] __attribute__((visibility("hidden"))); \
207 static void __attribute__((constructor)) __tracepoints__init(void) \
209 tracepoint_register_lib(__start___tracepoints, \
210 (((long)__stop___tracepoints)-((long)__start___tracepoints))/sizeof(struct tracepoint)); \
This page took 0.033593 seconds and 4 git commands to generate.