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>
25 const char *name
; /* Tracepoint name */
26 DEFINE_IMV(char, state
); /* State. */
28 } __attribute__((aligned(32))); /*
29 * Aligned on 32 bytes because it is
30 * globally visible and gcc happily
31 * align these on the structure size.
32 * Keep in sync with vmlinux.lds.h.
35 #define TPPROTO(args...) args
36 #define TPARGS(args...) args
38 #ifdef CONFIG_TRACEPOINTS
41 * it_func[0] is never NULL because there is at least one element in the array
42 * when the array itself is non NULL.
44 #define __DO_TRACE(tp, proto, args) \
48 rcu_read_lock_sched_notrace(); \
49 it_func = rcu_dereference((tp)->funcs); \
52 ((void(*)(proto))(*it_func))(args); \
53 } while (*(++it_func)); \
55 rcu_read_unlock_sched_notrace(); \
58 #define __CHECK_TRACE(name, generic, proto, args) \
61 if (unlikely(imv_read(__tracepoint_##name.state))) \
62 __DO_TRACE(&__tracepoint_##name, \
63 TPPROTO(proto), TPARGS(args)); \
65 if (unlikely(_imv_read(__tracepoint_##name.state))) \
66 __DO_TRACE(&__tracepoint_##name, \
67 TPPROTO(proto), TPARGS(args)); \
72 * Make sure the alignment of the structure in the __tracepoints section will
73 * not add unwanted padding between the beginning of the section and the
74 * structure. Force alignment to the same alignment as the section start.
76 * The "generic" argument, passed to the declared __trace_##name inline
77 * function controls which tracepoint enabling mechanism must be used.
78 * If generic is true, a variable read is used.
79 * If generic is false, immediate values are used.
81 #define DECLARE_TRACE(name, proto, args) \
82 extern struct tracepoint __tracepoint_##name; \
83 static inline void trace_##name(proto) \
85 __CHECK_TRACE(name, 0, TPPROTO(proto), TPARGS(args)); \
87 static inline void _trace_##name(proto) \
89 __CHECK_TRACE(name, 1, TPPROTO(proto), TPARGS(args)); \
91 static inline int register_trace_##name(void (*probe)(proto)) \
93 return tracepoint_probe_register(#name, (void *)probe); \
95 static inline int unregister_trace_##name(void (*probe)(proto)) \
97 return tracepoint_probe_unregister(#name, (void *)probe);\
100 #define DEFINE_TRACE(name) \
101 static const char __tpstrtab_##name[] \
102 __attribute__((section("__tracepoints_strings"))) = #name; \
103 struct tracepoint __tracepoint_##name \
104 __attribute__((section("__tracepoints"), aligned(32))) = \
105 { __tpstrtab_##name, 0, NULL }
107 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name) \
108 EXPORT_SYMBOL_GPL(__tracepoint_##name)
109 #define EXPORT_TRACEPOINT_SYMBOL(name) \
110 EXPORT_SYMBOL(__tracepoint_##name)
112 extern void tracepoint_update_probe_range(struct tracepoint
*begin
,
113 struct tracepoint
*end
);
115 #else /* !CONFIG_TRACEPOINTS */
116 #define DECLARE_TRACE(name, proto, args) \
117 static inline void trace_##name(proto) \
119 static inline void _trace_##name(proto) \
121 static inline int register_trace_##name(void (*probe)(proto)) \
125 static inline int unregister_trace_##name(void (*probe)(proto)) \
130 #define DEFINE_TRACE(name)
131 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
132 #define EXPORT_TRACEPOINT_SYMBOL(name)
134 static inline void tracepoint_update_probe_range(struct tracepoint
*begin
,
135 struct tracepoint
*end
)
137 #endif /* CONFIG_TRACEPOINTS */
140 * Connect a probe to a tracepoint.
141 * Internal API, should not be used directly.
143 extern int tracepoint_probe_register(const char *name
, void *probe
);
146 * Disconnect a probe from a tracepoint.
147 * Internal API, should not be used directly.
149 extern int tracepoint_probe_unregister(const char *name
, void *probe
);
151 extern int tracepoint_probe_register_noupdate(const char *name
, void *probe
);
152 extern int tracepoint_probe_unregister_noupdate(const char *name
, void *probe
);
153 extern void tracepoint_probe_update_all(void);
155 struct tracepoint_iter
{
156 struct module
*module
;
157 struct tracepoint
*tracepoint
;
160 extern void tracepoint_iter_start(struct tracepoint_iter
*iter
);
161 extern void tracepoint_iter_next(struct tracepoint_iter
*iter
);
162 extern void tracepoint_iter_stop(struct tracepoint_iter
*iter
);
163 extern void tracepoint_iter_reset(struct tracepoint_iter
*iter
);
164 extern int tracepoint_get_iter_range(struct tracepoint
**tracepoint
,
165 struct tracepoint
*begin
, struct tracepoint
*end
);
168 * tracepoint_synchronize_unregister must be called between the last tracepoint
169 * probe unregistration and the end of module exit to make sure there is no
170 * caller executing a probe when it is freed.
172 static inline void tracepoint_synchronize_unregister(void)
This page took 0.033455 seconds and 4 git commands to generate.