1 #ifndef _UST_TRACEPOINT_H
2 #define _UST_TRACEPOINT_H
5 * Copyright (C) 2008 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
6 * Copyright (C) 2009 Pierre-Marc Fournier
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library 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 GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; 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.
29 #include <ust/immediate.h>
36 const char *name
; /* Tracepoint name */
37 DEFINE_IMV(char, state
); /* State. */
39 } __attribute__((aligned(32))); /*
40 * Aligned on 32 bytes because it is
41 * globally visible and gcc happily
42 * align these on the structure size.
43 * Keep in sync with vmlinux.lds.h.
46 #define TP_PROTO(args...) args
47 #define TP_ARGS(args...) args
49 #define CONFIG_TRACEPOINTS
50 #ifdef CONFIG_TRACEPOINTS
53 * it_func[0] is never NULL because there is at least one element in the array
54 * when the array itself is non NULL.
56 #define __DO_TRACE(tp, proto, args) \
60 rcu_read_lock(); /*ust rcu_read_lock_sched_notrace(); */ \
61 it_func = rcu_dereference((tp)->funcs); \
64 ((void(*)(proto))(*it_func))(args); \
65 } while (*(++it_func)); \
67 rcu_read_unlock(); /*ust rcu_read_unlock_sched_notrace(); */ \
70 #define __CHECK_TRACE(name, generic, proto, args) \
73 if (unlikely(imv_read(__tracepoint_##name.state))) \
74 __DO_TRACE(&__tracepoint_##name, \
75 TP_PROTO(proto), TP_ARGS(args)); \
77 if (unlikely(_imv_read(__tracepoint_##name.state))) \
78 __DO_TRACE(&__tracepoint_##name, \
79 TP_PROTO(proto), TP_ARGS(args)); \
84 * Make sure the alignment of the structure in the __tracepoints section will
85 * not add unwanted padding between the beginning of the section and the
86 * structure. Force alignment to the same alignment as the section start.
88 * The "generic" argument, passed to the declared __trace_##name inline
89 * function controls which tracepoint enabling mechanism must be used.
90 * If generic is true, a variable read is used.
91 * If generic is false, immediate values are used.
93 #define DECLARE_TRACE(name, proto, args) \
94 extern struct tracepoint __tracepoint_##name; \
95 static inline void trace_##name(proto) \
97 __CHECK_TRACE(name, 0, TP_PROTO(proto), TP_ARGS(args)); \
99 static inline void _trace_##name(proto) \
101 __CHECK_TRACE(name, 1, TP_PROTO(proto), TP_ARGS(args)); \
103 static inline int register_trace_##name(void (*probe)(proto)) \
105 return tracepoint_probe_register(#name, (void *)probe); \
107 static inline int unregister_trace_##name(void (*probe)(proto)) \
109 return tracepoint_probe_unregister(#name, (void *)probe);\
112 #define DEFINE_TRACE(name) \
113 static const char __tpstrtab_##name[] \
114 __attribute__((section("__tracepoints_strings"))) = #name; \
115 struct tracepoint __tracepoint_##name \
116 __attribute__((section("__tracepoints"), aligned(32))) = \
117 { __tpstrtab_##name, 0, NULL }
119 extern void tracepoint_update_probe_range(struct tracepoint
*begin
,
120 struct tracepoint
*end
);
122 #else /* !CONFIG_TRACEPOINTS */
123 #define DECLARE_TRACE(name, proto, args) \
124 static inline void trace_##name(proto) \
126 static inline void _trace_##name(proto) \
128 static inline int register_trace_##name(void (*probe)(proto)) \
132 static inline int unregister_trace_##name(void (*probe)(proto)) \
137 #define DEFINE_TRACE(name)
138 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
139 #define EXPORT_TRACEPOINT_SYMBOL(name)
141 static inline void tracepoint_update_probe_range(struct tracepoint
*begin
,
142 struct tracepoint
*end
)
144 #endif /* CONFIG_TRACEPOINTS */
147 * Connect a probe to a tracepoint.
148 * Internal API, should not be used directly.
150 extern int tracepoint_probe_register(const char *name
, void *probe
);
153 * Disconnect a probe from a tracepoint.
154 * Internal API, should not be used directly.
156 extern int tracepoint_probe_unregister(const char *name
, void *probe
);
158 extern int tracepoint_probe_register_noupdate(const char *name
, void *probe
);
159 extern int tracepoint_probe_unregister_noupdate(const char *name
, void *probe
);
160 extern void tracepoint_probe_update_all(void);
162 struct tracepoint_iter
{
163 //ust// struct module *module;
164 struct tracepoint_lib
*lib
;
165 struct tracepoint
*tracepoint
;
168 extern void tracepoint_iter_start(struct tracepoint_iter
*iter
);
169 extern void tracepoint_iter_next(struct tracepoint_iter
*iter
);
170 extern void tracepoint_iter_stop(struct tracepoint_iter
*iter
);
171 extern void tracepoint_iter_reset(struct tracepoint_iter
*iter
);
172 extern int tracepoint_get_iter_range(struct tracepoint
**tracepoint
,
173 struct tracepoint
*begin
, struct tracepoint
*end
);
176 * tracepoint_synchronize_unregister must be called between the last tracepoint
177 * probe unregistration and the end of module exit to make sure there is no
178 * caller executing a probe when it is freed.
180 static inline void tracepoint_synchronize_unregister(void)
182 //ust// synchronize_sched();
185 struct tracepoint_lib
{
186 struct tracepoint
*tracepoints_start
;
187 int tracepoints_count
;
188 struct list_head list
;
191 extern int tracepoint_register_lib(struct tracepoint
*tracepoints_start
,
192 int tracepoints_count
);
193 extern int tracepoint_unregister_lib(struct tracepoint
*tracepoints_start
);
195 #define TRACEPOINT_LIB \
196 extern struct tracepoint __start___tracepoints[] __attribute__((weak, visibility("hidden"))); \
197 extern struct tracepoint __stop___tracepoints[] __attribute__((weak, visibility("hidden"))); \
198 static void __attribute__((constructor)) __tracepoints__init(void) \
200 tracepoint_register_lib(__start___tracepoints, \
201 (((long)__stop___tracepoints)-((long)__start___tracepoints))/sizeof(struct tracepoint)); \
204 static void __attribute__((destructor)) __tracepoints__destroy(void) \
206 tracepoint_unregister_lib(__start___tracepoints); \
209 #endif /* _UST_TRACEPOINT_H */
This page took 0.03473 seconds and 6 git commands to generate.