fda2aba900906bab5a440ad662e2375d6305336c
1 #ifndef _LINUX_TRACEPOINT_H
2 #define _LINUX_TRACEPOINT_H
5 * Kernel Tracepoint API.
7 * See Documentation/tracepoint.txt.
9 * (C) Copyright 2008 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
11 * Heavily inspired from the Linux Kernel Markers.
13 * This file is released under the GPLv2.
14 * See the file COPYING for more details.
17 //#include <linux/immediate.h>
18 //#include <linux/types.h>
19 //#include <linux/rcupdate.h>
21 #include "immediate.h"
22 #include "kernelcompat.h"
28 const char *name
; /* Tracepoint name */
29 DEFINE_IMV(char, state
); /* State. */
31 } __attribute__((aligned(32))); /*
32 * Aligned on 32 bytes because it is
33 * globally visible and gcc happily
34 * align these on the structure size.
35 * Keep in sync with vmlinux.lds.h.
38 #define TPPROTO(args...) args
39 #define TPARGS(args...) args
41 //ust// #ifdef CONFIG_TRACEPOINTS
44 * it_func[0] is never NULL because there is at least one element in the array
45 * when the array itself is non NULL.
47 #define __DO_TRACE(tp, proto, args) \
51 rcu_read_lock_sched_notrace(); \
52 it_func = rcu_dereference((tp)->funcs); \
55 ((void(*)(proto))(*it_func))(args); \
56 } while (*(++it_func)); \
58 rcu_read_unlock_sched_notrace(); \
61 #define __CHECK_TRACE(name, generic, proto, args) \
64 if (unlikely(imv_read(__tracepoint_##name.state))) \
65 __DO_TRACE(&__tracepoint_##name, \
66 TPPROTO(proto), TPARGS(args)); \
68 if (unlikely(_imv_read(__tracepoint_##name.state))) \
69 __DO_TRACE(&__tracepoint_##name, \
70 TPPROTO(proto), TPARGS(args)); \
75 * Make sure the alignment of the structure in the __tracepoints section will
76 * not add unwanted padding between the beginning of the section and the
77 * structure. Force alignment to the same alignment as the section start.
79 * The "generic" argument, passed to the declared __trace_##name inline
80 * function controls which tracepoint enabling mechanism must be used.
81 * If generic is true, a variable read is used.
82 * If generic is false, immediate values are used.
84 #define DECLARE_TRACE(name, proto, args) \
85 extern struct tracepoint __tracepoint_##name; \
86 static inline void trace_##name(proto) \
88 __CHECK_TRACE(name, 0, TPPROTO(proto), TPARGS(args)); \
90 static inline void _trace_##name(proto) \
92 __CHECK_TRACE(name, 1, TPPROTO(proto), TPARGS(args)); \
94 static inline int register_trace_##name(void (*probe)(proto)) \
96 return tracepoint_probe_register(#name, (void *)probe); \
98 static inline int unregister_trace_##name(void (*probe)(proto)) \
100 return tracepoint_probe_unregister(#name, (void *)probe);\
103 #define DEFINE_TRACE(name) \
104 static const char __tpstrtab_##name[] \
105 __attribute__((section("__tracepoints_strings"))) = #name; \
106 struct tracepoint __tracepoint_##name \
107 __attribute__((section("__tracepoints"), aligned(32))) = \
108 { __tpstrtab_##name, 0, NULL }
110 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name) \
111 EXPORT_SYMBOL_GPL(__tracepoint_##name)
112 #define EXPORT_TRACEPOINT_SYMBOL(name) \
113 EXPORT_SYMBOL(__tracepoint_##name)
115 extern void tracepoint_update_probe_range(struct tracepoint
*begin
,
116 struct tracepoint
*end
);
118 //ust// #else /* !CONFIG_TRACEPOINTS */
119 //ust// #define DECLARE_TRACE(name, proto, args) \
120 //ust// static inline void trace_##name(proto) \
122 //ust// static inline void _trace_##name(proto) \
124 //ust// static inline int register_trace_##name(void (*probe)(proto)) \
126 //ust// return -ENOSYS; \
128 //ust// static inline int unregister_trace_##name(void (*probe)(proto)) \
130 //ust// return -ENOSYS; \
133 //ust// #define DEFINE_TRACE(name)
134 //ust// #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
135 //ust// #define EXPORT_TRACEPOINT_SYMBOL(name)
137 //ust// static inline void tracepoint_update_probe_range(struct tracepoint *begin,
138 //ust// struct tracepoint *end)
140 //ust// #endif /* CONFIG_TRACEPOINTS */
143 * Connect a probe to a tracepoint.
144 * Internal API, should not be used directly.
146 extern int tracepoint_probe_register(const char *name
, void *probe
);
149 * Disconnect a probe from a tracepoint.
150 * Internal API, should not be used directly.
152 extern int tracepoint_probe_unregister(const char *name
, void *probe
);
154 extern int tracepoint_probe_register_noupdate(const char *name
, void *probe
);
155 extern int tracepoint_probe_unregister_noupdate(const char *name
, void *probe
);
156 extern void tracepoint_probe_update_all(void);
158 struct tracepoint_iter
{
159 //ust// struct module *module;
160 struct tracepoint_lib
*lib
;
161 struct tracepoint
*tracepoint
;
164 extern void tracepoint_iter_start(struct tracepoint_iter
*iter
);
165 extern void tracepoint_iter_next(struct tracepoint_iter
*iter
);
166 extern void tracepoint_iter_stop(struct tracepoint_iter
*iter
);
167 extern void tracepoint_iter_reset(struct tracepoint_iter
*iter
);
168 extern int tracepoint_get_iter_range(struct tracepoint
**tracepoint
,
169 struct tracepoint
*begin
, struct tracepoint
*end
);
172 * tracepoint_synchronize_unregister must be called between the last tracepoint
173 * probe unregistration and the end of module exit to make sure there is no
174 * caller executing a probe when it is freed.
176 static inline void tracepoint_synchronize_unregister(void)
181 struct tracepoint_lib
{
182 struct tracepoint
*tracepoints_start
;
183 int tracepoints_count
;
184 struct list_head list
;
187 #define TRACEPOINT_LIB \
188 extern struct tracepoint __start___tracepoints[] __attribute__((visibility("hidden"))); \
189 extern struct tracepoint __stop___tracepoints[] __attribute__((visibility("hidden"))); \
191 static void __attribute__((constructor)) __tracepoints__init(void) \
193 tracepoint_register_lib(__start___tracepoints, (((long)__stop___tracepoints)-((long)__start___tracepoints))/sizeof(struct tracepoint));\
This page took 0.033052 seconds and 4 git commands to generate.