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>
31 #include "immediate.h"
32 #include "kernelcompat.h"
38 const char *name
; /* Tracepoint name */
39 DEFINE_IMV(char, state
); /* State. */
41 } __attribute__((aligned(32))); /*
42 * Aligned on 32 bytes because it is
43 * globally visible and gcc happily
44 * align these on the structure size.
45 * Keep in sync with vmlinux.lds.h.
48 #define TPPROTO(args...) args
49 #define TPARGS(args...) args
51 //ust// #ifdef CONFIG_TRACEPOINTS
54 * it_func[0] is never NULL because there is at least one element in the array
55 * when the array itself is non NULL.
57 #define __DO_TRACE(tp, proto, args) \
61 rcu_read_lock_sched_notrace(); \
62 it_func = rcu_dereference((tp)->funcs); \
65 ((void(*)(proto))(*it_func))(args); \
66 } while (*(++it_func)); \
68 rcu_read_unlock_sched_notrace(); \
71 #define __CHECK_TRACE(name, generic, proto, args) \
74 if (unlikely(imv_read(__tracepoint_##name.state))) \
75 __DO_TRACE(&__tracepoint_##name, \
76 TPPROTO(proto), TPARGS(args)); \
78 if (unlikely(_imv_read(__tracepoint_##name.state))) \
79 __DO_TRACE(&__tracepoint_##name, \
80 TPPROTO(proto), TPARGS(args)); \
85 * Make sure the alignment of the structure in the __tracepoints section will
86 * not add unwanted padding between the beginning of the section and the
87 * structure. Force alignment to the same alignment as the section start.
89 * The "generic" argument, passed to the declared __trace_##name inline
90 * function controls which tracepoint enabling mechanism must be used.
91 * If generic is true, a variable read is used.
92 * If generic is false, immediate values are used.
94 #define DECLARE_TRACE(name, proto, args) \
95 extern struct tracepoint __tracepoint_##name; \
96 static inline void trace_##name(proto) \
98 __CHECK_TRACE(name, 0, TPPROTO(proto), TPARGS(args)); \
100 static inline void _trace_##name(proto) \
102 __CHECK_TRACE(name, 1, TPPROTO(proto), TPARGS(args)); \
104 static inline int register_trace_##name(void (*probe)(proto)) \
106 return tracepoint_probe_register(#name, (void *)probe); \
108 static inline int unregister_trace_##name(void (*probe)(proto)) \
110 return tracepoint_probe_unregister(#name, (void *)probe);\
113 #define DEFINE_TRACE(name) \
114 static const char __tpstrtab_##name[] \
115 __attribute__((section("__tracepoints_strings"))) = #name; \
116 struct tracepoint __tracepoint_##name \
117 __attribute__((section("__tracepoints"), aligned(32))) = \
118 { __tpstrtab_##name, 0, NULL }
120 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name) \
121 EXPORT_SYMBOL_GPL(__tracepoint_##name)
122 #define EXPORT_TRACEPOINT_SYMBOL(name) \
123 EXPORT_SYMBOL(__tracepoint_##name)
125 extern void tracepoint_update_probe_range(struct tracepoint
*begin
,
126 struct tracepoint
*end
);
128 //ust// #else /* !CONFIG_TRACEPOINTS */
129 //ust// #define DECLARE_TRACE(name, proto, args) \
130 //ust// static inline void trace_##name(proto) \
132 //ust// static inline void _trace_##name(proto) \
134 //ust// static inline int register_trace_##name(void (*probe)(proto)) \
136 //ust// return -ENOSYS; \
138 //ust// static inline int unregister_trace_##name(void (*probe)(proto)) \
140 //ust// return -ENOSYS; \
143 //ust// #define DEFINE_TRACE(name)
144 //ust// #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
145 //ust// #define EXPORT_TRACEPOINT_SYMBOL(name)
147 //ust// static inline void tracepoint_update_probe_range(struct tracepoint *begin,
148 //ust// struct tracepoint *end)
150 //ust// #endif /* CONFIG_TRACEPOINTS */
153 * Connect a probe to a tracepoint.
154 * Internal API, should not be used directly.
156 extern int tracepoint_probe_register(const char *name
, void *probe
);
159 * Disconnect a probe from a tracepoint.
160 * Internal API, should not be used directly.
162 extern int tracepoint_probe_unregister(const char *name
, void *probe
);
164 extern int tracepoint_probe_register_noupdate(const char *name
, void *probe
);
165 extern int tracepoint_probe_unregister_noupdate(const char *name
, void *probe
);
166 extern void tracepoint_probe_update_all(void);
168 struct tracepoint_iter
{
169 //ust// struct module *module;
170 struct tracepoint_lib
*lib
;
171 struct tracepoint
*tracepoint
;
174 extern void tracepoint_iter_start(struct tracepoint_iter
*iter
);
175 extern void tracepoint_iter_next(struct tracepoint_iter
*iter
);
176 extern void tracepoint_iter_stop(struct tracepoint_iter
*iter
);
177 extern void tracepoint_iter_reset(struct tracepoint_iter
*iter
);
178 extern int tracepoint_get_iter_range(struct tracepoint
**tracepoint
,
179 struct tracepoint
*begin
, struct tracepoint
*end
);
182 * tracepoint_synchronize_unregister must be called between the last tracepoint
183 * probe unregistration and the end of module exit to make sure there is no
184 * caller executing a probe when it is freed.
186 static inline void tracepoint_synchronize_unregister(void)
191 struct tracepoint_lib
{
192 struct tracepoint
*tracepoints_start
;
193 int tracepoints_count
;
194 struct list_head list
;
197 #define TRACEPOINT_LIB \
198 extern struct tracepoint __start___tracepoints[] __attribute__((visibility("hidden"))); \
199 extern struct tracepoint __stop___tracepoints[] __attribute__((visibility("hidden"))); \
201 static void __attribute__((constructor)) __tracepoints__init(void) \
203 tracepoint_register_lib(__start___tracepoints, (((long)__stop___tracepoints)-((long)__start___tracepoints))/sizeof(struct tracepoint));\
This page took 0.033131 seconds and 4 git commands to generate.